use of org.apache.syncope.core.persistence.api.dao.search.MembershipCond in project syncope by apache.
the class AnySearchTest method searchByPageAndSize.
@Test
public void searchByPageAndSize() {
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(SyncopeConstants.FULL_ADMIN_REALMS, cond, 1, 2, Collections.<OrderByClause>emptyList(), AnyTypeKind.USER);
assertNotNull(users);
assertEquals(1, users.size());
users = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS, cond, 2, 2, Collections.<OrderByClause>emptyList(), AnyTypeKind.USER);
assertNotNull(users);
assertTrue(users.isEmpty());
}
Aggregations