use of org.apache.syncope.core.persistence.api.dao.search.SearchCond in project syncope by apache.
the class SearchCondConverterTest method roles.
@Test
public void roles() {
String fiql = new UserFiqlSearchConditionBuilder().inRoles("User reviewer").query();
assertEquals(SpecialAttr.ROLES + "==User reviewer", fiql);
RoleCond roleCond = new RoleCond();
roleCond.setRole("User reviewer");
SearchCond simpleCond = SearchCond.getLeafCond(roleCond);
assertEquals(simpleCond, SearchCondConverter.convert(fiql));
}
use of org.apache.syncope.core.persistence.api.dao.search.SearchCond in project syncope by apache.
the class AnySearchTest method searchByType.
@Test
public void searchByType() {
AnyTypeCond tcond = new AnyTypeCond();
tcond.setAnyTypeKey("PRINTER");
SearchCond searchCondition = SearchCond.getLeafCond(tcond);
assertTrue(searchCondition.isValid());
List<AnyObject> printers = searchDAO.search(searchCondition, AnyTypeKind.ANY_OBJECT);
assertNotNull(printers);
assertEquals(3, printers.size());
tcond.setAnyTypeKey("UNEXISTING");
printers = searchDAO.search(searchCondition, AnyTypeKind.ANY_OBJECT);
assertNotNull(printers);
assertTrue(printers.isEmpty());
}
use of org.apache.syncope.core.persistence.api.dao.search.SearchCond in project syncope by apache.
the class AnySearchTest method searchByKey.
@Test
public void searchByKey() {
AnyCond idLeafCond = new AnyCond(AnyCond.Type.EQ);
idLeafCond.setSchema("id");
idLeafCond.setExpression("74cd8ece-715a-44a4-a736-e17b46c4e7e6");
SearchCond searchCondition = SearchCond.getLeafCond(idLeafCond);
assertTrue(searchCondition.isValid());
List<User> users = searchDAO.search(searchCondition, AnyTypeKind.USER);
assertNotNull(users);
assertEquals(1, users.size());
assertEquals("74cd8ece-715a-44a4-a736-e17b46c4e7e6", users.iterator().next().getKey());
}
use of org.apache.syncope.core.persistence.api.dao.search.SearchCond in project syncope by apache.
the class AnySearchTest method groupOrderBy.
@Test
public void groupOrderBy() {
AnyCond idLeafCond = new AnyCond(AnyCond.Type.LIKE);
idLeafCond.setSchema("name");
idLeafCond.setExpression("%r");
SearchCond searchCondition = SearchCond.getLeafCond(idLeafCond);
assertTrue(searchCondition.isValid());
OrderByClause orderByClause = new OrderByClause();
orderByClause.setField("name");
List<Group> groups = searchDAO.search(searchCondition, Collections.singletonList(orderByClause), AnyTypeKind.GROUP);
assertEquals(searchDAO.count(SyncopeConstants.FULL_ADMIN_REALMS, searchCondition, AnyTypeKind.GROUP), groups.size());
}
use of org.apache.syncope.core.persistence.api.dao.search.SearchCond in project syncope by apache.
the class AnySearchTest method issueSYNCOPE980.
@Test
public void issueSYNCOPE980() {
AnyType service = entityFactory.newEntity(AnyType.class);
service.setKey("SERVICE");
service.setKind(AnyTypeKind.ANY_OBJECT);
service = anyTypeDAO.save(service);
Group citizen = groupDAO.findByName("citizen");
assertNotNull(citizen);
AnyObject anyObject = entityFactory.newEntity(AnyObject.class);
anyObject.setName("one");
anyObject.setType(service);
anyObject.setRealm(realmDAO.findByFullPath(SyncopeConstants.ROOT_REALM));
AMembership membership = entityFactory.newEntity(AMembership.class);
membership.setRightEnd(citizen);
membership.setLeftEnd(anyObject);
anyObject.add(membership);
anyObjectDAO.save(anyObject);
anyObject = anyObjectDAO.find("fc6dbc3a-6c07-4965-8781-921e7401a4a5");
membership = entityFactory.newEntity(AMembership.class);
membership.setRightEnd(citizen);
membership.setLeftEnd(anyObject);
anyObject.add(membership);
anyObjectDAO.save(anyObject);
anyObjectDAO.flush();
MembershipCond groupCond = new MembershipCond();
groupCond.setGroup("citizen");
SearchCond searchCondition = SearchCond.getLeafCond(groupCond);
List<AnyObject> matching = searchDAO.search(searchCondition, AnyTypeKind.ANY_OBJECT);
assertEquals(2, matching.size());
AnyTypeCond anyTypeCond = new AnyTypeCond();
anyTypeCond.setAnyTypeKey(service.getKey());
searchCondition = SearchCond.getAndCond(SearchCond.getLeafCond(groupCond), SearchCond.getLeafCond(anyTypeCond));
matching = searchDAO.search(searchCondition, AnyTypeKind.ANY_OBJECT);
assertEquals(1, matching.size());
}
Aggregations