-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(logical-operators): add Operator ISNULL for filtering on NULL va…
…lues
- Loading branch information
1 parent
9665201
commit 67e295b
Showing
4 changed files
with
66 additions
and
1 deletion.
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
20 changes: 20 additions & 0 deletions
20
src/main/java/fr/ouestfrance/querydsl/service/validators/impl/BooleanValidator.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,20 @@ | ||
package fr.ouestfrance.querydsl.service.validators.impl; | ||
|
||
import fr.ouestfrance.querydsl.service.validators.FilterFieldValidator; | ||
import lombok.NoArgsConstructor; | ||
|
||
/** | ||
* Validator that handle filter on Boolean | ||
*/ | ||
@NoArgsConstructor | ||
public class BooleanValidator implements FilterFieldValidator { | ||
@Override | ||
public boolean validate(Class<?> clazz) { | ||
return Boolean.class.isAssignableFrom(clazz); | ||
} | ||
|
||
@Override | ||
public String message() { | ||
return "should be applied to Boolean"; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/test/java/fr/ouestfrance/querydsl/service/validators/impl/BooleanValidatorTest.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,37 @@ | ||
package fr.ouestfrance.querydsl.service.validators.impl; | ||
|
||
import fr.ouestfrance.querydsl.service.validators.FilterFieldValidator; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.math.BigDecimal; | ||
import java.time.LocalDate; | ||
import java.time.LocalDateTime; | ||
import java.util.*; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
class BooleanValidatorTest { | ||
|
||
private final FilterFieldValidator validator = new BooleanValidator(); | ||
@Test | ||
void shouldValidate(){ | ||
assertTrue(validator.validate(Boolean.class)); | ||
} | ||
|
||
@Test | ||
void shouldUnValidate(){ | ||
assertFalse(validator.validate(String.class)); | ||
assertFalse(validator.validate(Double.class)); | ||
assertFalse(validator.validate(LocalDate.class)); | ||
assertFalse(validator.validate(LocalDateTime.class)); | ||
assertFalse(validator.validate(Date.class)); | ||
assertFalse(validator.validate(UUID.class)); | ||
assertFalse(validator.validate(Integer.class)); | ||
assertFalse(validator.validate(BigDecimal.class)); | ||
assertFalse(validator.validate(Set.class)); | ||
assertFalse(validator.validate(ArrayList.class)); | ||
assertFalse(validator.validate(LinkedList.class)); | ||
assertFalse(validator.validate(HashSet.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