Search in sources :

Example 21 with AnyCond

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

the class AnySearchTest method issueSYNCOPE433.

@Test
public void issueSYNCOPE433() {
    AttributeCond isNullCond = new AttributeCond(AttributeCond.Type.ISNULL);
    isNullCond.setSchema("loginDate");
    AnyCond likeCond = new AnyCond(AttributeCond.Type.LIKE);
    likeCond.setSchema("username");
    likeCond.setExpression("%ossin%");
    SearchCond searchCond = SearchCond.getOrCond(SearchCond.getLeafCond(isNullCond), SearchCond.getLeafCond(likeCond));
    Integer count = searchDAO.count(SyncopeConstants.FULL_ADMIN_REALMS, searchCond, AnyTypeKind.USER);
    assertNotNull(count);
    assertTrue(count > 0);
}
Also used : 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 22 with AnyCond

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

the class AnySearchTest method searchByUsernameAndKey.

@Test
public void searchByUsernameAndKey() {
    AnyCond usernameLeafCond = new AnyCond(AnyCond.Type.LIKE);
    usernameLeafCond.setSchema("username");
    usernameLeafCond.setExpression("%ini");
    AnyCond idRightCond = new AnyCond(AnyCond.Type.LT);
    idRightCond.setSchema("id");
    idRightCond.setExpression("2");
    SearchCond searchCondition = SearchCond.getAndCond(SearchCond.getLeafCond(usernameLeafCond), SearchCond.getLeafCond(idRightCond));
    List<User> matching = searchDAO.search(searchCondition, AnyTypeKind.USER);
    assertNotNull(matching);
    assertEquals(1, matching.size());
    assertEquals("rossini", matching.iterator().next().getUsername());
    assertEquals("1417acbe-cbf6-4277-9372-e75e04f97000", matching.iterator().next().getKey());
}
Also used : User(org.apache.syncope.core.persistence.api.entity.user.User) 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 23 with AnyCond

use of org.apache.syncope.core.persistence.api.dao.search.AnyCond 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 24 with AnyCond

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

Example 25 with AnyCond

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

the class AnySearchTest method issue242.

@Test
public void issue242() {
    AnyCond cond = new AnyCond(AttributeCond.Type.LIKE);
    cond.setSchema("id");
    cond.setExpression("test%");
    SearchCond searchCondition = SearchCond.getLeafCond(cond);
    assertTrue(searchCondition.isValid());
    List<User> users = searchDAO.search(searchCondition, AnyTypeKind.USER);
    assertNotNull(users);
    assertTrue(users.isEmpty());
}
Also used : User(org.apache.syncope.core.persistence.api.entity.user.User) 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

AnyCond (org.apache.syncope.core.persistence.api.dao.search.AnyCond)25 SearchCond (org.apache.syncope.core.persistence.api.dao.search.SearchCond)20 Test (org.junit.jupiter.api.Test)16 AttributeCond (org.apache.syncope.core.persistence.api.dao.search.AttributeCond)11 AbstractTest (org.apache.syncope.core.persistence.jpa.AbstractTest)10 UserFiqlSearchConditionBuilder (org.apache.syncope.common.lib.search.UserFiqlSearchConditionBuilder)6 User (org.apache.syncope.core.persistence.api.entity.user.User)6 OrderByClause (org.apache.syncope.core.persistence.api.dao.search.OrderByClause)3 Group (org.apache.syncope.core.persistence.api.entity.group.Group)3 Method (java.lang.reflect.Method)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)2 PropagationTaskTO (org.apache.syncope.common.lib.to.PropagationTaskTO)2 RealmTO (org.apache.syncope.common.lib.to.RealmTO)2 Realm (org.apache.syncope.core.persistence.api.entity.Realm)2 PropagationByResource (org.apache.syncope.core.provisioning.api.PropagationByResource)2 Annotation (java.lang.annotation.Annotation)1 ManagementFactory (java.lang.management.ManagementFactory)1 OperatingSystemMXBean (java.lang.management.OperatingSystemMXBean)1