Search in sources :

Example 1 with PrismAsserts.assertEqualsPolyString

use of com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString in project midpoint by Evolveum.

the class TestSanityLegacy method test020ModifyUser.

/**
     * We are going to modify the user. As the user has an account, the user
     * changes should be also applied to the account (by schemaHandling).
     */
@Test
public void test020ModifyUser() throws Exception {
    final String TEST_NAME = "test020ModifyUser";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    assertNoRepoCache();
    ObjectDeltaType objectChange = unmarshallValueFromFile(REQUEST_USER_MODIFY_FULLNAME_LOCALITY_FILENAME, ObjectDeltaType.class);
    // WHEN ObjectTypes.USER.getTypeQName(), 
    OperationResultType result = modifyObjectViaModelWS(objectChange);
    // THEN
    assertNoRepoCache();
    displayJaxb("modifyObject result:", result, SchemaConstants.C_RESULT);
    TestUtil.assertSuccess("modifyObject has failed", result);
    // Check if user object was modified in the repo
    OperationResult repoResult = new OperationResult("getObject");
    PrismObject<UserType> repoUser = repositoryService.getObject(UserType.class, USER_JACK_OID, null, repoResult);
    UserType repoUserType = repoUser.asObjectable();
    display("repository user", repoUser);
    PrismAsserts.assertEqualsPolyString("wrong value for fullName", "Cpt. Jack Sparrow", repoUserType.getFullName());
    PrismAsserts.assertEqualsPolyString("wrong value for locality", "somewhere", repoUserType.getLocality());
    assertEquals("wrong value for employeeNumber", "1", repoUserType.getEmployeeNumber());
    // Check if appropriate accountRef is still there
    List<ObjectReferenceType> accountRefs = repoUserType.getLinkRef();
    assertEquals(1, accountRefs.size());
    for (ObjectReferenceType accountRef : accountRefs) {
        assertTrue("No OID in " + accountRef + " in " + repoUserType, accountRef.getOid().equals(accountShadowOidOpendj));
    }
    // Check if shadow is still in the repo and that it is untouched
    repoResult = new OperationResult("getObject");
    PrismObject<ShadowType> repoShadow = repositoryService.getObject(ShadowType.class, accountShadowOidOpendj, null, repoResult);
    repoResult.computeStatus();
    TestUtil.assertSuccess("getObject(repo) has failed", repoResult);
    display("repository shadow", repoShadow);
    AssertJUnit.assertNotNull(repoShadow);
    ShadowType repoShadowType = repoShadow.asObjectable();
    AssertJUnit.assertEquals(RESOURCE_OPENDJ_OID, repoShadowType.getResourceRef().getOid());
    // check attributes in the shadow: should be only identifiers (ICF UID)
    String uid = checkRepoShadow(repoShadow);
    // Check if LDAP account was updated
    assertOpenDJAccountJack(uid, "jack");
}
Also used : ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PrismAsserts.assertEqualsPolyString(com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 2 with PrismAsserts.assertEqualsPolyString

use of com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString in project midpoint by Evolveum.

the class TestSanityLegacy method test302LiveSyncModify.

@Test
public void test302LiveSyncModify() throws Exception {
    final String TEST_NAME = "test302LiveSyncModify";
    TestUtil.displayTestTile(TEST_NAME);
    final OperationResult result = new OperationResult(TestSanityLegacy.class.getName() + "." + TEST_NAME);
    final Task syncCycle = taskManager.getTask(TASK_OPENDJ_SYNC_OID, result);
    AssertJUnit.assertNotNull(syncCycle);
    int tokenBefore = findSyncToken(syncCycle);
    display("Sync token before", tokenBefore);
    // WHEN
    display("Modifying LDAP entry");
    ChangeRecordEntry entry = openDJController.executeLdifChange(LDIF_WILL_MODIFY_FILE);
    // THEN
    display("Entry from LDIF", entry);
    // Wait a bit to give the sync cycle time to detect the change
    basicWaitForSyncChangeDetection(syncCycle, tokenBefore, 1, result);
    // Search for the user that should be created now
    UserType user = searchUserByName(WILL_NAME);
    //        AssertJUnit.assertEquals(WILL_NAME, user.getName());
    PrismAsserts.assertEqualsPolyString("Wrong name.", WILL_NAME, user.getName());
    PrismAsserts.assertEqualsPolyString("wrong givenName", "asdf", user.getGivenName());
    assertAndStoreSyncTokenIncrement(syncCycle, 1);
    checkAllShadows();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ChangeRecordEntry(org.opends.server.util.ChangeRecordEntry) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PrismAsserts.assertEqualsPolyString(com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 3 with PrismAsserts.assertEqualsPolyString

use of com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString in project midpoint by Evolveum.

the class TestSanityLegacy method test503NotifyChangeDeleteAccount.

@Test
public void test503NotifyChangeDeleteAccount() throws Exception {
    TestUtil.displayTestTile("test503NotifyChangeDeleteAccount");
    OperationResult parentResult = new OperationResult("test500notifyChange.addAngelicaAccount");
    PrismObject<UserType> userAngelika = findUserByUsername(ANGELIKA_NAME);
    assertNotNull("User with the name angelika must exist.", userAngelika);
    UserType user = userAngelika.asObjectable();
    assertNotNull("User with the name angelika must have one link ref.", user.getLinkRef());
    assertEquals("Expected one account ref in user", 1, user.getLinkRef().size());
    String oid = user.getLinkRef().get(0).getOid();
    ResourceObjectShadowChangeDescriptionType changeDescription = new ResourceObjectShadowChangeDescriptionType();
    ObjectDeltaType delta = new ObjectDeltaType();
    delta.setChangeType(ChangeTypeType.DELETE);
    delta.setObjectType(ShadowType.COMPLEX_TYPE);
    delta.setOid(oid);
    changeDescription.setObjectDelta(delta);
    changeDescription.setOldShadowOid(oid);
    changeDescription.setChannel(SchemaConstants.CHANNEL_WEB_SERVICE_URI);
    TaskType task = modelWeb.notifyChange(changeDescription);
    OperationResult result = OperationResult.createOperationResult(task.getResult());
    display(result);
    assertSuccess(result);
    PrismObject<UserType> userAngelikaAfterSync = findUserByUsername(ANGELIKA_NAME);
    assertNotNull("User with the name angelika must exist.", userAngelikaAfterSync);
    UserType userType = userAngelikaAfterSync.asObjectable();
    assertNotNull("User with the name angelika must have one link ref.", userType.getLinkRef());
    assertEquals("Expected no account ref in user", 0, userType.getLinkRef().size());
//    	String oid = userType.getLinkRef().get(0).getOid();
//    	UserType userAfterSync = userAngelikaAfterSync.asObjectable();
//    	PrismAsserts.assertEqualsPolyString("wrong given name in user angelika", PrismTestUtil.createPolyStringType("newAngelika"), userAfterSync.getGivenName());
}
Also used : ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PrismAsserts.assertEqualsPolyString(com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString) ResourceObjectShadowChangeDescriptionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectShadowChangeDescriptionType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 4 with PrismAsserts.assertEqualsPolyString

use of com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString in project midpoint by Evolveum.

the class TestSanityLegacy method test501NotifyChangeModifyAccount.

@Test
public void test501NotifyChangeModifyAccount() throws Exception {
    TestUtil.displayTestTile("test501NotifyChangeModifyAccount");
    OperationResult parentResult = new OperationResult("test500notifyChange.addAngelicaAccount");
    PrismObject<UserType> userAngelika = findUserByUsername(ANGELIKA_NAME);
    assertNotNull("User with the name angelika must exist.", userAngelika);
    UserType user = userAngelika.asObjectable();
    assertNotNull("User with the name angelika must have one link ref.", user.getLinkRef());
    assertEquals("Expected one account ref in user", 1, user.getLinkRef().size());
    String oid = user.getLinkRef().get(0).getOid();
    ResourceObjectShadowChangeDescriptionType changeDescription = new ResourceObjectShadowChangeDescriptionType();
    ObjectDeltaType delta = new ObjectDeltaType();
    delta.setChangeType(ChangeTypeType.MODIFY);
    delta.setObjectType(ShadowType.COMPLEX_TYPE);
    ItemDeltaType mod1 = new ItemDeltaType();
    mod1.setModificationType(ModificationTypeType.REPLACE);
    ItemPathType path = new ItemPathType(new ItemPath(ShadowType.F_ATTRIBUTES, new QName(resourceTypeOpenDjrepo.getNamespace(), "givenName")));
    mod1.setPath(path);
    RawType value = new RawType(new PrimitiveXNode<String>("newAngelika"), prismContext);
    //TODO: shouldn't it be JaxbElement<PolyString>? 
    //    	Element el = DOMUtil.createElement(DOMUtil.getDocument(), new QName(resourceTypeOpenDjrepo.getNamespace(), "givenName"));
    //    	el.setTextContent("newAngelika");
    mod1.getValue().add(value);
    delta.getItemDelta().add(mod1);
    delta.setOid(oid);
    LOGGER.info("item delta: {}", SchemaDebugUtil.prettyPrint(mod1));
    LOGGER.info("delta: {}", DebugUtil.dump(mod1));
    changeDescription.setObjectDelta(delta);
    changeDescription.setOldShadowOid(oid);
    changeDescription.setChannel(SchemaConstants.CHANNEL_WEB_SERVICE_URI);
    TaskType task = modelWeb.notifyChange(changeDescription);
    OperationResult result = OperationResult.createOperationResult(task.getResult());
    display(result);
    assertSuccess(result);
    PrismObject<UserType> userAngelikaAfterSync = findUserByUsername(ANGELIKA_NAME);
    assertNotNull("User with the name angelika must exist.", userAngelikaAfterSync);
    UserType userAfterSync = userAngelikaAfterSync.asObjectable();
    PrismAsserts.assertEqualsPolyString("wrong given name in user angelika", PrismTestUtil.createPolyStringType("newAngelika"), userAfterSync.getGivenName());
}
Also used : ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) QName(javax.xml.namespace.QName) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PrismAsserts.assertEqualsPolyString(com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString) ItemDeltaType(com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType) ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) RawType(com.evolveum.prism.xml.ns._public.types_3.RawType) ResourceObjectShadowChangeDescriptionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectShadowChangeDescriptionType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 5 with PrismAsserts.assertEqualsPolyString

use of com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString in project midpoint by Evolveum.

the class TestSanity method test020ModifyUser.

/**
     * We are going to modify the user. As the user has an account, the user
     * changes should be also applied to the account (by schemaHandling).
     */
@Test
public void test020ModifyUser() throws Exception {
    final String TEST_NAME = "test020ModifyUser";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    assertNoRepoCache();
    ObjectDeltaType objectChange = unmarshallValueFromFile(REQUEST_USER_MODIFY_FULLNAME_LOCALITY_FILENAME, ObjectDeltaType.class);
    // WHEN ObjectTypes.USER.getTypeQName(), 
    OperationResultType result = modifyObjectViaModelWS(objectChange);
    // THEN
    assertNoRepoCache();
    displayJaxb("modifyObject result:", result, SchemaConstants.C_RESULT);
    TestUtil.assertSuccess("modifyObject has failed", result);
    // Check if user object was modified in the repo
    OperationResult repoResult = new OperationResult("getObject");
    PrismObject<UserType> repoUser = repositoryService.getObject(UserType.class, USER_JACK_OID, null, repoResult);
    UserType repoUserType = repoUser.asObjectable();
    display("repository user", repoUser);
    PrismAsserts.assertEqualsPolyString("wrong value for fullName", "Cpt. Jack Sparrow", repoUserType.getFullName());
    PrismAsserts.assertEqualsPolyString("wrong value for locality", "somewhere", repoUserType.getLocality());
    assertEquals("wrong value for employeeNumber", "1", repoUserType.getEmployeeNumber());
    // Check if appropriate accountRef is still there
    List<ObjectReferenceType> accountRefs = repoUserType.getLinkRef();
    assertEquals(2, accountRefs.size());
    for (ObjectReferenceType accountRef : accountRefs) {
        assertTrue("No OID in " + accountRef + " in " + repoUserType, accountRef.getOid().equals(accountShadowOidOpendj) || accountRef.getOid().equals(accountShadowOidDerby));
    }
    // Check if shadow is still in the repo and that it is untouched
    repoResult = new OperationResult("getObject");
    PrismObject<ShadowType> repoShadow = repositoryService.getObject(ShadowType.class, accountShadowOidOpendj, null, repoResult);
    repoResult.computeStatus();
    TestUtil.assertSuccess("getObject(repo) has failed", repoResult);
    display("repository shadow", repoShadow);
    AssertJUnit.assertNotNull(repoShadow);
    ShadowType repoShadowType = repoShadow.asObjectable();
    AssertJUnit.assertEquals(RESOURCE_OPENDJ_OID, repoShadowType.getResourceRef().getOid());
    // check attributes in the shadow: should be only identifiers (ICF UID)
    String uid = checkRepoShadow(repoShadow);
    // Check if LDAP account was updated
    assertOpenDJAccountJack(uid, "jack");
}
Also used : ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PrismAsserts.assertEqualsPolyString(com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Aggregations

PrismAsserts.assertEqualsPolyString (com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)20 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)20 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)20 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)18 Test (org.testng.annotations.Test)18 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)12 ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)12 ChangeRecordEntry (org.opends.server.util.ChangeRecordEntry)12 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)10 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)8 Task (com.evolveum.midpoint.task.api.Task)6 TaskType (com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType)6 ResourceObjectShadowChangeDescriptionType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectShadowChangeDescriptionType)4 QName (javax.xml.namespace.QName)4 ItemDeltaType (com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType)3 RawType (com.evolveum.prism.xml.ns._public.types_3.RawType)3 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)2 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)2 Checker (com.evolveum.midpoint.test.Checker)2 ObjectChecker (com.evolveum.midpoint.test.ObjectChecker)2