use of com.evolveum.midpoint.prism.delta.ObjectDelta 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.prism.delta.ObjectDelta in project midpoint by Evolveum.
the class TestMapping method test139DeleteAccountRed.
/**
* Note: red resource disables account on unsassign, does NOT delete it
* So let's delete the account explicitly to make room for the following tests
*/
@Test
public void test139DeleteAccountRed() throws Exception {
final String TEST_NAME = "test139DeleteAccountRed";
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 acccountRedOid = getLinkRefOid(userJack, RESOURCE_DUMMY_RED_OID);
Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<ObjectDelta<? extends ObjectType>>();
ObjectDelta<ShadowType> shadowDelta = ObjectDelta.createDeleteDelta(ShadowType.class, acccountRedOid, prismContext);
deltas.add(shadowDelta);
// WHEN
modelService.executeChanges(deltas, null, task, result);
// THEN
result.computeStatus();
TestUtil.assertSuccess(result);
userJack = getUser(USER_JACK_OID);
assertUserJack(userJack, "Captain Jack Sparrow", "Jack", "Sparrow");
assertNoLinkedAccount(userJack);
// Check if dummy resource accounts are gone
assertNoDummyAccount("jack");
assertNoDummyAccount(RESOURCE_DUMMY_RED_NAME, "jack");
// Check audit
display("Audit", dummyAuditService);
dummyAuditService.assertSimpleRecordSanity();
dummyAuditService.assertRecords(2);
dummyAuditService.assertAnyRequestDeltas();
dummyAuditService.assertExecutionDeltas(2);
dummyAuditService.assertHasDelta(ChangeType.MODIFY, UserType.class);
dummyAuditService.assertHasDelta(ChangeType.DELETE, ShadowType.class);
dummyAuditService.assertExecutionSuccess();
}
use of com.evolveum.midpoint.prism.delta.ObjectDelta in project midpoint by Evolveum.
the class TestMapping method test102ModifyUserFullNameRecon.
@Test
public void test102ModifyUserFullNameRecon() throws Exception {
final String TEST_NAME = "test102ModifyUserFullNameRecon";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestMapping.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
dummyAuditService.clear();
// WHEN
TestUtil.displayWhen(TEST_NAME);
ObjectDelta<UserType> objectDelta = createModifyUserReplaceDelta(USER_JACK_OID, UserType.F_FULL_NAME, PrismTestUtil.createPolyString("Captain Jack Sparrow"));
Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(objectDelta);
modelService.executeChanges(deltas, ModelExecuteOptions.createReconcile(), task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
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, "Jack Sparrow", null, dummyResourceCtlBlue, task);
// The quote attribute was empty before this operation. So the weak mapping kicks in
// and sets a new value.
assertDummyAccountAttribute(RESOURCE_DUMMY_BLUE_NAME, USER_JACK_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_QUOTE_NAME, "Where's the rum? -- Captain Jack Sparrow");
// Check audit
display("Audit", dummyAuditService);
dummyAuditService.assertSimpleRecordSanity();
dummyAuditService.assertRecords(2);
dummyAuditService.assertAnyRequestDeltas();
dummyAuditService.assertExecutionDeltas(2);
dummyAuditService.assertHasDelta(ChangeType.MODIFY, UserType.class);
dummyAuditService.assertExecutionSuccess();
}
use of com.evolveum.midpoint.prism.delta.ObjectDelta in project midpoint by Evolveum.
the class TestMapping method test107ModifyAccountShipAgain.
@Test
public void test107ModifyAccountShipAgain() throws Exception {
final String TEST_NAME = "test107ModifyAccountShipAgain";
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, dummyResourceCtlBlue.getAttributePath(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME), prismContext, "HMS Dauntless");
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");
assertAccountShip(userJack, "Jack Sparrow", "HMS Dauntless", dummyResourceCtlBlue, 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.prism.delta.ObjectDelta in project midpoint by Evolveum.
the class TestLoggingConfiguration method test021JulLoggingEnabled.
@Test
public void test021JulLoggingEnabled() throws Exception {
final String TEST_NAME = "test021JulLoggingEnabled";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
LogfileTestTailer tailer = new LogfileTestTailer(LoggingConfigurationManager.AUDIT_LOGGER_NAME);
java.util.logging.Logger julLogger = java.util.logging.Logger.getLogger(JUL_LOGGER_NAME);
Task task = taskManager.createTaskInstance(TestLoggingConfiguration.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
// Setup
PrismObject<SystemConfigurationType> systemConfiguration = PrismTestUtil.parseObject(AbstractInitializedModelIntegrationTest.SYSTEM_CONFIGURATION_FILE);
LoggingConfigurationType logging = systemConfiguration.asObjectable().getLogging();
applyTestLoggingConfig(logging);
ClassLoggerConfigurationType classLogerCongif = new ClassLoggerConfigurationType();
classLogerCongif.setPackage(JUL_LOGGER_NAME);
classLogerCongif.setLevel(LoggingLevelType.ALL);
logging.getClassLogger().add(classLogerCongif);
ObjectDelta<SystemConfigurationType> systemConfigDelta = ObjectDelta.createModificationReplaceProperty(SystemConfigurationType.class, AbstractInitializedModelIntegrationTest.SYSTEM_CONFIGURATION_OID, SystemConfigurationType.F_LOGGING, prismContext, logging);
Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(systemConfigDelta);
modelService.executeChanges(deltas, null, task, result);
// WHEN
julLogger.severe(LogfileTestTailer.MARKER + " JULsevere");
julLogger.warning(LogfileTestTailer.MARKER + " JULwarning");
julLogger.info(LogfileTestTailer.MARKER + " JULinfo");
julLogger.fine(LogfileTestTailer.MARKER + " JULfine");
julLogger.finer(LogfileTestTailer.MARKER + " JULfiner");
julLogger.finest(LogfileTestTailer.MARKER + " JULfinest");
tailer.tail();
tailer.assertMarkerLogged(LogfileTestTailer.LEVEL_ERROR, "JULsevere");
tailer.assertMarkerLogged(LogfileTestTailer.LEVEL_WARN, "JULwarning");
tailer.assertMarkerLogged(LogfileTestTailer.LEVEL_INFO, "JULinfo");
tailer.assertMarkerLogged(LogfileTestTailer.LEVEL_DEBUG, "JULfine");
tailer.assertMarkerLogged(LogfileTestTailer.LEVEL_DEBUG, "JULfiner");
tailer.assertMarkerLogged(LogfileTestTailer.LEVEL_TRACE, "JULfinest");
tailer.close();
}
Aggregations