Search in sources :

Example 91 with UserType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.UserType in project midpoint by Evolveum.

the class TestMapping method test204DummyCrimsonReconcile.

/**
	 * Just make sure that plain recon does not destroy anything.
	 * MID-3661
	 */
@Test
public void test204DummyCrimsonReconcile() throws Exception {
    final String TEST_NAME = "test204DummyCrimsonReconcile";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestMapping.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_CRIMSON_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME);
    display("Dummy account before", dummyAccountBefore);
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    reconcileUser(USER_GUYBRUSH_OID, task, result);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    TestUtil.assertSuccess("executeChanges result", result);
    PrismObject<UserType> userAfter = getUser(USER_GUYBRUSH_OID);
    display("User after", userAfter);
    assertUser(userAfter, USER_GUYBRUSH_OID, USER_GUYBRUSH_USERNAME, USER_GUYBRUSH_FULL_NAME, USER_GUYBRUSH_GIVEN_NAME, USER_GUYBRUSH_FAMILY_NAME);
    String accountOid = getSingleLinkOid(userAfter);
    PrismObject<ShadowType> repoShadow = repositoryService.getObject(ShadowType.class, accountOid, null, result);
    display("Repo shadow after", repoShadow);
    assertNoPostponedOperation(repoShadow);
    // Check account in dummy resource
    DummyAccount dummyAccountAfter = assertDummyAccount(RESOURCE_DUMMY_CRIMSON_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, ACCOUNT_GUYBRUSH_DUMMY_FULLNAME, true);
    display("Dummy account after", dummyAccountAfter);
    assertDummyAccountAttribute(RESOURCE_DUMMY_CRIMSON_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, ACCOUNT_GUYBRUSH_DUMMY_LOCATION);
    assertDummyAccountAttribute(RESOURCE_DUMMY_CRIMSON_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_DRINK_NAME, "vodka", "whisky", "rum from Melee Island");
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test)

Example 92 with UserType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.UserType in project midpoint by Evolveum.

the class TestMapping method test123ModifyAccountShip.

@Test
public void test123ModifyAccountShip() throws Exception {
    final String TEST_NAME = "test123ModifyAccountShip";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestMapping.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    dummyAuditService.clear();
    PrismObject<UserType> userJack = getUser(USER_JACK_OID);
    String accountOid = getSingleLinkOid(userJack);
    Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<ObjectDelta<? extends ObjectType>>();
    ObjectDelta<ShadowType> accountDelta = ObjectDelta.createModificationReplaceProperty(ShadowType.class, accountOid, dummyResourceCtlRed.getAttributePath(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME), prismContext, "Flying Dutchman");
    deltas.add(accountDelta);
    // WHEN
    try {
        modelService.executeChanges(deltas, null, task, result);
        AssertJUnit.fail("Unexpected success");
    } catch (SchemaException e) {
        // This is expected
        display("Expected exception", e);
    }
    // THEN
    result.computeStatus();
    TestUtil.assertFailure(result);
    userJack = getUser(USER_JACK_OID);
    display("User after change execution", userJack);
    assertUserJack(userJack, "Captain Jack Sparrow", "Jack", "Sparrow");
    assertAccountShip(userJack, "Captain Jack Sparrow", "Black Pearl", dummyResourceCtlRed, task);
    // Check audit
    display("Audit", dummyAuditService);
    dummyAuditService.assertSimpleRecordSanity();
    dummyAuditService.assertRecords(2);
    dummyAuditService.assertAnyRequestDeltas();
    dummyAuditService.assertExecutionDeltas(0);
    dummyAuditService.assertExecutionOutcome(OperationResultStatus.FATAL_ERROR);
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Task(com.evolveum.midpoint.task.api.Task) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test)

Example 93 with UserType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.UserType in project midpoint by Evolveum.

the class TestMisc method test200ExportUsers.

@Test
public void test200ExportUsers() throws Exception {
    final String TEST_NAME = "test200ExportUsers";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestMisc.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    // WHEN
    List<PrismObject<UserType>> users = modelService.searchObjects(UserType.class, null, SelectorOptions.createCollection(new ItemPath(), GetOperationOptions.createRaw()), task, result);
    // THEN
    result.computeStatus();
    display("Search users result", result);
    TestUtil.assertSuccess(result);
    assertEquals("Unexpected number of users", 5, users.size());
    for (PrismObject<UserType> user : users) {
        display("Exporting user", user);
        assertNotNull("Null definition in " + user, user.getDefinition());
        display("Definition", user.getDefinition());
        String xmlString = prismContext.serializeObjectToString(user, PrismContext.LANG_XML);
        display("Exported user", xmlString);
        Document xmlDocument = DOMUtil.parseDocument(xmlString);
        Schema javaxSchema = prismContext.getSchemaRegistry().getJavaxSchema();
        Validator validator = javaxSchema.newValidator();
        validator.setResourceResolver(prismContext.getEntityResolver());
        validator.validate(new DOMSource(xmlDocument));
        PrismObject<Objectable> parsedUser = prismContext.parseObject(xmlString);
        assertTrue("Re-parsed user is not equal to original: " + user, user.equals(parsedUser));
    }
}
Also used : Task(com.evolveum.midpoint.task.api.Task) DOMSource(javax.xml.transform.dom.DOMSource) Schema(javax.xml.validation.Schema) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Document(org.w3c.dom.Document) PrismObject(com.evolveum.midpoint.prism.PrismObject) Objectable(com.evolveum.midpoint.prism.Objectable) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Validator(javax.xml.validation.Validator) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Example 94 with UserType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.UserType in project midpoint by Evolveum.

the class TestMapping method test144ModifyAccountLocationReplaceEmpty.

/**
	 * This test will not fail. It will splice the strong mapping into an empty replace delta.
	 * That still results in a single value and is a valid operation, although it really changes nothing
	 * (replace with the same value that was already there).
	 */
@Test
public void test144ModifyAccountLocationReplaceEmpty() throws Exception {
    final String TEST_NAME = "test144ModifyAccountLocationReplaceEmpty";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestMapping.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    dummyAuditService.clear();
    PrismObject<UserType> userJack = getUser(USER_JACK_OID);
    String accountOid = getSingleLinkOid(userJack);
    Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<ObjectDelta<? extends ObjectType>>();
    ObjectDelta<ShadowType> accountDelta = ObjectDelta.createModificationReplaceProperty(ShadowType.class, accountOid, dummyResourceCtl.getAttributePath(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME), prismContext);
    deltas.add(accountDelta);
    // WHEN
    modelService.executeChanges(deltas, null, task, result);
    // THEN
    result.computeStatus();
    TestUtil.assertSuccess(result);
    userJack = getUser(USER_JACK_OID);
    display("User after change execution", userJack);
    assertUserJack(userJack, "Captain Jack Sparrow", "Jack", "Sparrow", "Fountain of Youth");
    assertAccountLocation(userJack, "Captain Jack Sparrow", "Fountain of Youth", dummyResourceCtl, task);
    // Check audit
    display("Audit", dummyAuditService);
    dummyAuditService.assertSimpleRecordSanity();
    dummyAuditService.assertRecords(2);
    dummyAuditService.assertAnyRequestDeltas();
    dummyAuditService.assertExecutionDeltas(1);
    dummyAuditService.assertHasDelta(ChangeType.MODIFY, ShadowType.class);
    dummyAuditService.assertExecutionSuccess();
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) Task(com.evolveum.midpoint.task.api.Task) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test)

Example 95 with UserType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.UserType in project midpoint by Evolveum.

the class TestMapping method test141ModifyUserFullName.

/**
	 * fullName mapping is NORMAL, the change should go through
	 */
@Test
public void test141ModifyUserFullName() throws Exception {
    final String TEST_NAME = "test141ModifyUserFullName";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestMapping.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    dummyAuditService.clear();
    // WHEN
    modifyUserReplace(USER_JACK_OID, UserType.F_FULL_NAME, task, result, PrismTestUtil.createPolyString("Captain Jack Sparrow"));
    // THEN
    result.computeStatus();
    TestUtil.assertSuccess(result);
    PrismObject<UserType> userJack = getUser(USER_JACK_OID);
    display("User after change execution", userJack);
    assertUserJack(userJack, "Captain Jack Sparrow", "Jack", "Sparrow");
    assertAccountShip(userJack, "Captain Jack Sparrow", null, dummyResourceCtl, task);
    // Check audit
    display("Audit", dummyAuditService);
    dummyAuditService.assertSimpleRecordSanity();
    dummyAuditService.assertRecords(2);
    dummyAuditService.assertAnyRequestDeltas();
    dummyAuditService.assertExecutionDeltas(2);
    dummyAuditService.assertHasDelta(ChangeType.MODIFY, UserType.class);
    dummyAuditService.assertHasDelta(ChangeType.MODIFY, ShadowType.class);
    dummyAuditService.assertExecutionSuccess();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test)

Aggregations

UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)903 Test (org.testng.annotations.Test)767 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)741 Task (com.evolveum.midpoint.task.api.Task)576 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)217 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)192 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)104 PrismObject (com.evolveum.midpoint.prism.PrismObject)100 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)99 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)88 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)85 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)84 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)83 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)77 ArrayList (java.util.ArrayList)74 QName (javax.xml.namespace.QName)74 File (java.io.File)72 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)58 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)55 PrismAsserts.assertEqualsPolyString (com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)55