Search in sources :

Example 51 with User

use of org.apache.syncope.core.persistence.api.entity.user.User in project syncope by apache.

the class AnySearchTest method searchByGroup.

@Test
public void searchByGroup() {
    MembershipCond groupCond = new MembershipCond();
    groupCond.setGroup("root");
    List<User> users = searchDAO.search(SearchCond.getLeafCond(groupCond), AnyTypeKind.USER);
    assertNotNull(users);
    assertEquals(2, users.size());
    groupCond = new MembershipCond();
    groupCond.setGroup("secretary");
    users = searchDAO.search(SearchCond.getNotLeafCond(groupCond), AnyTypeKind.USER);
    assertNotNull(users);
    assertEquals(5, users.size());
}
Also used : User(org.apache.syncope.core.persistence.api.entity.user.User) MembershipCond(org.apache.syncope.core.persistence.api.dao.search.MembershipCond) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Example 52 with User

use of org.apache.syncope.core.persistence.api.entity.user.User in project syncope by apache.

the class AnySearchTest method searchCaseInsensitiveWithNotCondition.

@Test
public void searchCaseInsensitiveWithNotCondition() {
    AttributeCond fullnameLeafCond = new AttributeCond(AttributeCond.Type.IEQ);
    fullnameLeafCond.setSchema("fullname");
    fullnameLeafCond.setExpression("giuseppe verdi");
    SearchCond cond = SearchCond.getNotLeafCond(fullnameLeafCond);
    assertTrue(cond.isValid());
    List<User> users = searchDAO.search(cond, AnyTypeKind.USER);
    assertNotNull(users);
    assertEquals(4, users.size());
    Set<String> ids = users.stream().map(Entity::getKey).collect(Collectors.toSet());
    assertTrue(ids.contains("1417acbe-cbf6-4277-9372-e75e04f97000"));
    assertTrue(ids.contains("b3cbc78d-32e6-4bd4-92e0-bbe07566a2ee"));
}
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 53 with User

use of org.apache.syncope.core.persistence.api.entity.user.User in project syncope by apache.

the class AnySearchTest method searchByResource.

@Test
public void searchByResource() {
    ResourceCond ws2 = new ResourceCond();
    ws2.setResourceKey("ws-target-resource-2");
    ResourceCond ws1 = new ResourceCond();
    ws1.setResourceKey("ws-target-resource-list-mappings-2");
    SearchCond searchCondition = SearchCond.getAndCond(SearchCond.getNotLeafCond(ws2), SearchCond.getLeafCond(ws1));
    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) 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) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Example 54 with User

use of org.apache.syncope.core.persistence.api.entity.user.User in project syncope by apache.

the class AnySearchTest method searchByRelationshipType.

@Test
public void searchByRelationshipType() {
    // 1. first search for printers involved in "neighborhood" relationship
    RelationshipTypeCond relationshipTypeCond = new RelationshipTypeCond();
    relationshipTypeCond.setRelationshipTypeKey("neighborhood");
    AnyTypeCond tcond = new AnyTypeCond();
    tcond.setAnyTypeKey("PRINTER");
    SearchCond searchCondition = SearchCond.getAndCond(SearchCond.getLeafCond(relationshipTypeCond), SearchCond.getLeafCond(tcond));
    assertTrue(searchCondition.isValid());
    List<AnyObject> anyObjects = searchDAO.search(searchCondition, AnyTypeKind.ANY_OBJECT);
    assertNotNull(anyObjects);
    assertEquals(2, anyObjects.size());
    assertTrue(anyObjects.stream().anyMatch(any -> "fc6dbc3a-6c07-4965-8781-921e7401a4a5".equals(any.getKey())));
    assertTrue(anyObjects.stream().anyMatch(any -> "8559d14d-58c2-46eb-a2d4-a7d35161e8f8".equals(any.getKey())));
    // 2. search for users involved in "neighborhood" relationship
    searchCondition = SearchCond.getLeafCond(relationshipTypeCond);
    List<User> users = searchDAO.search(searchCondition, AnyTypeKind.USER);
    assertNotNull(users);
    assertEquals(1, users.size());
    assertTrue(users.stream().anyMatch(any -> "c9b2dec2-00a7-4855-97c0-d854842b4b24".equals(any.getKey())));
}
Also used : Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) AnySearchDAO(org.apache.syncope.core.persistence.api.dao.AnySearchDAO) RoleCond(org.apache.syncope.core.persistence.api.dao.search.RoleCond) AnyTypeCond(org.apache.syncope.core.persistence.api.dao.search.AnyTypeCond) OrderByClause(org.apache.syncope.core.persistence.api.dao.search.OrderByClause) AnyType(org.apache.syncope.core.persistence.api.entity.AnyType) Autowired(org.springframework.beans.factory.annotation.Autowired) Entity(org.apache.syncope.core.persistence.api.entity.Entity) AssignableCond(org.apache.syncope.core.persistence.api.dao.search.AssignableCond) PrivilegeCond(org.apache.syncope.core.persistence.api.dao.search.PrivilegeCond) ArrayList(java.util.ArrayList) AnyTypeKind(org.apache.syncope.common.lib.types.AnyTypeKind) ResourceCond(org.apache.syncope.core.persistence.api.dao.search.ResourceCond) AttributeCond(org.apache.syncope.core.persistence.api.dao.search.AttributeCond) GroupDAO(org.apache.syncope.core.persistence.api.dao.GroupDAO) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) AnyObjectDAO(org.apache.syncope.core.persistence.api.dao.AnyObjectDAO) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) RealmDAO(org.apache.syncope.core.persistence.api.dao.RealmDAO) SyncopeConstants(org.apache.syncope.common.lib.SyncopeConstants) UserDAO(org.apache.syncope.core.persistence.api.dao.UserDAO) SearchCond(org.apache.syncope.core.persistence.api.dao.search.SearchCond) AnyObject(org.apache.syncope.core.persistence.api.entity.anyobject.AnyObject) AMembership(org.apache.syncope.core.persistence.api.entity.anyobject.AMembership) Set(java.util.Set) User(org.apache.syncope.core.persistence.api.entity.user.User) Collectors(java.util.stream.Collectors) AnyTypeDAO(org.apache.syncope.core.persistence.api.dao.AnyTypeDAO) MemberCond(org.apache.syncope.core.persistence.api.dao.search.MemberCond) Test(org.junit.jupiter.api.Test) List(java.util.List) RelationshipTypeCond(org.apache.syncope.core.persistence.api.dao.search.RelationshipTypeCond) RelationshipCond(org.apache.syncope.core.persistence.api.dao.search.RelationshipCond) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Group(org.apache.syncope.core.persistence.api.entity.group.Group) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest) AnyCond(org.apache.syncope.core.persistence.api.dao.search.AnyCond) MembershipCond(org.apache.syncope.core.persistence.api.dao.search.MembershipCond) Collections(java.util.Collections) Transactional(org.springframework.transaction.annotation.Transactional) AnyObject(org.apache.syncope.core.persistence.api.entity.anyobject.AnyObject) AnyTypeCond(org.apache.syncope.core.persistence.api.dao.search.AnyTypeCond) User(org.apache.syncope.core.persistence.api.entity.user.User) RelationshipTypeCond(org.apache.syncope.core.persistence.api.dao.search.RelationshipTypeCond) 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 55 with User

use of org.apache.syncope.core.persistence.api.entity.user.User in project syncope by apache.

the class AnySearchTest method searchCaseInsensitiveWithLikeCondition.

@Test
public void searchCaseInsensitiveWithLikeCondition() {
    AttributeCond fullnameLeafCond = new AttributeCond(AttributeCond.Type.ILIKE);
    fullnameLeafCond.setSchema("fullname");
    fullnameLeafCond.setExpression("%O%");
    MembershipCond groupCond = new MembershipCond();
    groupCond.setGroup("root");
    AttributeCond loginDateCond = new AttributeCond(AttributeCond.Type.EQ);
    loginDateCond.setSchema("loginDate");
    loginDateCond.setExpression("2009-05-26");
    SearchCond subCond = SearchCond.getAndCond(SearchCond.getLeafCond(fullnameLeafCond), SearchCond.getLeafCond(groupCond));
    assertTrue(subCond.isValid());
    SearchCond cond = SearchCond.getAndCond(subCond, SearchCond.getLeafCond(loginDateCond));
    assertTrue(cond.isValid());
    List<User> users = searchDAO.search(cond, 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) MembershipCond(org.apache.syncope.core.persistence.api.dao.search.MembershipCond) SearchCond(org.apache.syncope.core.persistence.api.dao.search.SearchCond) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Aggregations

User (org.apache.syncope.core.persistence.api.entity.user.User)135 Test (org.junit.jupiter.api.Test)58 AbstractTest (org.apache.syncope.core.persistence.jpa.AbstractTest)56 Transactional (org.springframework.transaction.annotation.Transactional)39 Group (org.apache.syncope.core.persistence.api.entity.group.Group)24 ArrayList (java.util.ArrayList)20 UserTO (org.apache.syncope.common.lib.to.UserTO)20 SearchCond (org.apache.syncope.core.persistence.api.dao.search.SearchCond)20 HashSet (java.util.HashSet)18 AttributeCond (org.apache.syncope.core.persistence.api.dao.search.AttributeCond)17 AnyObject (org.apache.syncope.core.persistence.api.entity.anyobject.AnyObject)17 List (java.util.List)16 WorkflowResult (org.apache.syncope.core.provisioning.api.WorkflowResult)16 UPlainAttr (org.apache.syncope.core.persistence.api.entity.user.UPlainAttr)15 Autowired (org.springframework.beans.factory.annotation.Autowired)15 Set (java.util.Set)14 PlainSchema (org.apache.syncope.core.persistence.api.entity.PlainSchema)14 PropagationByResource (org.apache.syncope.core.provisioning.api.PropagationByResource)14 Collections (java.util.Collections)11 Collectors (java.util.stream.Collectors)11