Search in sources :

Example 56 with PrismReferenceValue

use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.

the class SearchTest method roleAssignmentSearchTest.

@Test
public void roleAssignmentSearchTest() throws Exception {
    PrismReferenceValue r456 = new PrismReferenceValue("r123", RoleType.COMPLEX_TYPE);
    ObjectQuery query = QueryBuilder.queryFor(UserType.class, prismContext).item(UserType.F_ASSIGNMENT, AssignmentType.F_TARGET_REF).ref(r456).build();
    OperationResult result = new OperationResult("search");
    List<PrismObject<UserType>> users = repositoryService.searchObjects(UserType.class, query, null, result);
    result.recomputeStatus();
    assertTrue(result.isSuccess());
    assertEquals("Should find one user", 1, users.size());
    assertEquals("Wrong user name", "atestuserX00002", users.get(0).getName().getOrig());
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) Test(org.testng.annotations.Test)

Example 57 with PrismReferenceValue

use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.

the class SearchTest method personaSearchTest.

@Test
public void personaSearchTest() throws Exception {
    PrismReferenceValue u000 = new PrismReferenceValue("u000", UserType.COMPLEX_TYPE);
    ObjectQuery query = QueryBuilder.queryFor(UserType.class, prismContext).item(UserType.F_PERSONA_REF).ref(u000).build();
    OperationResult result = new OperationResult("search");
    List<PrismObject<UserType>> users = repositoryService.searchObjects(UserType.class, query, null, result);
    result.recomputeStatus();
    assertTrue(result.isSuccess());
    assertEquals("Should find one user", 1, users.size());
    assertEquals("Wrong user name", "atestuserX00003", users.get(0).getName().getOrig());
    PrismReferenceValue r789 = new PrismReferenceValue("r789", RoleType.COMPLEX_TYPE);
    query = QueryBuilder.queryFor(UserType.class, prismContext).item(UserType.F_PERSONA_REF).ref(r789).build();
    users = repositoryService.searchObjects(UserType.class, query, null, result);
    result.recomputeStatus();
    assertTrue(result.isSuccess());
    assertEquals("Should find no users", 0, users.size());
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) Test(org.testng.annotations.Test)

Example 58 with PrismReferenceValue

use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.

the class SearchTest method roleMembershipSearchTest.

@Test
public void roleMembershipSearchTest() throws Exception {
    PrismReferenceValue r456 = new PrismReferenceValue("r456", RoleType.COMPLEX_TYPE);
    r456.setRelation(SchemaConstants.ORG_DEFAULT);
    ObjectQuery query = QueryBuilder.queryFor(UserType.class, prismContext).item(UserType.F_ROLE_MEMBERSHIP_REF).ref(r456).build();
    OperationResult result = new OperationResult("search");
    List<PrismObject<UserType>> users = repositoryService.searchObjects(UserType.class, query, null, result);
    result.recomputeStatus();
    assertTrue(result.isSuccess());
    assertEquals("Should find one user", 1, users.size());
    assertEquals("Wrong user name", "atestuserX00003", users.get(0).getName().getOrig());
    PrismReferenceValue r123 = new PrismReferenceValue("r123", RoleType.COMPLEX_TYPE);
    query = QueryBuilder.queryFor(UserType.class, prismContext).item(UserType.F_ROLE_MEMBERSHIP_REF).ref(r123).build();
    users = repositoryService.searchObjects(UserType.class, query, null, result);
    result.recomputeStatus();
    assertTrue(result.isSuccess());
    assertEquals("Should find two users", 2, users.size());
    PrismReferenceValue r123approver = new PrismReferenceValue("r123", RoleType.COMPLEX_TYPE);
    r123approver.setRelation(SchemaConstants.ORG_APPROVER);
    query = QueryBuilder.queryFor(UserType.class, prismContext).item(UserType.F_ROLE_MEMBERSHIP_REF).ref(r123approver).build();
    users = repositoryService.searchObjects(UserType.class, query, null, result);
    result.recomputeStatus();
    assertTrue(result.isSuccess());
    assertEquals("Should find no users", 0, users.size());
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) Test(org.testng.annotations.Test)

Example 59 with PrismReferenceValue

use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.

the class TaskQuartzImpl method setObjectRefAndPrepareDelta.

private ReferenceDelta setObjectRefAndPrepareDelta(ObjectReferenceType value) {
    setObjectRefTransient(value);
    PrismReferenceValue prismReferenceValue = new PrismReferenceValue();
    prismReferenceValue.setOid(value.getOid());
    prismReferenceValue.setTargetType(value.getType());
    return isPersistent() ? ReferenceDelta.createModificationReplace(TaskType.F_OBJECT_REF, taskManager.getTaskObjectDefinition(), prismReferenceValue) : null;
}
Also used : PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue)

Example 60 with PrismReferenceValue

use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.

the class TestVillage method assertLdapLocGov.

private void assertLdapLocGov(PrismObject<UserType> user, String expLoc, String expOrg) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, DirectoryException, ExpressionEvaluationException {
    UserType userType = user.asObjectable();
    String groupCn = expOrg + ":" + expLoc;
    String groupDn = "cn=" + groupCn + ",ou=groups," + openDJController.getSuffix();
    Entry groupEntry = openDJController.fetchAndAssertEntry(groupDn, "groupOfUniqueNames");
    display("Group entry", groupEntry);
    PrismReferenceValue accountLinkRef = getLinkRef(user, RESOURCE_OPENDJ_OID);
    PrismObject<ShadowType> accountShadow = getShadowModel(accountLinkRef.getOid());
    String accountDn = IntegrationTestTools.getSecondaryIdentifier(accountShadow);
    openDJController.assertUniqueMember(groupEntry, accountDn);
}
Also used : Entry(org.opends.server.types.Entry) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue)

Aggregations

PrismReferenceValue (com.evolveum.midpoint.prism.PrismReferenceValue)126 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)64 Test (org.testng.annotations.Test)47 Task (com.evolveum.midpoint.task.api.Task)45 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)32 ReferenceDelta (com.evolveum.midpoint.prism.delta.ReferenceDelta)27 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)26 PrismObject (com.evolveum.midpoint.prism.PrismObject)25 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)25 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)24 ArrayList (java.util.ArrayList)22 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)21 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)20 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)16 PrismReference (com.evolveum.midpoint.prism.PrismReference)15 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)15 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)15 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)12 Collection (java.util.Collection)12 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)11