use of com.evolveum.midpoint.provisioning.api.ResourceObjectShadowChangeDescription in project midpoint by Evolveum.
the class TestSynchronizationService method test021ModifyLootAbsoluteEmpty.
@Test
public void test021ModifyLootAbsoluteEmpty() throws Exception {
final String TEST_NAME = "test021ModifyLootAbsoluteEmpty";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestSynchronizationService.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
MockLensDebugListener mockListener = new MockLensDebugListener();
clockwork.setDebugListener(mockListener);
DummyAccount dummyAccount = getDummyResource().getAccountByUsername(ACCOUNT_JACK_DUMMY_USERNAME);
dummyAccount.replaceAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOOT_NAME);
ResourceObjectShadowChangeDescription change = new ResourceObjectShadowChangeDescription();
PrismObject<ShadowType> accountShadowJack = provisioningService.getObject(ShadowType.class, accountShadowJackDummyOid, null, task, result);
change.setCurrentShadow(accountShadowJack);
change.setResource(getDummyResourceObject());
change.setSourceChannel(SchemaConstants.CHANGE_CHANNEL_LIVE_SYNC_URI);
display("SENDING CHANGE NOTIFICATION", change);
// WHEN
synchronizationService.notifyChange(change, task, result);
// THEN
LensContext<UserType> context = mockListener.getLastSyncContext();
display("Resulting context (as seen by debug listener)", context);
assertNotNull("No resulting context (as seen by debug listener)", context);
assertNull("Unexpected user primary delta", context.getFocusContext().getPrimaryDelta());
assertEquals("Unexpected number of executed deltas", 1, context.getFocusContext().getExecutedDeltas().size());
ObjectDelta<UserType> userSecondaryDelta = context.getFocusContext().getExecutedDeltas().iterator().next().getObjectDelta();
// ObjectDelta<UserType> userSecondaryDelta = context.getFocusContext().getSecondaryDelta();
assertNotNull("No user secondary delta", userSecondaryDelta);
assertEquals("Unexpected number of modifications in user secondary delta", 3, userSecondaryDelta.getModifications().size());
PrismAsserts.assertPropertyReplace(userSecondaryDelta, UserType.F_COST_CENTER);
ResourceShadowDiscriminator rat = new ResourceShadowDiscriminator(getDummyResourceObject().getOid(), ShadowKindType.ACCOUNT, null);
LensProjectionContext accCtx = context.findProjectionContext(rat);
assertNotNull("No account sync context for " + rat, accCtx);
PrismAsserts.assertNoDelta("Unexpected account primary delta", accCtx.getPrimaryDelta());
PrismAsserts.assertNoDelta("Unexpected account secondary delta", accCtx.getSecondaryDelta());
assertEquals("Wrong detected situation in context", SynchronizationSituationType.LINKED, accCtx.getSynchronizationSituationDetected());
assertLinked(context.getFocusContext().getObjectOld().getOid(), accountShadowJack.getOid());
PrismObject<UserType> user = getUser(USER_JACK_OID);
assertEquals("Unexpected used constCenter", null, user.asObjectable().getCostCenter());
PrismObject<ShadowType> shadow = getShadowModelNoFetch(accountShadowJackDummyOid);
assertIteration(shadow, 0, "");
assertSituation(shadow, SynchronizationSituationType.LINKED);
result.computeStatus();
TestUtil.assertSuccess(result);
}
use of com.evolveum.midpoint.provisioning.api.ResourceObjectShadowChangeDescription in project midpoint by Evolveum.
the class TestSynchronizationService method test020ModifyLootAbsolute.
@Test
public void test020ModifyLootAbsolute() throws Exception {
final String TEST_NAME = "test020ModifyLootAbsolute";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestSynchronizationService.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
MockLensDebugListener mockListener = new MockLensDebugListener();
clockwork.setDebugListener(mockListener);
DummyAccount dummyAccount = getDummyResource().getAccountByUsername(ACCOUNT_JACK_DUMMY_USERNAME);
dummyAccount.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOOT_NAME, "999");
ResourceObjectShadowChangeDescription change = new ResourceObjectShadowChangeDescription();
PrismObject<ShadowType> accountShadowJack = provisioningService.getObject(ShadowType.class, accountShadowJackDummyOid, null, task, result);
change.setCurrentShadow(accountShadowJack);
change.setResource(getDummyResourceObject());
change.setSourceChannel(SchemaConstants.CHANGE_CHANNEL_LIVE_SYNC_URI);
// WHEN
TestUtil.displayWhen(TEST_NAME);
synchronizationService.notifyChange(change, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
LensContext<UserType> context = mockListener.getLastSyncContext();
display("Resulting context (as seen by debug listener)", context);
assertNotNull("No resulting context (as seen by debug listener)", context);
assertNull("Unexpected user primary delta", context.getFocusContext().getPrimaryDelta());
assertEquals("Unexpected number of executed deltas", 1, context.getFocusContext().getExecutedDeltas().size());
ObjectDelta<UserType> userSecondaryDelta = context.getFocusContext().getExecutedDeltas().iterator().next().getObjectDelta();
assertNotNull("No user secondary delta", userSecondaryDelta);
assertEquals("Unexpected number of modifications in user secondary delta", 3, userSecondaryDelta.getModifications().size());
PrismAsserts.assertPropertyAdd(userSecondaryDelta, UserType.F_COST_CENTER, "999");
ResourceShadowDiscriminator rat = new ResourceShadowDiscriminator(getDummyResourceObject().getOid(), ShadowKindType.ACCOUNT, null);
LensProjectionContext accCtx = context.findProjectionContext(rat);
assertNotNull("No account sync context for " + rat, accCtx);
PrismAsserts.assertNoDelta("account primary delta", accCtx.getPrimaryDelta());
PrismAsserts.assertNoDelta("account secondary delta", accCtx.getSecondaryDelta());
assertEquals("Wrong detected situation in context", SynchronizationSituationType.LINKED, accCtx.getSynchronizationSituationDetected());
assertLinked(context.getFocusContext().getObjectOld().getOid(), accountShadowJack.getOid());
PrismObject<UserType> user = getUser(USER_JACK_OID);
assertEquals("Unexpected used constCenter", "999", user.asObjectable().getCostCenter());
PrismObject<ShadowType> shadow = getShadowModelNoFetch(accountShadowJackDummyOid);
assertIteration(shadow, 0, "");
assertSituation(shadow, SynchronizationSituationType.LINKED);
result.computeStatus();
TestUtil.assertSuccess(result);
}
use of com.evolveum.midpoint.provisioning.api.ResourceObjectShadowChangeDescription in project midpoint by Evolveum.
the class TestSynchronizationService method test039DeletedAccountJack.
@Test
public void test039DeletedAccountJack() throws Exception {
final String TEST_NAME = "test039DeletedAccountJack";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestSynchronizationService.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
PrismObject<ShadowType> shadowRepo = repositoryService.getObject(ShadowType.class, accountShadowJackDummyOid, null, result);
assertIteration(shadowRepo, 0, "");
assertSituation(shadowRepo, SynchronizationSituationType.LINKED);
MockLensDebugListener mockListener = new MockLensDebugListener();
clockwork.setDebugListener(mockListener);
getDummyResource().deleteAccountByName(ACCOUNT_JACK_DUMMY_USERNAME);
PrismObject<ShadowType> shadow = getShadowModelNoFetch(accountShadowJackDummyOid);
shadowRepo = repositoryService.getObject(ShadowType.class, accountShadowJackDummyOid, null, result);
assertIteration(shadowRepo, 0, "");
assertSituation(shadowRepo, SynchronizationSituationType.LINKED);
ResourceObjectShadowChangeDescription change = new ResourceObjectShadowChangeDescription();
change.setCurrentShadow(shadow);
change.setResource(getDummyResourceObject());
ObjectDelta<ShadowType> syncDelta = ObjectDelta.createDeleteDelta(ShadowType.class, accountShadowJackDummyOid, prismContext);
change.setObjectDelta(syncDelta);
// WHEN
TestUtil.displayWhen(TEST_NAME);
synchronizationService.notifyChange(change, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
LensContext<UserType> context = mockListener.getLastSyncContext();
display("Resulting context (as seen by debug listener)", context);
assertNotNull("No resulting context (as seen by debug listener)", context);
assertNull("Unexpected user primary delta", context.getFocusContext().getPrimaryDelta());
assertSideEffectiveDeltasOnly("user secondary delta", context.getFocusContext().getSecondaryDelta());
ResourceShadowDiscriminator rat = new ResourceShadowDiscriminator(getDummyResourceObject().getOid(), ShadowKindType.ACCOUNT, null, true);
LensProjectionContext accCtx = context.findProjectionContext(rat);
assertNotNull("No account sync context for " + rat, accCtx);
assertEquals("Wrong detected situation in context", SynchronizationSituationType.DELETED, accCtx.getSynchronizationSituationDetected());
PrismAsserts.assertNoDelta("Unexpected account primary delta", accCtx.getPrimaryDelta());
assertNotLinked(context.getFocusContext().getObjectOld().getOid(), accountShadowJackDummyOid);
shadowRepo = repositoryService.getObject(ShadowType.class, accountShadowJackDummyOid, null, result);
assertIteration(shadowRepo, 0, "");
assertSituation(shadowRepo, SynchronizationSituationType.DELETED);
result.computeStatus();
TestUtil.assertSuccess(result);
PrismObject<UserType> userAfter = getUser(USER_JACK_OID);
assertLinks(userAfter, 0);
repositoryService.deleteObject(ShadowType.class, accountShadowJackDummyOid, result);
}
use of com.evolveum.midpoint.provisioning.api.ResourceObjectShadowChangeDescription in project midpoint by Evolveum.
the class TestDummy method test890LiveSyncModifyProtectedAccount.
@Test
public void test890LiveSyncModifyProtectedAccount() throws Exception {
final String TEST_NAME = "test890LiveSyncModifyProtectedAccount";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
Task syncTask = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME);
OperationResult result = syncTask.getResult();
syncServiceMock.reset();
DummyAccount dummyAccount = getDummyAccountAssert(ACCOUNT_DAEMON_USERNAME, daemonIcfUid);
dummyAccount.replaceAttributeValue("fullname", "Maxwell deamon");
ResourceShadowDiscriminator coords = new ResourceShadowDiscriminator(RESOURCE_DUMMY_OID, ProvisioningTestUtil.getDefaultAccountObjectClass(resourceType));
// WHEN
TestUtil.displayWhen(TEST_NAME);
provisioningService.synchronize(coords, syncTokenTask, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
display("Synchronization result", result);
TestUtil.assertSuccess("Synchronization result is not OK", result);
ResourceObjectShadowChangeDescription lastChange = syncServiceMock.getLastChange();
display("The change", lastChange);
syncServiceMock.assertNoNotifyChange();
checkAllShadows();
assertSteadyResource();
}
use of com.evolveum.midpoint.provisioning.api.ResourceObjectShadowChangeDescription in project midpoint by Evolveum.
the class TestDummy method test802LiveSyncModifyBlackbeard.
@Test
public void test802LiveSyncModifyBlackbeard() throws Exception {
final String TEST_NAME = "test802LiveSyncModifyBlackbeard";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME);
syncServiceMock.reset();
DummyAccount dummyAccount = getDummyAccountAssert(BLACKBEARD_USERNAME, blackbeardIcfUid);
dummyAccount.replaceAttributeValue("fullname", "Captain Blackbeard");
display("Resource before sync", dummyResource.debugDump());
ResourceShadowDiscriminator coords = new ResourceShadowDiscriminator(RESOURCE_DUMMY_OID, ProvisioningTestUtil.getDefaultAccountObjectClass(resourceType));
// WHEN
TestUtil.displayWhen(TEST_NAME);
provisioningService.synchronize(coords, syncTokenTask, result);
// THEN
result.computeStatus();
display("Synchronization result", result);
TestUtil.assertSuccess("Synchronization result is not OK", result);
syncServiceMock.assertNotifyChange();
ResourceObjectShadowChangeDescription lastChange = syncServiceMock.getLastChange();
display("The change", lastChange);
PrismObject<? extends ShadowType> oldShadow = lastChange.getOldShadow();
assertSyncOldShadow(oldShadow, getBlackbeardRepoIcfName());
assertNull("Delta present when not expecting it", lastChange.getObjectDelta());
PrismObject<ShadowType> currentShadow = lastChange.getCurrentShadow();
assertNotNull("Current shadow missing", lastChange.getCurrentShadow());
assertTrue("Wrong type of current shadow: " + currentShadow.getClass().getName(), currentShadow.canRepresent(ShadowType.class));
ResourceAttributeContainer attributesContainer = ShadowUtil.getAttributesContainer(currentShadow);
assertNotNull("No attributes container in current shadow", attributesContainer);
Collection<ResourceAttribute<?>> attributes = attributesContainer.getAttributes();
assertFalse("Attributes container is empty", attributes.isEmpty());
assertAttribute(currentShadow, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Captain Blackbeard");
assertAttribute(currentShadow, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOOT_NAME, 66666L);
assertEquals("Unexpected number of attributes", 4, attributes.size());
PrismObject<ShadowType> accountRepo = findAccountShadowByUsername(getBlackbeardRepoIcfName(), resource, result);
assertNotNull("Shadow was not created in the repository", accountRepo);
display("Repository shadow", accountRepo);
checkRepoAccountShadow(accountRepo);
checkAllShadows();
assertSteadyResource();
}
Aggregations