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