Search in sources :

Example 11 with UserFiqlSearchConditionBuilder

use of org.apache.syncope.common.lib.search.UserFiqlSearchConditionBuilder 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 12 with UserFiqlSearchConditionBuilder

use of org.apache.syncope.common.lib.search.UserFiqlSearchConditionBuilder 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 13 with UserFiqlSearchConditionBuilder

use of org.apache.syncope.common.lib.search.UserFiqlSearchConditionBuilder 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 14 with UserFiqlSearchConditionBuilder

use of org.apache.syncope.common.lib.search.UserFiqlSearchConditionBuilder 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)

Example 15 with UserFiqlSearchConditionBuilder

use of org.apache.syncope.common.lib.search.UserFiqlSearchConditionBuilder in project syncope by apache.

the class SearchCondConverterTest method resources.

@Test
public void resources() {
    String fiql = new UserFiqlSearchConditionBuilder().hasResources("resource-ldap").query();
    assertEquals(SpecialAttr.RESOURCES + "==resource-ldap", fiql);
    ResourceCond resCond = new ResourceCond();
    resCond.setResourceKey("resource-ldap");
    SearchCond simpleCond = SearchCond.getLeafCond(resCond);
    assertEquals(simpleCond, SearchCondConverter.convert(fiql));
}
Also used : UserFiqlSearchConditionBuilder(org.apache.syncope.common.lib.search.UserFiqlSearchConditionBuilder) ResourceCond(org.apache.syncope.core.persistence.api.dao.search.ResourceCond) SearchCond(org.apache.syncope.core.persistence.api.dao.search.SearchCond) Test(org.junit.jupiter.api.Test)

Aggregations

UserFiqlSearchConditionBuilder (org.apache.syncope.common.lib.search.UserFiqlSearchConditionBuilder)19 Test (org.junit.jupiter.api.Test)18 SearchCond (org.apache.syncope.core.persistence.api.dao.search.SearchCond)17 AttributeCond (org.apache.syncope.core.persistence.api.dao.search.AttributeCond)8 AnyCond (org.apache.syncope.core.persistence.api.dao.search.AnyCond)6 AnyObjectFiqlSearchConditionBuilder (org.apache.syncope.common.lib.search.AnyObjectFiqlSearchConditionBuilder)2 CompleteCondition (org.apache.cxf.jaxrs.ext.search.client.CompleteCondition)1 SyncopeProperty (org.apache.syncope.common.lib.search.SyncopeProperty)1 DynRealmCond (org.apache.syncope.core.persistence.api.dao.search.DynRealmCond)1 MembershipCond (org.apache.syncope.core.persistence.api.dao.search.MembershipCond)1 PrivilegeCond (org.apache.syncope.core.persistence.api.dao.search.PrivilegeCond)1 RelationshipCond (org.apache.syncope.core.persistence.api.dao.search.RelationshipCond)1 RelationshipTypeCond (org.apache.syncope.core.persistence.api.dao.search.RelationshipTypeCond)1 ResourceCond (org.apache.syncope.core.persistence.api.dao.search.ResourceCond)1 RoleCond (org.apache.syncope.core.persistence.api.dao.search.RoleCond)1