Search in sources :

Example 56 with SearchCond

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

the class SearchCondConverterTest method assignable.

@Test
public void assignable() {
    String fiql = new GroupFiqlSearchConditionBuilder().isAssignable().query();
    assertEquals(SpecialAttr.ASSIGNABLE + "==" + SpecialAttr.NULL, fiql);
    AssignableCond assignableCond = new AssignableCond();
    assignableCond.setRealmFullPath("/even/two");
    SearchCond simpleCond = SearchCond.getLeafCond(assignableCond);
    assertEquals(simpleCond, SearchCondConverter.convert(fiql, "/even/two"));
}
Also used : AssignableCond(org.apache.syncope.core.persistence.api.dao.search.AssignableCond) GroupFiqlSearchConditionBuilder(org.apache.syncope.common.lib.search.GroupFiqlSearchConditionBuilder) SearchCond(org.apache.syncope.core.persistence.api.dao.search.SearchCond) Test(org.junit.jupiter.api.Test)

Example 57 with SearchCond

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

the class SearchCondConverterTest method or.

@Test
public void or() {
    String fiql = new UserFiqlSearchConditionBuilder().is("fullname").equalTo("*o*", "*i*", "*ini").query();
    assertEquals("fullname==*o*,fullname==*i*,fullname==*ini", fiql);
    fiql = new UserFiqlSearchConditionBuilder().is("fullname").equalTo("*o*").or("fullname").equalTo("*i*").or("fullname").equalTo("*ini").query();
    assertEquals("fullname==*o*,fullname==*i*,fullname==*ini", fiql);
    AttributeCond fullnameLeafCond1 = new AttributeCond(AttributeCond.Type.LIKE);
    fullnameLeafCond1.setSchema("fullname");
    fullnameLeafCond1.setExpression("%o%");
    AttributeCond fullnameLeafCond2 = new AttributeCond(AttributeCond.Type.LIKE);
    fullnameLeafCond2.setSchema("fullname");
    fullnameLeafCond2.setExpression("%i%");
    AttributeCond fullnameLeafCond3 = new AttributeCond(AttributeCond.Type.LIKE);
    fullnameLeafCond3.setSchema("fullname");
    fullnameLeafCond3.setExpression("%ini");
    SearchCond orCond = SearchCond.getOrCond(SearchCond.getLeafCond(fullnameLeafCond1), SearchCond.getOrCond(SearchCond.getLeafCond(fullnameLeafCond2), SearchCond.getLeafCond(fullnameLeafCond3)));
    assertEquals(orCond, SearchCondConverter.convert(fiql));
}
Also used : AttributeCond(org.apache.syncope.core.persistence.api.dao.search.AttributeCond) UserFiqlSearchConditionBuilder(org.apache.syncope.common.lib.search.UserFiqlSearchConditionBuilder) SearchCond(org.apache.syncope.core.persistence.api.dao.search.SearchCond) Test(org.junit.jupiter.api.Test)

Example 58 with SearchCond

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

the class SearchCondConverterTest method nieq.

@Test
public void nieq() {
    String fiql = new UserFiqlSearchConditionBuilder().is("username").notEqualTolIgnoreCase("rossini").query();
    assertEquals("username!~rossini", fiql);
    AnyCond attrCond = new AnyCond(AttributeCond.Type.IEQ);
    attrCond.setSchema("username");
    attrCond.setExpression("rossini");
    SearchCond simpleCond = SearchCond.getNotLeafCond(attrCond);
    assertEquals(simpleCond, SearchCondConverter.convert(fiql));
}
Also used : UserFiqlSearchConditionBuilder(org.apache.syncope.common.lib.search.UserFiqlSearchConditionBuilder) 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)

Example 59 with SearchCond

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

the class SearchCondConverterTest method nilike.

@Test
public void nilike() {
    String fiql = new UserFiqlSearchConditionBuilder().is("username").notEqualTolIgnoreCase("ros*").query();
    assertEquals("username!~ros*", fiql);
    AttributeCond attrCond = new AnyCond(AttributeCond.Type.ILIKE);
    attrCond.setSchema("username");
    attrCond.setExpression("ros%");
    SearchCond simpleCond = SearchCond.getNotLeafCond(attrCond);
    assertEquals(simpleCond, SearchCondConverter.convert(fiql));
}
Also used : AttributeCond(org.apache.syncope.core.persistence.api.dao.search.AttributeCond) UserFiqlSearchConditionBuilder(org.apache.syncope.common.lib.search.UserFiqlSearchConditionBuilder) 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)

Example 60 with SearchCond

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

the class SearchCondConverterTest method groups.

@Test
public void groups() {
    String fiql = new UserFiqlSearchConditionBuilder().inGroups("e7ff94e8-19c9-4f0a-b8b7-28327edbf6ed").query();
    assertEquals(SpecialAttr.GROUPS + "==e7ff94e8-19c9-4f0a-b8b7-28327edbf6ed", fiql);
    MembershipCond groupCond = new MembershipCond();
    groupCond.setGroup("e7ff94e8-19c9-4f0a-b8b7-28327edbf6ed");
    SearchCond simpleCond = SearchCond.getLeafCond(groupCond);
    assertEquals(simpleCond, SearchCondConverter.convert(fiql));
}
Also used : MembershipCond(org.apache.syncope.core.persistence.api.dao.search.MembershipCond) UserFiqlSearchConditionBuilder(org.apache.syncope.common.lib.search.UserFiqlSearchConditionBuilder) SearchCond(org.apache.syncope.core.persistence.api.dao.search.SearchCond) Test(org.junit.jupiter.api.Test)

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