Search in sources :

Example 1 with ScriptHistoryEntry

use of com.evolveum.icf.dummy.resource.ScriptHistoryEntry in project midpoint by Evolveum.

the class IntegrationTestTools method assertScripts.

public static void assertScripts(List<ScriptHistoryEntry> scriptsHistory, ProvisioningScriptSpec... expectedScripts) {
    displayScripts(scriptsHistory);
    assertEquals("Wrong number of scripts executed", expectedScripts.length, scriptsHistory.size());
    Iterator<ScriptHistoryEntry> historyIter = scriptsHistory.iterator();
    for (ProvisioningScriptSpec expecedScript : expectedScripts) {
        ScriptHistoryEntry actualScript = historyIter.next();
        assertEquals("Wrong script code", expecedScript.getCode(), actualScript.getCode());
        if (expecedScript.getLanguage() == null) {
            assertEquals("We talk only gibberish here", "Gibberish", actualScript.getLanguage());
        } else {
            assertEquals("Wrong script language", expecedScript.getLanguage(), actualScript.getLanguage());
        }
        assertEquals("Wrong number of arguments", expecedScript.getArgs().size(), actualScript.getParams().size());
        for (java.util.Map.Entry<String, Object> expectedEntry : expecedScript.getArgs().entrySet()) {
            Object expectedValue = expectedEntry.getValue();
            Object actualVal = actualScript.getParams().get(expectedEntry.getKey());
            assertEquals("Wrong value for argument '" + expectedEntry.getKey() + "'", expectedValue, actualVal);
        }
    }
}
Also used : ScriptHistoryEntry(com.evolveum.icf.dummy.resource.ScriptHistoryEntry) PolyString(com.evolveum.midpoint.prism.polystring.PolyString)

Example 2 with ScriptHistoryEntry

use of com.evolveum.icf.dummy.resource.ScriptHistoryEntry in project midpoint by Evolveum.

the class TestReconScript method text001testReconcileScriptsWhenProvisioning.

@Test
public void text001testReconcileScriptsWhenProvisioning() throws Exception {
    final String TEST_NAME = "text001testReconcileScriptsWhenProvisioning";
    TestUtil.displayTestTile(this, TEST_NAME);
    Task task = taskManager.createTaskInstance(TEST_NAME);
    OperationResult parentResult = new OperationResult(TEST_NAME);
    ObjectDelta<UserType> delta = createModifyUserAddAccount(USER_JACK_OID, getDummyResourceObject());
    Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<ObjectDelta<? extends ObjectType>>();
    deltas.add(delta);
    task.setChannel(QNameUtil.qNameToUri(SchemaConstants.CHANGE_CHANNEL_RECON));
    modelService.executeChanges(deltas, ModelExecuteOptions.createReconcile(), task, parentResult);
    delta = createModifyUserReplaceDelta(USER_JACK_OID, new ItemPath(UserType.F_FULL_NAME), new PolyString("tralala"));
    deltas = new ArrayList<ObjectDelta<? extends ObjectType>>();
    deltas.add(delta);
    modelService.executeChanges(deltas, ModelExecuteOptions.createReconcile(), task, parentResult);
    delta = createModifyUserReplaceDelta(USER_BARBOSSA_OID, new ItemPath(UserType.F_FULL_NAME), new PolyString("tralala"));
    deltas = new ArrayList<ObjectDelta<? extends ObjectType>>();
    deltas.add(delta);
    modelService.executeChanges(deltas, ModelExecuteOptions.createReconcile(), task, parentResult);
    for (ScriptHistoryEntry script : getDummyResource().getScriptHistory()) {
        String userName = (String) script.getParams().get("midpoint_usercn");
        String idPath = (String) script.getParams().get("midpoint_idpath");
        String tempPath = (String) script.getParams().get("midpoint_temppath");
        LOGGER.trace("userName {} idPath {} tempPath {}", new Object[] { userName, idPath, tempPath });
        if (!idPath.contains(userName)) {
            AssertJUnit.fail("Expected that idPath will contain userName [idPath: " + idPath + ", userName " + userName + "]");
        }
        if (!tempPath.contains(userName)) {
            AssertJUnit.fail("Expected that tempPath will contain userName [idPath: " + idPath + ", userName " + userName + "]");
        }
    }
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) ScriptHistoryEntry(com.evolveum.icf.dummy.resource.ScriptHistoryEntry) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test) AbstractInternalModelIntegrationTest(com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)

Example 3 with ScriptHistoryEntry

use of com.evolveum.icf.dummy.resource.ScriptHistoryEntry in project midpoint by Evolveum.

the class TestReconScript method test003testReconcileScriptsAddUserAction.

@Test
public void test003testReconcileScriptsAddUserAction() throws Exception {
    final String TEST_NAME = "test003testReconcileScriptsAddUserAction";
    TestUtil.displayTestTile(this, TEST_NAME);
    Task task = taskManager.createTaskInstance(TEST_NAME);
    OperationResult parentResult = new OperationResult(TEST_NAME);
    ShadowType shadow = parseObjectType(new File(ACCOUNT_BEFORE_SCRIPT_FILENAME), ShadowType.class);
    provisioningService.addObject(shadow.asPrismObject(), null, null, task, parentResult);
    getDummyResource().getScriptHistory().clear();
    waitForTaskStart(TASK_RECON_DUMMY_OID, false, DEFAULT_TASK_WAIT_TIMEOUT);
    waitForTaskNextRunAssertSuccess(TASK_RECON_DUMMY_OID, false, DEFAULT_TASK_WAIT_TIMEOUT);
    waitForTaskFinish(TASK_RECON_DUMMY_OID, true);
    PrismObject<ShadowType> afterRecon = repositoryService.getObject(ShadowType.class, ACCOUNT_BEFORE_SCRIPT_OID, null, parentResult);
    AssertJUnit.assertNotNull(afterRecon);
    ShadowType afterReconShadow = afterRecon.asObjectable();
    if (afterReconShadow.getResult() != null) {
        OperationResult beforeScriptResult = OperationResult.createOperationResult(afterReconShadow.getResult());
        display("result in shadow: " + beforeScriptResult);
        AssertJUnit.fail("Operation in shadow not null, recocniliation failed. ");
    }
    PrismObject<FocusType> user = repositoryService.searchShadowOwner(ACCOUNT_BEFORE_SCRIPT_OID, null, parentResult);
    AssertJUnit.assertNotNull("Owner for account " + shadow.asPrismObject() + " not found. Some probelm in recon occured.", user);
    for (ScriptHistoryEntry script : getDummyResource().getScriptHistory()) {
        String userName = (String) script.getParams().get("midpoint_usercn");
        String idPath = (String) script.getParams().get("midpoint_idpath");
        String tempPath = (String) script.getParams().get("midpoint_temppath");
        LOGGER.trace("userName {} idPath {} tempPath {}", new Object[] { userName, idPath, tempPath });
        if (!idPath.contains(userName)) {
            AssertJUnit.fail("Expected that idPath will contain userName [idPath: " + idPath + ", userName " + userName + "]");
        }
        if (!tempPath.contains(userName)) {
            AssertJUnit.fail("Expected that tempPath will contain userName [idPath: " + idPath + ", userName " + userName + "]");
        }
    }
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) FocusType(com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType) ScriptHistoryEntry(com.evolveum.icf.dummy.resource.ScriptHistoryEntry) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) File(java.io.File) Test(org.testng.annotations.Test) AbstractInternalModelIntegrationTest(com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)

Example 4 with ScriptHistoryEntry

use of com.evolveum.icf.dummy.resource.ScriptHistoryEntry in project midpoint by Evolveum.

the class TestReconScript method test002testReconcileScriptsWhenReconciling.

@Test
public void test002testReconcileScriptsWhenReconciling() throws Exception {
    final String TEST_NAME = "test002testReconcileScriptsWhenReconciling";
    TestUtil.displayTestTile(this, TEST_NAME);
    getDummyResource().getScriptHistory().clear();
    importObjectFromFile(new File(TASK_RECON_DUMMY_FILENAME));
    waitForTaskStart(TASK_RECON_DUMMY_OID, false, DEFAULT_TASK_WAIT_TIMEOUT);
    waitForTaskNextRunAssertSuccess(TASK_RECON_DUMMY_OID, false, DEFAULT_TASK_WAIT_TIMEOUT);
    waitForTaskFinish(TASK_RECON_DUMMY_OID, false);
    for (ScriptHistoryEntry script : getDummyResource().getScriptHistory()) {
        String userName = (String) script.getParams().get("midpoint_usercn");
        String idPath = (String) script.getParams().get("midpoint_idpath");
        String tempPath = (String) script.getParams().get("midpoint_temppath");
        LOGGER.trace("userName {} idPath {} tempPath {}", new Object[] { userName, idPath, tempPath });
        if (!idPath.contains(userName)) {
            AssertJUnit.fail("Expected that idPath will contain userName [idPath: " + idPath + ", userName " + userName + "]");
        }
        if (!tempPath.contains(userName)) {
            AssertJUnit.fail("Expected that tempPath will contain userName [idPath: " + idPath + ", userName " + userName + "]");
        }
    }
}
Also used : ScriptHistoryEntry(com.evolveum.icf.dummy.resource.ScriptHistoryEntry) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) File(java.io.File) Test(org.testng.annotations.Test) AbstractInternalModelIntegrationTest(com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)

Aggregations

ScriptHistoryEntry (com.evolveum.icf.dummy.resource.ScriptHistoryEntry)4 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)4 AbstractInternalModelIntegrationTest (com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)3 Test (org.testng.annotations.Test)3 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2 Task (com.evolveum.midpoint.task.api.Task)2 File (java.io.File)2 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)1 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)1 FocusType (com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType)1 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)1 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)1 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)1 ArrayList (java.util.ArrayList)1