Search in sources :

Example 91 with AssignmentType

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

the class TestAssignmentsWithDifferentMetaroles method toDelete.

private AssignmentType toDelete(AssignmentType assignment, boolean byId) {
    if (assignment == null) {
        return null;
    }
    if (!byId) {
        return assignment.clone();
    } else {
        AssignmentType rv = new AssignmentType(prismContext);
        rv.setId(assignment.getId());
        return rv;
    }
}
Also used : AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)

Example 92 with AssignmentType

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

the class RoleAssignmentHelper method cloneAndCanonicalizeAssignment.

// TODO is this ok?
AssignmentType cloneAndCanonicalizeAssignment(AssignmentType assignmentType) {
    AssignmentType assignmentClone = assignmentType.clone();
    PrismContainerValue.copyDefinition(assignmentClone, assignmentType, prismContext);
    assignmentClone.setTarget(null);
    return assignmentClone;
}
Also used : AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)

Example 93 with AssignmentType

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

the class TestSchemaDelta method testDeleteInducementValidIdSameValueApplyToObject.

@Test
public void testDeleteInducementValidIdSameValueApplyToObject() throws Exception {
    final String TEST_NAME = "testDeleteInducementValidIdSameValueApplyToObject";
    displayTestTile(TEST_NAME);
    // GIVEN
    PrismObject<RoleType> role = PrismTestUtil.parseObject(ROLE_CONSTRUCTION_FILE);
    //Delta
    ConstructionType construction = new ConstructionType();
    ObjectReferenceType resourceRef = new ObjectReferenceType();
    resourceRef.setOid(ROLE_CONSTRUCTION_RESOURCE_OID);
    construction.setResourceRef(resourceRef);
    AssignmentType inducement = new AssignmentType();
    inducement.setConstruction(construction);
    inducement.setId(ROLE_CONSTRUCTION_INDUCEMENT_ID);
    ObjectDelta<RoleType> roleDelta = ObjectDelta.createModificationDeleteContainer(RoleType.class, ROLE_CONSTRUCTION_OID, RoleType.F_INDUCEMENT, getPrismContext(), inducement);
    // WHEN
    roleDelta.applyTo(role);
    // THEN
    System.out.println("Role after delta application:");
    System.out.println(role.debugDump());
    assertEquals("Wrong OID", ROLE_CONSTRUCTION_OID, role.getOid());
    PrismAsserts.assertPropertyValue(role, UserType.F_NAME, PrismTestUtil.createPolyString("Construction"));
    PrismContainer<AssignmentType> assignment = role.findContainer(RoleType.F_INDUCEMENT);
    assertNull("Unexpected inducement", assignment);
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) ConstructionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConstructionType) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType) Test(org.testng.annotations.Test)

Example 94 with AssignmentType

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

the class TestSchemaDelta method testDeleteInducementValidIdEmptyValueApplyToObjectStatic.

@Test
public void testDeleteInducementValidIdEmptyValueApplyToObjectStatic() throws Exception {
    final String TEST_NAME = "testDeleteInducementValidIdEmptyValueApplyToObjectStatic";
    displayTestTile(TEST_NAME);
    // GIVEN
    PrismObject<RoleType> role = PrismTestUtil.parseObject(ROLE_CONSTRUCTION_FILE);
    System.out.println("Role before delta application:");
    System.out.println(role.debugDump());
    //Delta
    AssignmentType inducement = new AssignmentType();
    inducement.setId(ROLE_CONSTRUCTION_INDUCEMENT_ID);
    ObjectDelta<RoleType> roleDelta = ObjectDelta.createModificationDeleteContainer(RoleType.class, ROLE_CONSTRUCTION_OID, RoleType.F_INDUCEMENT, getPrismContext(), inducement);
    // WHEN
    PropertyDelta.applyTo(roleDelta.getModifications(), role);
    // THEN
    System.out.println("Role after delta application:");
    System.out.println(role.debugDump());
    assertEquals("Wrong OID", ROLE_CONSTRUCTION_OID, role.getOid());
    PrismAsserts.assertPropertyValue(role, UserType.F_NAME, PrismTestUtil.createPolyString("Construction"));
    PrismContainer<AssignmentType> assignment = role.findContainer(RoleType.F_INDUCEMENT);
    assertNull("Unexpected inducement", assignment);
}
Also used : RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType) Test(org.testng.annotations.Test)

Example 95 with AssignmentType

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

the class TestSchemaDelta method testDeleteUserAssignmentActivationSameNullIdApplyToObject.

@Test
public void testDeleteUserAssignmentActivationSameNullIdApplyToObject() throws Exception {
    final String TEST_NAME = "testDeleteUserAssignmentActivationSameNullIdApplyToObject";
    displayTestTile(TEST_NAME);
    // GIVEN
    PrismObject<UserType> user = PrismTestUtil.parseObject(USER_JACK_FILE);
    //Delta
    ActivationType activationType = new ActivationType();
    activationType.setAdministrativeStatus(ActivationStatusType.ENABLED);
    // No container ID
    ObjectDelta<UserType> userDelta = ObjectDelta.createModificationDeleteContainer(UserType.class, USER_JACK_OID, new ItemPath(new NameItemPathSegment(UserType.F_ASSIGNMENT), new IdItemPathSegment(USER_JACK_ASSIGNMENT_ID), new NameItemPathSegment(AssignmentType.F_ACTIVATION)), getPrismContext(), activationType);
    // WHEN
    userDelta.applyTo(user);
    // THEN
    System.out.println("User after delta application:");
    System.out.println(user.debugDump());
    assertEquals("Wrong OID", USER_JACK_OID, user.getOid());
    PrismAsserts.assertPropertyValue(user, UserType.F_NAME, PrismTestUtil.createPolyString(USER_JACK_NAME));
    PrismContainer<AssignmentType> assignmentContainer = user.findContainer(RoleType.F_ASSIGNMENT);
    assertNotNull("No assignment", assignmentContainer);
    assertEquals("Unexpected number of assignment values", 1, assignmentContainer.size());
    PrismContainerValue<AssignmentType> assignmentValue = assignmentContainer.getValues().iterator().next();
    AssignmentType assignment = assignmentValue.asContainerable();
    ActivationType assignmentActivation = assignment.getActivation();
    // activation should be gone (the error is that it is empty and not gone)
    assertNull("Assignment activation is not gone", assignmentActivation);
    ActivationType activation = user.asObjectable().getActivation();
    assertNotNull("Activation missing", activation);
    assertEquals("Wrong activation administrativeStatus", ActivationStatusType.ENABLED, activation.getAdministrativeStatus());
}
Also used : ActivationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType) IdItemPathSegment(com.evolveum.midpoint.prism.path.IdItemPathSegment) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType) NameItemPathSegment(com.evolveum.midpoint.prism.path.NameItemPathSegment) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Aggregations

AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)121 Test (org.testng.annotations.Test)61 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)55 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)42 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)41 Task (com.evolveum.midpoint.task.api.Task)39 PrismContainerValue (com.evolveum.midpoint.prism.PrismContainerValue)33 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)25 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)24 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)21 QName (javax.xml.namespace.QName)20 PrismObject (com.evolveum.midpoint.prism.PrismObject)19 PrismContainerDefinition (com.evolveum.midpoint.prism.PrismContainerDefinition)17 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)17 com.evolveum.midpoint.xml.ns._public.common.common_3 (com.evolveum.midpoint.xml.ns._public.common.common_3)17 RoleType (com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType)17 PolyStringType (com.evolveum.prism.xml.ns._public.types_3.PolyStringType)17 ArrayList (java.util.ArrayList)17 SchemaConstants (com.evolveum.midpoint.schema.constants.SchemaConstants)15 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)14