use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType in project midpoint by Evolveum.
the class ModifyAssignmentTest method test31DeleteInducement.
@Test
public void test31DeleteInducement() throws Exception {
//given
//when
ObjectModificationType modification = PrismTestUtil.parseAtomicValue(new File(TEST_DIR, "modify-delete-inducement.xml"), ObjectModificationType.COMPLEX_TYPE);
ObjectDelta delta = DeltaConvertor.createObjectDelta(modification, RoleType.class, prismContext);
OperationResult result = new OperationResult("delete inducement");
repositoryService.modifyObject(RoleType.class, delta.getOid(), delta.getModifications(), result);
result.recomputeStatus();
result.recordSuccessIfUnknown();
//then
AssertJUnit.assertTrue(result.isSuccess());
result = new OperationResult("get role");
PrismObject repoRole = repositoryService.getObject(RoleType.class, ROLE_OID, null, result);
result.recomputeStatus();
result.recordSuccessIfUnknown();
AssertJUnit.assertTrue(result.isSuccess());
PrismContainer inducement = repoRole.findContainer(new ItemPath(RoleType.F_INDUCEMENT));
AssertJUnit.assertNotNull(inducement);
AssertJUnit.assertEquals(2, inducement.getValues().size());
AssertJUnit.assertNotNull(inducement.getValue(2L));
AssertJUnit.assertNotNull(inducement.getValue(5L));
PrismContainer assignment = repoRole.findContainer(new ItemPath(AbstractRoleType.F_ASSIGNMENT));
AssertJUnit.assertNotNull(assignment);
AssertJUnit.assertEquals(1, assignment.getValues().size());
AssertJUnit.assertNotNull(assignment.getValue(1L));
}
use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType in project midpoint by Evolveum.
the class ModifyAssignmentTest method test11AddInducement.
@Test
public void test11AddInducement() throws Exception {
//given
//when
ObjectModificationType modification = PrismTestUtil.parseAtomicValue(new File(TEST_DIR, "modify-add-inducement.xml"), ObjectModificationType.COMPLEX_TYPE);
ObjectDelta delta = DeltaConvertor.createObjectDelta(modification, RoleType.class, prismContext);
OperationResult result = new OperationResult("add inducement");
repositoryService.modifyObject(RoleType.class, delta.getOid(), delta.getModifications(), result);
result.recomputeStatus();
result.recordSuccessIfUnknown();
//then
AssertJUnit.assertTrue(result.isSuccess());
//check role and its assignments and inducements
result = new OperationResult("get role");
PrismObject repoRole = repositoryService.getObject(RoleType.class, ROLE_OID, null, result);
System.out.println("role: " + repoRole.debugDump());
result.recomputeStatus();
result.recordSuccessIfUnknown();
AssertJUnit.assertTrue(result.isSuccess());
PrismContainer inducement = repoRole.findContainer(new ItemPath(RoleType.F_INDUCEMENT));
AssertJUnit.assertNotNull(inducement);
AssertJUnit.assertEquals(3, inducement.getValues().size());
PrismContainer assignment = repoRole.findContainer(new ItemPath(AbstractRoleType.F_ASSIGNMENT));
AssertJUnit.assertNotNull(assignment);
AssertJUnit.assertEquals(2, assignment.getValues().size());
PrismContainerValue value5 = inducement.getValue(5L);
PrismContainer accConstruction = value5.findContainer(AssignmentType.F_CONSTRUCTION);
AssertJUnit.assertNotNull(accConstruction);
AssertJUnit.assertEquals(1, accConstruction.getValues().size());
}
use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType in project midpoint by Evolveum.
the class ModifyAssignmentTest method test10AddAssignment.
@Test
public void test10AddAssignment() throws Exception {
//given
//when
ObjectModificationType modification = PrismTestUtil.parseAtomicValue(new File(TEST_DIR, "modify-add-assignment.xml"), ObjectModificationType.COMPLEX_TYPE);
ObjectDelta delta = DeltaConvertor.createObjectDelta(modification, RoleType.class, prismContext);
OperationResult result = new OperationResult("add assignment");
repositoryService.modifyObject(RoleType.class, delta.getOid(), delta.getModifications(), result);
result.recomputeStatus();
result.recordSuccessIfUnknown();
//then
AssertJUnit.assertTrue(result.isSuccess());
//check role and its assignments and inducements
result = new OperationResult("get role");
PrismObject repoRole = repositoryService.getObject(RoleType.class, ROLE_OID, null, result);
System.out.println("role: " + repoRole.debugDump());
result.recomputeStatus();
result.recordSuccessIfUnknown();
AssertJUnit.assertTrue(result.isSuccess());
PrismContainer inducement = repoRole.findContainer(new ItemPath(RoleType.F_INDUCEMENT));
AssertJUnit.assertNotNull(inducement);
AssertJUnit.assertEquals(2, inducement.getValues().size());
PrismContainer assignment = repoRole.findContainer(new ItemPath(AbstractRoleType.F_ASSIGNMENT));
AssertJUnit.assertNotNull(assignment);
AssertJUnit.assertEquals(2, assignment.getValues().size());
PrismContainerValue value4 = assignment.getValue(4L);
PrismReference targetRef = value4.findReference(AssignmentType.F_TARGET_REF);
AssertJUnit.assertNotNull(targetRef);
AssertJUnit.assertEquals(1, targetRef.getValues().size());
PrismReferenceValue refValue = targetRef.getValue();
AssertJUnit.assertEquals(OLD_ASSIGNMENT_OID, refValue.getOid());
AssertJUnit.assertEquals(RoleType.COMPLEX_TYPE, refValue.getTargetType());
}
use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType in project midpoint by Evolveum.
the class ModifyAssignmentTest method test21ModifyInducement.
@Test
public void test21ModifyInducement() throws Exception {
//given
//when
ObjectModificationType modification = PrismTestUtil.parseAtomicValue(new File(TEST_DIR, "modify-inducement.xml"), ObjectModificationType.COMPLEX_TYPE);
ObjectDelta delta = DeltaConvertor.createObjectDelta(modification, RoleType.class, prismContext);
OperationResult result = new OperationResult("modify inducement");
repositoryService.modifyObject(RoleType.class, delta.getOid(), delta.getModifications(), result);
result.recomputeStatus();
result.recordSuccessIfUnknown();
//then
AssertJUnit.assertTrue(result.isSuccess());
result = new OperationResult("get role");
PrismObject repoRole = repositoryService.getObject(RoleType.class, ROLE_OID, null, result);
result.recomputeStatus();
result.recordSuccessIfUnknown();
AssertJUnit.assertTrue(result.isSuccess());
PrismContainer inducement = repoRole.findContainer(new ItemPath(RoleType.F_INDUCEMENT));
AssertJUnit.assertNotNull(inducement);
AssertJUnit.assertEquals(3, inducement.getValues().size());
PrismContainer assignment = repoRole.findContainer(new ItemPath(AbstractRoleType.F_ASSIGNMENT));
AssertJUnit.assertNotNull(assignment);
AssertJUnit.assertEquals(2, assignment.getValues().size());
PrismContainerValue value5 = inducement.getValue(5L);
PrismReference targetRef = value5.findReference(AssignmentType.F_TARGET_REF);
AssertJUnit.assertNotNull(targetRef);
AssertJUnit.assertEquals(1, targetRef.getValues().size());
PrismReferenceValue refValue = targetRef.getValue();
AssertJUnit.assertEquals(NEW_INDUCEMENT_OID, refValue.getOid());
AssertJUnit.assertEquals(RoleType.COMPLEX_TYPE, refValue.getTargetType());
PrismProperty accConstruction = value5.findProperty(AssignmentType.F_CONSTRUCTION);
AssertJUnit.assertNull(accConstruction);
}
use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType in project midpoint by Evolveum.
the class TestOpenDjNegative method test150ModifyObject.
@Test
public void test150ModifyObject() throws Exception {
final String TEST_NAME = "test150ModifyObject";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
OperationResult result = new OperationResult(TestOpenDjNegative.class.getName() + "." + TEST_NAME);
ObjectModificationType objectChange = PrismTestUtil.parseAtomicValue(ACCOUNT_JACK_CHANGE_FILE, ObjectModificationType.COMPLEX_TYPE);
ObjectDelta<ShadowType> delta = DeltaConvertor.createObjectDelta(objectChange, ShadowType.class, PrismTestUtil.getPrismContext());
display("Object change", delta);
try {
provisioningService.modifyObject(ShadowType.class, objectChange.getOid(), delta.getModifications(), null, null, taskManager.createTaskInstance(), result);
AssertJUnit.fail("addObject succeeded unexpectedly");
} catch (ConfigurationException e) {
// This is expected
display("Expected exception", e);
}
result.computeStatus();
TestUtil.assertFailure(result);
}
Aggregations