Search in sources :

Example 66 with SearchCond

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

the class AnySearchTest method issueSYNCOPE46.

@Test
public void issueSYNCOPE46() {
    AnyCond cond = new AnyCond(AttributeCond.Type.LIKE);
    cond.setSchema("username");
    cond.setExpression("%ossin%");
    SearchCond searchCondition = SearchCond.getLeafCond(cond);
    assertTrue(searchCondition.isValid());
    List<User> users = searchDAO.search(searchCondition, AnyTypeKind.USER);
    assertNotNull(users);
    assertEquals(1, users.size());
}
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 67 with SearchCond

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

the class AnySearchTest method issueSYNCOPE929.

@Test
public void issueSYNCOPE929() {
    AttributeCond rossiniCond = new AttributeCond(AttributeCond.Type.EQ);
    rossiniCond.setSchema("surname");
    rossiniCond.setExpression("Rossini");
    AttributeCond genderCond = new AttributeCond(AttributeCond.Type.EQ);
    genderCond.setSchema("gender");
    genderCond.setExpression("M");
    SearchCond orCond = SearchCond.getOrCond(SearchCond.getLeafCond(rossiniCond), SearchCond.getLeafCond(genderCond));
    AttributeCond belliniCond = new AttributeCond(AttributeCond.Type.EQ);
    belliniCond.setSchema("surname");
    belliniCond.setExpression("Bellini");
    SearchCond searchCond = SearchCond.getAndCond(orCond, SearchCond.getLeafCond(belliniCond));
    List<User> users = searchDAO.search(searchCond, 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) 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 68 with SearchCond

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

the class AnySearchTest method searchByUsernameAndFullname.

@Test
public void searchByUsernameAndFullname() {
    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<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 69 with SearchCond

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

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

Aggregations

SearchCond (org.apache.syncope.core.persistence.api.dao.search.SearchCond)74 Test (org.junit.jupiter.api.Test)55 AttributeCond (org.apache.syncope.core.persistence.api.dao.search.AttributeCond)30 AnyCond (org.apache.syncope.core.persistence.api.dao.search.AnyCond)26 AbstractTest (org.apache.syncope.core.persistence.jpa.AbstractTest)25 User (org.apache.syncope.core.persistence.api.entity.user.User)20 UserFiqlSearchConditionBuilder (org.apache.syncope.common.lib.search.UserFiqlSearchConditionBuilder)17 MembershipCond (org.apache.syncope.core.persistence.api.dao.search.MembershipCond)12 OrderByClause (org.apache.syncope.core.persistence.api.dao.search.OrderByClause)11 ArrayList (java.util.ArrayList)10 Group (org.apache.syncope.core.persistence.api.entity.group.Group)10 List (java.util.List)8 AnyTypeCond (org.apache.syncope.core.persistence.api.dao.search.AnyTypeCond)8 AssignableCond (org.apache.syncope.core.persistence.api.dao.search.AssignableCond)7 MemberCond (org.apache.syncope.core.persistence.api.dao.search.MemberCond)7 Collections (java.util.Collections)6 Collectors (java.util.stream.Collectors)6 SyncopeConstants (org.apache.syncope.common.lib.SyncopeConstants)6 RelationshipCond (org.apache.syncope.core.persistence.api.dao.search.RelationshipCond)6 ResourceCond (org.apache.syncope.core.persistence.api.dao.search.ResourceCond)6