use of com.evolveum.midpoint.provisioning.api.ResourceObjectShadowChangeDescription in project midpoint by Evolveum.
the class ReconciliationTaskHandler method reactShadowGone.
private void reactShadowGone(PrismObject<ShadowType> shadow, PrismObject<ResourceType> resource, Task task, OperationResult result) {
try {
provisioningService.applyDefinition(shadow, task, result);
ResourceObjectShadowChangeDescription change = new ResourceObjectShadowChangeDescription();
change.setSourceChannel(QNameUtil.qNameToUri(SchemaConstants.CHANGE_CHANNEL_RECON));
change.setResource(resource);
ObjectDelta<ShadowType> shadowDelta = ObjectDelta.createDeleteDelta(ShadowType.class, shadow.getOid(), shadow.getPrismContext());
change.setObjectDelta(shadowDelta);
// Need to also set current shadow. This will get reflected in "old" object in lens context
change.setCurrentShadow(shadow);
Utils.clearRequestee(task);
changeNotificationDispatcher.notifyChange(change, task, result);
} catch (SchemaException | ObjectNotFoundException | CommunicationException | ConfigurationException | ExpressionEvaluationException e) {
processShadowReconError(e, shadow, result);
}
}
use of com.evolveum.midpoint.provisioning.api.ResourceObjectShadowChangeDescription in project midpoint by Evolveum.
the class TestSynchronizationService method test051CalypsoRecon.
/**
* Calypso is protected, no reaction should be applied.
*/
@Test
public void test051CalypsoRecon() throws Exception {
final String TEST_NAME = "test051CalypsoRecon";
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);
// Lets make this a bit more interesting by setting up a fake situation in the shadow
ObjectDelta<ShadowType> objectDelta = createModifyAccountShadowReplaceDelta(accountShadowCalypsoDummyOid, getDummyResourceObject(), new ItemPath(ShadowType.F_SYNCHRONIZATION_SITUATION), SynchronizationSituationType.DISPUTED);
repositoryService.modifyObject(ShadowType.class, accountShadowCalypsoDummyOid, objectDelta.getModifications(), result);
PrismObject<ShadowType> accountShadowCalypso = getShadowModelNoFetch(accountShadowCalypsoDummyOid);
// Make sure that it is properly marked as protected. This is what provisioning would normally do
accountShadowCalypso.asObjectable().setProtectedObject(true);
ResourceObjectShadowChangeDescription change = new ResourceObjectShadowChangeDescription();
change.setCurrentShadow(accountShadowCalypso);
change.setResource(getDummyResourceObject());
display("Change notification", change);
// 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);
assertNull("Unexpected lens context", context);
PrismObject<UserType> userCalypso = findUserByUsername(ACCOUNT_CALYPSO_DUMMY_USERNAME);
assertNull("Unexpected user " + userCalypso, userCalypso);
PrismObject<ShadowType> shadow = getShadowModelNoFetch(accountShadowCalypsoDummyOid);
assertSituation(shadow, SynchronizationSituationType.DISPUTED);
result.computeStatus();
TestUtil.assertSuccess(result);
}
use of com.evolveum.midpoint.provisioning.api.ResourceObjectShadowChangeDescription in project midpoint by Evolveum.
the class TestSynchronizationService method test199DeletedAccountJackTotal.
/**
* Delete the account but also the shadow in the repo. The system should work well.
*/
@Test
public void test199DeletedAccountJackTotal() throws Exception {
final String TEST_NAME = "test199DeletedAccountJackTotal";
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);
getDummyResource().deleteAccountByName(ACCOUNT_JACK_DUMMY_USERNAME);
PrismObject<ShadowType> shadow = getShadowModelNoFetch(accountShadowJackDummyOid);
ResourceObjectShadowChangeDescription change = new ResourceObjectShadowChangeDescription();
change.setCurrentShadow(shadow);
change.setResource(getDummyResourceObject());
ObjectDelta<ShadowType> syncDelta = ObjectDelta.createDeleteDelta(ShadowType.class, accountShadowJackDummyOid, prismContext);
change.setObjectDelta(syncDelta);
repositoryService.deleteObject(ShadowType.class, accountShadowJackDummyOid, result);
// 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);
assertNotNull("No focus context", context.getFocusContext());
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);
PrismObject<UserType> userAfter = getUser(USER_JACK_OID);
assertLinks(userAfter, 0);
result.computeStatus();
display("Final result", result);
TestUtil.assertSuccess(result, 1);
assertNoObject(ShadowType.class, accountShadowJackDummyOid, task, result);
}
use of com.evolveum.midpoint.provisioning.api.ResourceObjectShadowChangeDescription in project midpoint by Evolveum.
the class TestSynchronizationService method test050AddedAccountCalypso.
/**
* Calypso is protected, no reaction should be applied.
*/
@Test
public void test050AddedAccountCalypso() throws Exception {
final String TEST_NAME = "test050AddedAccountCalypso";
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);
PrismObject<ShadowType> accountShadowCalypso = repoAddObjectFromFile(ACCOUNT_SHADOW_CALYPSO_DUMMY_FILE, result);
accountShadowCalypsoDummyOid = accountShadowCalypso.getOid();
provisioningService.applyDefinition(accountShadowCalypso, task, result);
assertNotNull("No oid in shadow", accountShadowCalypso.getOid());
// Make sure that it is properly marked as protected. This is what provisioning would normally do
accountShadowCalypso.asObjectable().setProtectedObject(true);
DummyAccount dummyAccount = new DummyAccount();
dummyAccount.setName(ACCOUNT_CALYPSO_DUMMY_USERNAME);
dummyAccount.setPassword("h1ghS3AS");
dummyAccount.setEnabled(true);
dummyAccount.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Calypso");
getDummyResource().addAccount(dummyAccount);
ResourceObjectShadowChangeDescription change = new ResourceObjectShadowChangeDescription();
change.setCurrentShadow(accountShadowCalypso);
change.setResource(getDummyResourceObject());
// WHEN
synchronizationService.notifyChange(change, task, result);
// THEN
LensContext<UserType> context = mockListener.getLastSyncContext();
display("Resulting context (as seen by debug listener)", context);
assertNull("Unexpected lens context", context);
PrismObject<UserType> userCalypso = findUserByUsername(ACCOUNT_CALYPSO_DUMMY_USERNAME);
assertNull("Unexpected user " + userCalypso, userCalypso);
PrismObject<ShadowType> shadow = getShadowModelNoFetch(accountShadowCalypsoDummyOid);
assertSituation(shadow, null);
result.computeStatus();
TestUtil.assertSuccess(result);
}
use of com.evolveum.midpoint.provisioning.api.ResourceObjectShadowChangeDescription in project midpoint by Evolveum.
the class TestSynchronizationService method test030Reconcile.
/**
* Sending empty delta, this is what reconciliation does.
*/
@Test
public void test030Reconcile() throws Exception {
final String TEST_NAME = "test030Reconcile";
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);
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_DISCOVERY_URI);
// 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());
assertSideEffectiveDeltasOnly("user secondary delta", context.getFocusContext().getSecondaryDelta());
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<ShadowType> shadow = getShadowModelNoFetch(accountShadowJackDummyOid);
assertIteration(shadow, 0, "");
assertSituation(shadow, SynchronizationSituationType.LINKED);
result.computeStatus();
TestUtil.assertSuccess(result);
}
Aggregations