-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(isnull-operator): implement ISNULL operator
- Loading branch information
1 parent
4fbc96e
commit b253ce1
Showing
4 changed files
with
50 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
querydsl-postgrest/src/main/java/fr/ouestfrance/querydsl/postgrest/mappers/IsNullMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package fr.ouestfrance.querydsl.postgrest.mappers; | ||
|
||
import fr.ouestfrance.querydsl.FilterOperation; | ||
import fr.ouestfrance.querydsl.postgrest.model.Filter; | ||
import fr.ouestfrance.querydsl.postgrest.model.impl.QueryFilter; | ||
|
||
public class IsNullMapper extends AbstractMapper { | ||
|
||
@Override | ||
public Filter getFilter(String field, Object value) { | ||
return QueryFilter.of(field, Boolean.TRUE.equals(value) ? Operators.IS : Operators.IS_NOT, null); | ||
} | ||
|
||
@Override | ||
public Class<? extends FilterOperation> operation() { | ||
return FilterOperation.ISNULL.class; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...l-postgrest/src/test/java/fr/ouestfrance/querydsl/postgrest/mappers/IsNullMapperTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package fr.ouestfrance.querydsl.postgrest.mappers; | ||
|
||
import fr.ouestfrance.querydsl.FilterOperation; | ||
import fr.ouestfrance.querydsl.model.SimpleFilter; | ||
import fr.ouestfrance.querydsl.postgrest.builders.QueryFilterVisitor; | ||
import fr.ouestfrance.querydsl.postgrest.model.Filter; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
class IsNullMapperTest { | ||
|
||
@Test | ||
void shouldMapIsNull() { | ||
IsNullMapper mapper = new IsNullMapper(); | ||
assertNotNull(mapper.operation()); | ||
Filter result = mapper.map(new SimpleFilter("name", FilterOperation.ISNULL.class, false, null), Boolean.TRUE); | ||
assertNotNull(result); | ||
QueryFilterVisitor visitor = new QueryFilterVisitor(); | ||
result.accept(visitor); | ||
assertNotNull(visitor.getValue()); | ||
assertEquals("is.null", visitor.getValue()); | ||
} | ||
} |