use of org.apache.syncope.core.persistence.api.dao.search.SearchCond in project syncope by apache.
the class AnySearchTest method assignable.
@Test
public void assignable() {
AssignableCond assignableCond = new AssignableCond();
assignableCond.setRealmFullPath("/even/two");
SearchCond searchCondition = SearchCond.getLeafCond(assignableCond);
assertTrue(searchCondition.isValid());
List<Group> groups = searchDAO.search(searchCondition, AnyTypeKind.GROUP);
assertTrue(groups.stream().anyMatch(group -> "additional".equals(group.getName())));
assertFalse(groups.stream().anyMatch(group -> "fake".equals(group.getName())));
assignableCond = new AssignableCond();
assignableCond.setRealmFullPath("/odd");
searchCondition = SearchCond.getLeafCond(assignableCond);
assertTrue(searchCondition.isValid());
List<AnyObject> anyObjects = searchDAO.search(searchCondition, AnyTypeKind.ANY_OBJECT);
assertFalse(anyObjects.stream().anyMatch(anyObject -> "9e1d130c-d6a3-48b1-98b3-182477ed0688".equals(anyObject.getKey())));
}
use of org.apache.syncope.core.persistence.api.dao.search.SearchCond in project syncope by apache.
the class AnySearchTest method searchByRelationshipType.
@Test
public void searchByRelationshipType() {
// 1. first search for printers involved in "neighborhood" relationship
RelationshipTypeCond relationshipTypeCond = new RelationshipTypeCond();
relationshipTypeCond.setRelationshipTypeKey("neighborhood");
AnyTypeCond tcond = new AnyTypeCond();
tcond.setAnyTypeKey("PRINTER");
SearchCond searchCondition = SearchCond.getAndCond(SearchCond.getLeafCond(relationshipTypeCond), SearchCond.getLeafCond(tcond));
assertTrue(searchCondition.isValid());
List<AnyObject> anyObjects = searchDAO.search(searchCondition, AnyTypeKind.ANY_OBJECT);
assertNotNull(anyObjects);
assertEquals(2, anyObjects.size());
assertTrue(anyObjects.stream().anyMatch(any -> "fc6dbc3a-6c07-4965-8781-921e7401a4a5".equals(any.getKey())));
assertTrue(anyObjects.stream().anyMatch(any -> "8559d14d-58c2-46eb-a2d4-a7d35161e8f8".equals(any.getKey())));
// 2. search for users involved in "neighborhood" relationship
searchCondition = SearchCond.getLeafCond(relationshipTypeCond);
List<User> users = searchDAO.search(searchCondition, AnyTypeKind.USER);
assertNotNull(users);
assertEquals(1, users.size());
assertTrue(users.stream().anyMatch(any -> "c9b2dec2-00a7-4855-97c0-d854842b4b24".equals(any.getKey())));
}
use of org.apache.syncope.core.persistence.api.dao.search.SearchCond 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());
}
use of org.apache.syncope.core.persistence.api.dao.search.SearchCond in project syncope by apache.
the class AnySearchTest method searchWithNotCondition.
@Test
public void searchWithNotCondition() {
AttributeCond fullnameLeafCond = new AttributeCond(AttributeCond.Type.EQ);
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.SearchCond in project syncope by apache.
the class AnySearchTest method searchWithLikeCondition.
@Test
public void searchWithLikeCondition() {
AttributeCond fullnameLeafCond = new AttributeCond(AttributeCond.Type.LIKE);
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