Search in sources :

Example 11 with MembershipCond

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());
}
Also used : User(org.apache.syncope.core.persistence.api.entity.user.User) OrderByClause(org.apache.syncope.core.persistence.api.dao.search.OrderByClause) AttributeCond(org.apache.syncope.core.persistence.api.dao.search.AttributeCond) MembershipCond(org.apache.syncope.core.persistence.api.dao.search.MembershipCond) SearchCond(org.apache.syncope.core.persistence.api.dao.search.SearchCond) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Aggregations

MembershipCond (org.apache.syncope.core.persistence.api.dao.search.MembershipCond)11 SearchCond (org.apache.syncope.core.persistence.api.dao.search.SearchCond)8 Test (org.junit.jupiter.api.Test)7 User (org.apache.syncope.core.persistence.api.entity.user.User)6 AbstractTest (org.apache.syncope.core.persistence.jpa.AbstractTest)6 AttributeCond (org.apache.syncope.core.persistence.api.dao.search.AttributeCond)4 OrderByClause (org.apache.syncope.core.persistence.api.dao.search.OrderByClause)3 AnyTypeCond (org.apache.syncope.core.persistence.api.dao.search.AnyTypeCond)2 PrivilegeCond (org.apache.syncope.core.persistence.api.dao.search.PrivilegeCond)2 RelationshipCond (org.apache.syncope.core.persistence.api.dao.search.RelationshipCond)2 RelationshipTypeCond (org.apache.syncope.core.persistence.api.dao.search.RelationshipTypeCond)2 RoleCond (org.apache.syncope.core.persistence.api.dao.search.RoleCond)2 Member (org.apache.syncope.ext.scimv2.api.data.Member)2 SCIMGroup (org.apache.syncope.ext.scimv2.api.data.SCIMGroup)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1