Search in sources :

Example 16 with ObjectModificationType

use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType in project midpoint by Evolveum.

the class ModifyTest method test020ModifyNotExistingUser.

@Test(expectedExceptions = ObjectNotFoundException.class, enabled = false)
public void test020ModifyNotExistingUser() throws Exception {
    final String TEST_NAME = "test020ModifyNotExistingUser";
    TestUtil.displayTestTile(TEST_NAME);
    ObjectModificationType modification = PrismTestUtil.parseAtomicValue(new File(TEST_DIR, "change-add.xml"), ObjectModificationType.COMPLEX_TYPE);
    Collection<? extends ItemDelta> deltas = DeltaConvertor.toModifications(modification, UserType.class, prismContext);
    OperationResult result = new OperationResult("MODIFY");
    repositoryService.modifyObject(UserType.class, "1234", deltas, getModifyOptions(), result);
}
Also used : ObjectModificationType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) File(java.io.File) Test(org.testng.annotations.Test)

Example 17 with ObjectModificationType

use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType in project midpoint by Evolveum.

the class ModifyTest method test030ModifyUserOnNonExistingAccountTest.

// MID-3483
@Test(enabled = false)
public void test030ModifyUserOnNonExistingAccountTest() throws Exception {
    final String TEST_NAME = "test030ModifyUserOnNonExistingAccountTest";
    TestUtil.displayTestTile(TEST_NAME);
    OperationResult result = new OperationResult("MODIFY");
    //add user
    File userFile = new File(TEST_DIR, "modify-user.xml");
    PrismObject<UserType> user = prismContext.parseObject(userFile);
    user.setOid(null);
    user.asObjectable().setName(new PolyStringType("non-existing-account-user"));
    String oid = repositoryService.addObject(user, null, result);
    PrismObject<UserType> userOld = repositoryService.getObject(UserType.class, oid, null, result);
    ObjectModificationType modification = PrismTestUtil.parseAtomicValue(new File(TEST_DIR, "change-add-non-existing.xml"), ObjectModificationType.COMPLEX_TYPE);
    Collection<? extends ItemDelta> deltas = DeltaConvertor.toModifications(modification, UserType.class, prismContext);
    repositoryService.modifyObject(UserType.class, oid, deltas, getModifyOptions(), result);
    PropertyDelta.applyTo(deltas, userOld);
    PrismObject<UserType> userNew = repositoryService.getObject(UserType.class, oid, null, result);
    ObjectDelta<UserType> delta = userOld.diff(userNew);
    LOGGER.debug("Modify diff \n{}", delta.debugDump(3));
    AssertJUnit.assertTrue("Modify was unsuccessful, diff size: " + delta.getModifications().size(), delta.isEmpty());
    AssertJUnit.assertTrue("User is not equivalent.", userOld.equivalent(userNew));
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) ObjectModificationType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) File(java.io.File) Test(org.testng.annotations.Test)

Example 18 with ObjectModificationType

use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType in project midpoint by Evolveum.

the class ModifyUser method test020ModifyUser.

@Test
public void test020ModifyUser() throws Exception {
    final String TEST_NAME = "test020ModifyUser";
    TestUtil.displayTestTile(TEST_NAME);
    OperationResult result = new OperationResult(TEST_NAME);
    ObjectModificationType modification = PrismTestUtil.parseAtomicValue(new File(FOLDER_BASIC, "t002.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.assertPropertyValue(userAfter, UserType.F_EMPLOYEE_NUMBER, "en1234");
}
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)

Example 19 with ObjectModificationType

use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType in project midpoint by Evolveum.

the class ModifyUser method test070ModifyBigUser.

/**
     * This test fails with java.lang.IllegalStateException: An entity copy was already assigned to a different entity.
     * It's ok to fail, but it should fail somehow differently.
     *
     * todo improve later [lazyman]
     */
@Test(enabled = false)
public void test070ModifyBigUser() throws Exception {
    ObjectModificationType modification = PrismTestUtil.parseAtomicValue(new File(FOLDER_BASIC, "t004.xml"), ObjectModificationType.COMPLEX_TYPE);
    ObjectDelta delta = DeltaConvertor.createObjectDelta(modification, UserType.class, prismContext);
    repositoryService.modifyObject(UserType.class, userBigOid, 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 20 with ObjectModificationType

use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType in project midpoint by Evolveum.

the class ModifyUser method test022ModifyUserEmptyEmpNum.

@Test
public void test022ModifyUserEmptyEmpNum() throws Exception {
    final String TEST_NAME = "test022ModifyUserEmptyEmpNum";
    TestUtil.displayTestTile(TEST_NAME);
    OperationResult result = new OperationResult(TEST_NAME);
    ObjectModificationType modification = PrismTestUtil.parseAtomicValue(new File(FOLDER_BASIC, "t002b.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.assertPropertyValue(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