Search in sources :

Example 26 with AttributeCond

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

the class SearchCondConverterTest method issueSYNCOPE1223.

@Test
public void issueSYNCOPE1223() {
    String fiql = new UserFiqlSearchConditionBuilder().is("ctype").equalTo("ou=sample%252Co=isp").query();
    AttributeCond cond = new AttributeCond(AttributeCond.Type.EQ);
    cond.setSchema("ctype");
    cond.setExpression("ou=sample,o=isp");
    assertEquals(SearchCond.getLeafCond(cond), SearchCondConverter.convert(fiql));
}
Also used : AttributeCond(org.apache.syncope.core.persistence.api.dao.search.AttributeCond) UserFiqlSearchConditionBuilder(org.apache.syncope.common.lib.search.UserFiqlSearchConditionBuilder) Test(org.junit.jupiter.api.Test)

Example 27 with AttributeCond

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

the class AnySearchTest method groupMatch.

@Test
public void groupMatch() {
    Group group = groupDAO.find("37d15e4c-cdc1-460b-a591-8505c8133806");
    assertNotNull(group);
    AttributeCond attrCond = new AttributeCond();
    attrCond.setSchema("show");
    attrCond.setType(AttributeCond.Type.ISNOTNULL);
    assertTrue(searchDAO.matches(group, SearchCond.getLeafCond(attrCond)));
}
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 28 with AttributeCond

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

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

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

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