use of org.apache.syncope.core.persistence.api.dao.search.SearchCond 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.SearchCond in project syncope by apache.
the class AnySearchTest method member.
@Test
public void member() {
MemberCond memberCond = new MemberCond();
memberCond.setMember("1417acbe-cbf6-4277-9372-e75e04f97000");
SearchCond searchCondition = SearchCond.getLeafCond(memberCond);
assertTrue(searchCondition.isValid());
List<Group> groups = searchDAO.search(searchCondition, AnyTypeKind.GROUP);
assertEquals(2, groups.size());
assertTrue(groups.contains(groupDAO.findByName("root")));
assertTrue(groups.contains(groupDAO.findByName("otherchild")));
}
use of org.apache.syncope.core.persistence.api.dao.search.SearchCond in project syncope by apache.
the class AnySearchTest method issue202.
@Test
public void issue202() {
ResourceCond ws2 = new ResourceCond();
ws2.setResourceKey("ws-target-resource-2");
ResourceCond ws1 = new ResourceCond();
ws1.setResourceKey("ws-target-resource-list-mappings-1");
SearchCond searchCondition = SearchCond.getAndCond(SearchCond.getNotLeafCond(ws2), SearchCond.getNotLeafCond(ws1));
assertTrue(searchCondition.isValid());
List<User> users = searchDAO.search(searchCondition, AnyTypeKind.USER);
assertNotNull(users);
assertEquals(2, users.size());
assertTrue(users.stream().anyMatch(user -> "c9b2dec2-00a7-4855-97c0-d854842b4b24".equals(user.getKey())));
}
use of org.apache.syncope.core.persistence.api.dao.search.SearchCond 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.SearchCond in project syncope by apache.
the class AnySearchTest method searchByResource.
@Test
public void searchByResource() {
ResourceCond ws2 = new ResourceCond();
ws2.setResourceKey("ws-target-resource-2");
ResourceCond ws1 = new ResourceCond();
ws1.setResourceKey("ws-target-resource-list-mappings-2");
SearchCond searchCondition = SearchCond.getAndCond(SearchCond.getNotLeafCond(ws2), SearchCond.getLeafCond(ws1));
assertTrue(searchCondition.isValid());
List<User> users = searchDAO.search(searchCondition, AnyTypeKind.USER);
assertNotNull(users);
assertEquals(1, users.size());
}
Aggregations