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);
}
}
}
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 + "]");
}
}
}
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 + "]");
}
}
}
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 + "]");
}
}
}
Aggregations