use of org.apache.syncope.core.persistence.api.dao.search.AttributeCond in project syncope by apache.
the class SearchCondConverterTest method isNull.
@Test
public void isNull() {
String fiql = new UserFiqlSearchConditionBuilder().is("loginDate").nullValue().query();
assertEquals("loginDate==" + SpecialAttr.NULL, fiql);
AttributeCond attrCond = new AttributeCond(AttributeCond.Type.ISNULL);
attrCond.setSchema("loginDate");
SearchCond simpleCond = SearchCond.getLeafCond(attrCond);
assertEquals(simpleCond, SearchCondConverter.convert(fiql));
}
use of org.apache.syncope.core.persistence.api.dao.search.AttributeCond in project syncope by apache.
the class SearchCondVisitor method createAttributeCond.
private AttributeCond createAttributeCond(final String schema) {
AttributeCond attributeCond = SearchableFields.contains(schema) ? new AnyCond() : new AttributeCond();
attributeCond.setSchema(schema);
return attributeCond;
}
use of org.apache.syncope.core.persistence.api.dao.search.AttributeCond in project syncope by apache.
the class AnySearchTest method searchByBoolean.
@Test
public void searchByBoolean() {
AttributeCond coolLeafCond = new AttributeCond(AttributeCond.Type.EQ);
coolLeafCond.setSchema("cool");
coolLeafCond.setExpression("true");
SearchCond cond = SearchCond.getLeafCond(coolLeafCond);
assertTrue(cond.isValid());
List<User> users = searchDAO.search(cond, AnyTypeKind.USER);
assertNotNull(users);
assertEquals(1, users.size());
assertEquals("c9b2dec2-00a7-4855-97c0-d854842b4b24", users.get(0).getKey());
}
use of org.apache.syncope.core.persistence.api.dao.search.AttributeCond in project syncope by apache.
the class AnySearchTest method searchCaseInsensitiveWithNotCondition.
@Test
public void searchCaseInsensitiveWithNotCondition() {
AttributeCond fullnameLeafCond = new AttributeCond(AttributeCond.Type.IEQ);
fullnameLeafCond.setSchema("fullname");
fullnameLeafCond.setExpression("giuseppe verdi");
SearchCond cond = SearchCond.getNotLeafCond(fullnameLeafCond);
assertTrue(cond.isValid());
List<User> users = searchDAO.search(cond, AnyTypeKind.USER);
assertNotNull(users);
assertEquals(4, users.size());
Set<String> ids = users.stream().map(Entity::getKey).collect(Collectors.toSet());
assertTrue(ids.contains("1417acbe-cbf6-4277-9372-e75e04f97000"));
assertTrue(ids.contains("b3cbc78d-32e6-4bd4-92e0-bbe07566a2ee"));
}
use of org.apache.syncope.core.persistence.api.dao.search.AttributeCond in project syncope by apache.
the class AnySearchTest method searchCaseInsensitiveWithLikeCondition.
@Test
public void searchCaseInsensitiveWithLikeCondition() {
AttributeCond fullnameLeafCond = new AttributeCond(AttributeCond.Type.ILIKE);
fullnameLeafCond.setSchema("fullname");
fullnameLeafCond.setExpression("%O%");
MembershipCond groupCond = new MembershipCond();
groupCond.setGroup("root");
AttributeCond loginDateCond = new AttributeCond(AttributeCond.Type.EQ);
loginDateCond.setSchema("loginDate");
loginDateCond.setExpression("2009-05-26");
SearchCond subCond = SearchCond.getAndCond(SearchCond.getLeafCond(fullnameLeafCond), SearchCond.getLeafCond(groupCond));
assertTrue(subCond.isValid());
SearchCond cond = SearchCond.getAndCond(subCond, SearchCond.getLeafCond(loginDateCond));
assertTrue(cond.isValid());
List<User> users = searchDAO.search(cond, AnyTypeKind.USER);
assertNotNull(users);
assertEquals(1, users.size());
}
Aggregations