use of com.evolveum.midpoint.test.ProvisioningScriptSpec in project midpoint by Evolveum.
the class TestImportRecon method test229ReconcileDummyFixed.
/**
* Simply re-run recon after the resource is fixed. This should correct the data.
*/
@Test
public void test229ReconcileDummyFixed() throws Exception {
final String TEST_NAME = "test229ReconcileDummyFixed";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = createTask(TestImportRecon.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE);
// Fix it!
getDummyResource().setBreakMode(BreakMode.NONE);
getDummyResource().getAccountByUsername(ACCOUNT_GUYBRUSH_DUMMY_USERNAME).setModifyBreakMode(BreakMode.NONE);
getDummyResource().purgeScriptHistory();
dummyAuditService.clear();
rememberShadowFetchOperationCount();
reconciliationTaskResultListener.clear();
// WHEN
TestUtil.displayWhen(TEST_NAME);
restartTask(TASK_RECONCILE_DUMMY_OID);
waitForTaskFinish(TASK_RECONCILE_DUMMY_OID, false, DEFAULT_TASK_WAIT_TIMEOUT, true);
// THEN
TestUtil.displayThen(TEST_NAME);
assertShadowFetchOperationCountIncrement(3);
reconciliationTaskResultListener.assertResult(RESOURCE_DUMMY_OID, 0, 7, 0, 0);
List<PrismObject<UserType>> users = modelService.searchObjects(UserType.class, null, null, task, result);
display("Users after import", users);
assertImportedUserByOid(USER_ADMINISTRATOR_OID);
assertImportedUserByOid(USER_JACK_OID);
assertImportedUserByOid(USER_BARBOSSA_OID);
assertImportedUserByOid(USER_GUYBRUSH_OID, RESOURCE_DUMMY_OID);
assertDummyAccountAttribute(null, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Dubrish Freepweed");
assertDummyAccountAttribute(null, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "Melee Island");
assertDummyAccountAttribute(null, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME, "Feather duster");
assertDummyAccountAttribute(null, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_DRINK_NAME, "rum");
assertDummyAccountAttribute(null, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_QUOTE_NAME, "Arr!", "I want to be a pirate!");
assertImportedUserByOid(USER_RAPP_OID, RESOURCE_DUMMY_OID, RESOURCE_DUMMY_LIME_OID);
PrismObject<UserType> userRappAfter = getUser(USER_RAPP_OID);
display("User rapp after", userRappAfter);
PrismAsserts.assertPropertyValue(userRappAfter, UserType.F_ORGANIZATIONAL_UNIT, PrismTestUtil.createPolyString("The crew of The Elaine"));
assertImportedUserByUsername(ACCOUNT_HERMAN_DUMMY_USERNAME, RESOURCE_DUMMY_OID);
assertNoImporterUserByUsername(ACCOUNT_DAVIEJONES_DUMMY_USERNAME);
assertNoImporterUserByUsername(ACCOUNT_CALYPSO_DUMMY_USERNAME);
assertDummyAccountAttribute(null, ACCOUNT_CALYPSO_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Calypso");
assertEquals("Unexpected number of users", 10, users.size());
display("Dummy resource", getDummyResource().debugDump());
display("Script history", getDummyResource().getScriptHistory());
ArrayList<ProvisioningScriptSpec> scripts = new ArrayList<ProvisioningScriptSpec>();
addReconScripts(scripts, ACCOUNT_HERMAN_DUMMY_USERNAME, "Herman Toothrot", false);
addReconScripts(scripts, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, "Guybrush Threepwood", true);
addReconScripts(scripts, ACCOUNT_ELAINE_DUMMY_USERNAME, "Elaine Marley", false);
addReconScripts(scripts, USER_RAPP_USERNAME, USER_RAPP_FULLNAME, false);
addReconScripts(scripts, ACCOUNT_STAN_NAME, ACCOUNT_STAN_FULLNAME, false);
IntegrationTestTools.assertScripts(getDummyResource().getScriptHistory(), scripts.toArray(new ProvisioningScriptSpec[0]));
assertReconAuditModifications(1, TASK_RECONCILE_DUMMY_OID);
// Task result
PrismObject<TaskType> reconTaskAfter = getTask(TASK_RECONCILE_DUMMY_OID);
OperationResultType reconTaskResult = reconTaskAfter.asObjectable().getResult();
display("Recon task result", reconTaskResult);
TestUtil.assertSuccess(reconTaskResult);
}
use of com.evolveum.midpoint.test.ProvisioningScriptSpec in project midpoint by Evolveum.
the class TestModelServiceContract method assertDummyScriptsAdd.
private void assertDummyScriptsAdd(PrismObject<UserType> user, PrismObject<? extends ShadowType> account, ResourceType resource) {
ProvisioningScriptSpec script = new ProvisioningScriptSpec("\nto spiral :size\n" + " if :size > 30 [stop]\n fd :size rt 15\n spiral :size *1.02\nend\n ");
String userName = null;
if (user != null) {
userName = user.asObjectable().getName().getOrig();
}
script.addArgSingle("usr", "user: " + userName);
// Note: We cannot test for account name as name is only assigned in provisioning
String accountEnabled = null;
if (account != null && account.asObjectable().getActivation() != null && account.asObjectable().getActivation().getAdministrativeStatus() != null) {
accountEnabled = account.asObjectable().getActivation().getAdministrativeStatus().toString();
}
script.addArgSingle("acc", "account: " + accountEnabled);
String resourceName = null;
if (resource != null) {
resourceName = resource.getName().getOrig();
}
script.addArgSingle("res", "resource: " + resourceName);
script.addArgSingle("size", "3");
script.setLanguage("Logo");
IntegrationTestTools.assertScripts(getDummyResource().getScriptHistory(), script);
}
use of com.evolveum.midpoint.test.ProvisioningScriptSpec in project midpoint by Evolveum.
the class TestModelServiceContract method assertDummyScriptsModify.
private void assertDummyScriptsModify(PrismObject<UserType> user, boolean recon) {
ProvisioningScriptSpec modScript = new ProvisioningScriptSpec("Beware the Jabberwock, my son!");
String name = null;
String fullName = null;
String costCenter = null;
if (user != null) {
name = user.asObjectable().getName().getOrig();
fullName = user.asObjectable().getFullName().getOrig();
costCenter = user.asObjectable().getCostCenter();
}
modScript.addArgSingle("howMuch", costCenter);
modScript.addArgSingle("howLong", "from here to there");
modScript.addArgSingle("who", name);
modScript.addArgSingle("whatchacallit", fullName);
if (recon) {
ProvisioningScriptSpec reconBeforeScript = new ProvisioningScriptSpec("The vorpal blade went snicker-snack!");
reconBeforeScript.addArgSingle("who", name);
ProvisioningScriptSpec reconAfterScript = new ProvisioningScriptSpec("He left it dead, and with its head");
reconAfterScript.addArgSingle("how", "enabled");
IntegrationTestTools.assertScripts(getDummyResource().getScriptHistory(), reconBeforeScript, modScript, reconAfterScript);
} else {
IntegrationTestTools.assertScripts(getDummyResource().getScriptHistory(), modScript);
}
}
use of com.evolveum.midpoint.test.ProvisioningScriptSpec in project midpoint by Evolveum.
the class TestModelServiceContract method assertDummyScriptsDelete.
private void assertDummyScriptsDelete() {
ProvisioningScriptSpec script = new ProvisioningScriptSpec("The Jabberwock, with eyes of flame");
IntegrationTestTools.assertScripts(getDummyResource().getScriptHistory(), script);
}
use of com.evolveum.midpoint.test.ProvisioningScriptSpec in project midpoint by Evolveum.
the class TestNotifications method assertDummyScriptsAdd.
private void assertDummyScriptsAdd(PrismObject<UserType> user, PrismObject<? extends ShadowType> account, ResourceType resource) {
ProvisioningScriptSpec script = new ProvisioningScriptSpec("\nto spiral :size\n" + " if :size > 30 [stop]\n fd :size rt 15\n spiral :size *1.02\nend\n ");
String userName = null;
if (user != null) {
userName = user.asObjectable().getName().getOrig();
}
script.addArgSingle("usr", "user: " + userName);
// Note: We cannot test for account name as name is only assigned in provisioning
String accountEnabled = null;
if (account != null && account.asObjectable().getActivation() != null && account.asObjectable().getActivation().getAdministrativeStatus() != null) {
accountEnabled = account.asObjectable().getActivation().getAdministrativeStatus().toString();
}
script.addArgSingle("acc", "account: " + accountEnabled);
String resourceName = null;
if (resource != null) {
resourceName = resource.getName().getOrig();
}
script.addArgSingle("res", "resource: " + resourceName);
script.addArgSingle("size", "3");
script.setLanguage("Logo");
IntegrationTestTools.assertScripts(getDummyResource().getScriptHistory(), script);
}
Aggregations