Search in sources :

Example 31 with AttributeCond

use of org.apache.syncope.core.persistence.api.dao.search.AttributeCond in project syncope by apache.

the class AnySearchTest method searchByBooleanAnyCond.

@Test
public void searchByBooleanAnyCond() {
    AttributeCond booleanCond = new AttributeCond(AnyCond.Type.EQ);
    booleanCond.setSchema("show");
    booleanCond.setExpression("true");
    List<Group> matchingGroups = searchDAO.search(SearchCond.getLeafCond(booleanCond), AnyTypeKind.GROUP);
    assertNotNull(matchingGroups);
    assertFalse(matchingGroups.isEmpty());
}
Also used : Group(org.apache.syncope.core.persistence.api.entity.group.Group) AttributeCond(org.apache.syncope.core.persistence.api.dao.search.AttributeCond) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Example 32 with AttributeCond

use of org.apache.syncope.core.persistence.api.dao.search.AttributeCond in project syncope by apache.

the class AnySearchTest method searchByUsernameAndFullnameIgnoreCase.

@Test
public void searchByUsernameAndFullnameIgnoreCase() {
    AnyCond usernameLeafCond = new AnyCond(AnyCond.Type.IEQ);
    usernameLeafCond.setSchema("username");
    usernameLeafCond.setExpression("RoSsini");
    AttributeCond idRightCond = new AttributeCond(AttributeCond.Type.ILIKE);
    idRightCond.setSchema("fullname");
    idRightCond.setExpression("gIuseppe v%");
    SearchCond searchCondition = SearchCond.getOrCond(SearchCond.getLeafCond(usernameLeafCond), SearchCond.getLeafCond(idRightCond));
    List<User> matchingUsers = searchDAO.search(searchCondition, AnyTypeKind.USER);
    assertNotNull(matchingUsers);
    assertEquals(2, matchingUsers.size());
}
Also used : User(org.apache.syncope.core.persistence.api.entity.user.User) AttributeCond(org.apache.syncope.core.persistence.api.dao.search.AttributeCond) SearchCond(org.apache.syncope.core.persistence.api.dao.search.SearchCond) AnyCond(org.apache.syncope.core.persistence.api.dao.search.AnyCond) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Example 33 with AttributeCond

use of org.apache.syncope.core.persistence.api.dao.search.AttributeCond in project syncope by apache.

the class AnySearchTest method searchByIsNull.

@Test
public void searchByIsNull() {
    AttributeCond coolLeafCond = new AttributeCond(AttributeCond.Type.ISNULL);
    coolLeafCond.setSchema("cool");
    List<User> users = searchDAO.search(SearchCond.getLeafCond(coolLeafCond), AnyTypeKind.USER);
    assertNotNull(users);
    assertEquals(4, users.size());
    coolLeafCond = new AttributeCond(AttributeCond.Type.ISNOTNULL);
    coolLeafCond.setSchema("cool");
    users = searchDAO.search(SearchCond.getLeafCond(coolLeafCond), AnyTypeKind.USER);
    assertNotNull(users);
    assertEquals(1, users.size());
}
Also used : User(org.apache.syncope.core.persistence.api.entity.user.User) AttributeCond(org.apache.syncope.core.persistence.api.dao.search.AttributeCond) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Example 34 with AttributeCond

use of org.apache.syncope.core.persistence.api.dao.search.AttributeCond 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)

Example 35 with AttributeCond

use of org.apache.syncope.core.persistence.api.dao.search.AttributeCond in project syncope by apache.

the class AnySearchTest method userOrderBy.

@Test
public void userOrderBy() {
    AnyCond usernameLeafCond = new AnyCond(AnyCond.Type.EQ);
    usernameLeafCond.setSchema("username");
    usernameLeafCond.setExpression("rossini");
    AttributeCond idRightCond = new AttributeCond(AttributeCond.Type.LIKE);
    idRightCond.setSchema("fullname");
    idRightCond.setExpression("Giuseppe V%");
    SearchCond searchCondition = SearchCond.getOrCond(SearchCond.getLeafCond(usernameLeafCond), SearchCond.getLeafCond(idRightCond));
    List<OrderByClause> orderByClauses = new ArrayList<>();
    OrderByClause orderByClause = new OrderByClause();
    orderByClause.setField("username");
    orderByClause.setDirection(OrderByClause.Direction.DESC);
    orderByClauses.add(orderByClause);
    orderByClause = new OrderByClause();
    orderByClause.setField("fullname");
    orderByClause.setDirection(OrderByClause.Direction.ASC);
    orderByClauses.add(orderByClause);
    List<User> users = searchDAO.search(searchCondition, orderByClauses, AnyTypeKind.USER);
    assertEquals(searchDAO.count(SyncopeConstants.FULL_ADMIN_REALMS, searchCondition, AnyTypeKind.USER), users.size());
}
Also used : OrderByClause(org.apache.syncope.core.persistence.api.dao.search.OrderByClause) User(org.apache.syncope.core.persistence.api.entity.user.User) AttributeCond(org.apache.syncope.core.persistence.api.dao.search.AttributeCond) ArrayList(java.util.ArrayList) SearchCond(org.apache.syncope.core.persistence.api.dao.search.SearchCond) AnyCond(org.apache.syncope.core.persistence.api.dao.search.AnyCond) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Aggregations

AttributeCond (org.apache.syncope.core.persistence.api.dao.search.AttributeCond)35 SearchCond (org.apache.syncope.core.persistence.api.dao.search.SearchCond)25 Test (org.junit.jupiter.api.Test)25 AbstractTest (org.apache.syncope.core.persistence.jpa.AbstractTest)16 User (org.apache.syncope.core.persistence.api.entity.user.User)15 AnyCond (org.apache.syncope.core.persistence.api.dao.search.AnyCond)12 UserFiqlSearchConditionBuilder (org.apache.syncope.common.lib.search.UserFiqlSearchConditionBuilder)8 ArrayList (java.util.ArrayList)4 MembershipCond (org.apache.syncope.core.persistence.api.dao.search.MembershipCond)4 Map (java.util.Map)3 SCIMUserAddressConf (org.apache.syncope.common.lib.scim.SCIMUserAddressConf)3 SCIMUserConf (org.apache.syncope.common.lib.scim.SCIMUserConf)3 OrderByClause (org.apache.syncope.core.persistence.api.dao.search.OrderByClause)3 Group (org.apache.syncope.core.persistence.api.entity.group.Group)3 Arrays (java.util.Arrays)2 List (java.util.List)2 Optional (java.util.Optional)2 StringUtils (org.apache.commons.lang3.StringUtils)2 SCIMComplexConf (org.apache.syncope.common.lib.scim.SCIMComplexConf)2 SCIMConf (org.apache.syncope.common.lib.scim.SCIMConf)2