Search in sources :

Example 86 with ObjectReferenceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.

the class TestFunctions method test110ResolveReference.

/**
 * MID-6133
 */
@Test
public void test110ResolveReference() throws Exception {
    given();
    Task task = getTestTask();
    OperationResult result = task.getResult();
    ObjectReferenceType broken = ObjectTypeUtil.createObjectRef(TestUtil.NON_EXISTENT_OID, ObjectTypes.USER);
    when();
    try {
        execute(task, result, () -> libraryMidpointFunctions.resolveReference(broken));
        fail("unexpected success");
    } catch (ObjectNotFoundException e) {
        System.out.println("expected failure: " + e.getMessage());
    }
    then();
    assertFailure(result);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test)

Example 87 with ObjectReferenceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.

the class AbstractModelIntegrationTest method fillinUserAssignmentAccountConstruction.

protected void fillinUserAssignmentAccountConstruction(PrismObject<UserType> user, String resourceOid) {
    AssignmentType assignmentType = new AssignmentType();
    ConstructionType accountConstruntion = new ConstructionType();
    ObjectReferenceType resourceRef = new ObjectReferenceType();
    resourceRef.setOid(resourceOid);
    resourceRef.setType(ResourceType.COMPLEX_TYPE);
    accountConstruntion.setResourceRef(resourceRef);
    accountConstruntion.setKind(ShadowKindType.ACCOUNT);
    assignmentType.setConstruction(accountConstruntion);
    user.asObjectable().getAssignment().add(assignmentType);
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)

Example 88 with ObjectReferenceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.

the class AbstractModelIntegrationTest method checkApprovers.

protected void checkApprovers(List<String> expectedApprovers, List<ObjectReferenceType> realApprovers) {
    HashSet<String> realApproversSet = new HashSet<>();
    for (ObjectReferenceType approver : realApprovers) {
        realApproversSet.add(approver.getOid());
        assertEquals("Unexpected target type in approverRef", UserType.COMPLEX_TYPE, approver.getType());
    }
    assertEquals("Mismatch in approvers in metadata", new HashSet<>(expectedApprovers), realApproversSet);
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString)

Example 89 with ObjectReferenceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.

the class AbstractModelIntegrationTest method modifyRoleAddInducementTarget.

protected void modifyRoleAddInducementTarget(String roleOid, String targetOid, boolean recomputeMembers, ModelExecuteOptions defaultOptions) throws CommonException {
    OperationResult result = createSubresult("modifyRoleAddInducementTarget");
    AssignmentType inducement = new AssignmentType();
    ObjectReferenceType targetRef = new ObjectReferenceType();
    targetRef.setOid(targetOid);
    inducement.setTargetRef(targetRef);
    ObjectDelta<RoleType> roleDelta = prismContext.deltaFactory().object().createModificationAddContainer(RoleType.class, roleOid, RoleType.F_INDUCEMENT, inducement);
    ModelExecuteOptions options = setRecomputeMembers(defaultOptions, recomputeMembers);
    executeChanges(roleDelta, options, getTestTask(), result);
    result.computeStatus();
    if (recomputeMembers) {
        TestUtil.assertInProgressOrSuccess(result);
    } else {
        TestUtil.assertSuccess(result);
    }
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Example 90 with ObjectReferenceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.

the class AbstractModelIntegrationTest method getUserAssignment.

protected AssignmentType getUserAssignment(String userOid, String roleOid, QName relation) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
    PrismObject<UserType> user = getUser(userOid);
    List<AssignmentType> assignments = user.asObjectable().getAssignment();
    for (AssignmentType assignment : assignments) {
        ObjectReferenceType targetRef = assignment.getTargetRef();
        if (targetRef != null && roleOid.equals(targetRef.getOid()) && prismContext.relationMatches(relation, targetRef.getRelation())) {
            return assignment;
        }
    }
    return null;
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)

Aggregations

ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)278 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)104 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)61 Test (org.testng.annotations.Test)61 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)56 Task (com.evolveum.midpoint.task.api.Task)53 QName (javax.xml.namespace.QName)46 ArrayList (java.util.ArrayList)44 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)42 PrismAsserts.assertEqualsPolyString (com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)37 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)33 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)32 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)32 ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)31 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)30 ChangeRecordEntry (org.opends.server.util.ChangeRecordEntry)30 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)26 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)26 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)23 List (java.util.List)23