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;
}
}
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;
}
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);
}
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);
}
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());
}
Aggregations