Search in sources :

Example 31 with ObjectModificationType

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);
    }
}
Also used : Query(org.hibernate.Query) AbstractRoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType) RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Session(org.hibernate.Session) Test(org.testng.annotations.Test)

Example 32 with ObjectModificationType

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());
}
Also used : ObjectModificationType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) File(java.io.File) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Example 33 with ObjectModificationType

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));
}
Also used : ObjectModificationType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) File(java.io.File) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Example 34 with ObjectModificationType

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"));
}
Also used : ObjectModificationType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) File(java.io.File) Test(org.testng.annotations.Test)

Example 35 with ObjectModificationType

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);
}
Also used : ObjectModificationType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) File(java.io.File) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test)

Aggregations

ObjectModificationType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType)45 Test (org.testng.annotations.Test)40 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)31 File (java.io.File)31 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)13 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)12 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)8 Task (com.evolveum.midpoint.task.api.Task)7 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)6 Session (org.hibernate.Session)6 ROrgClosure (com.evolveum.midpoint.repo.sql.data.common.ROrgClosure)5 OrgType (com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType)5 Entry (org.opends.server.types.Entry)4 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)3 ItemDeltaType (com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType)3 QName (javax.xml.namespace.QName)3 ReferenceDelta (com.evolveum.midpoint.prism.delta.ReferenceDelta)2 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)2 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)2 PolyStringType (com.evolveum.prism.xml.ns._public.types_3.PolyStringType)2