use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType in project midpoint by Evolveum.
the class ModifyAssignmentTest method test30DeleteAssignment.
@Test
public void test30DeleteAssignment() throws Exception {
//given
//when
// ObjectModificationType modification = prismContext.getPrismJaxbProcessor().unmarshalObject(
// new File(TEST_DIR, "modify-delete-assignment.xml"), ObjectModificationType.class);
//
// ObjectDelta delta = DeltaConvertor.createObjectDelta(modification, RoleType.class, prismContext);
AssignmentType a = new AssignmentType();
a.setId(4L);
ObjectDelta<RoleType> delta = ObjectDelta.createModificationDeleteContainer(RoleType.class, "00000000-8888-6666-0000-100000000005", RoleType.F_ASSIGNMENT, prismContext, a);
OperationResult result = new OperationResult("delete assignment");
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(1, assignment.getValues().size());
AssertJUnit.assertNotNull(assignment.getValue(1L));
Session session = open();
try {
Query query = session.createSQLQuery("select count(*) from m_assignment where owner_oid=:oid and id=:id");
query.setParameter("oid", delta.getOid());
query.setParameter("id", 4);
Number number = (Number) query.uniqueResult();
AssertJUnit.assertEquals(0, number.intValue());
} finally {
close(session);
}
}
use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType in project midpoint by Evolveum.
the class ModifyAssignmentTest method test20ModifyAssignment.
@Test
public void test20ModifyAssignment() throws Exception {
//given
//when
ObjectModificationType modification = PrismTestUtil.parseAtomicValue(new File(TEST_DIR, "modify-assignment.xml"), ObjectModificationType.COMPLEX_TYPE);
ObjectDelta delta = DeltaConvertor.createObjectDelta(modification, RoleType.class, prismContext);
OperationResult result = new OperationResult("modify assignment");
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 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(NEW_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 test40RenameAssignmentToInducement.
/**
* Test for MID-1374
*/
@Test
public void test40RenameAssignmentToInducement() throws Exception {
//given
//when
ObjectModificationType modification = PrismTestUtil.parseAtomicValue(new File(TEST_DIR, "modify-delete-add-assignment.xml"), ObjectModificationType.COMPLEX_TYPE);
ObjectDelta delta = DeltaConvertor.createObjectDelta(modification, RoleType.class, prismContext);
OperationResult result = new OperationResult("delete add assignment");
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());
AssertJUnit.assertNotNull(inducement.getValue(1L));
AssertJUnit.assertNotNull(inducement.getValue(2L));
AssertJUnit.assertNotNull(inducement.getValue(5L));
}
use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType in project midpoint by Evolveum.
the class ModifyUser method test030ModifyShadow.
@Test
public void test030ModifyShadow() throws Exception {
ObjectModificationType modification = PrismTestUtil.parseAtomicValue(new File(FOLDER_BASIC, "t003.xml"), ObjectModificationType.COMPLEX_TYPE);
ObjectDelta delta = DeltaConvertor.createObjectDelta(modification, ShadowType.class, prismContext);
delta.setOid(userOid);
repositoryService.modifyObject(ShadowType.class, shadowOid, delta.getModifications(), new OperationResult("asdf"));
}
use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType in project midpoint by Evolveum.
the class ModifyUser method test021ModifyUserNoEmpNum.
@Test
public void test021ModifyUserNoEmpNum() throws Exception {
final String TEST_NAME = "test021ModifyUserNoEmpNum";
TestUtil.displayTestTile(TEST_NAME);
OperationResult result = new OperationResult(TEST_NAME);
ObjectModificationType modification = PrismTestUtil.parseAtomicValue(new File(FOLDER_BASIC, "t002a.xml"), ObjectModificationType.COMPLEX_TYPE);
ObjectDelta delta = DeltaConvertor.createObjectDelta(modification, UserType.class, prismContext);
delta.setOid(userOid);
// WHEN
TestUtil.displayWhen(TEST_NAME);
repositoryService.modifyObject(UserType.class, userOid, delta.getModifications(), result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);
PrismObject<UserType> userAfter = repositoryService.getObject(UserType.class, userOid, null, result);
PrismAsserts.assertPropertyValue(userAfter, UserType.F_FULL_NAME, PrismTestUtil.createPolyString(USER_FULLNAME));
PrismAsserts.assertNoItem(userAfter, UserType.F_EMPLOYEE_NUMBER);
}
Aggregations