use of com.evolveum.midpoint.xml.ns._public.common.common_3.TriggerType in project midpoint by Evolveum.
the class TestProjector method test254ModifyUserBarbossaDisable.
/**
* User barbossa has a direct account assignment. This assignment has an expression for enabledisable flag.
* Let's disable user, the account should be disabled as well.
*/
@Test
public void test254ModifyUserBarbossaDisable() throws Exception {
final String TEST_NAME = "test254ModifyUserBarbossaDisable";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestProjector.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL);
LensContext<UserType> context = createUserLensContext();
fillContextWithUser(context, USER_BARBOSSA_OID, result);
fillContextWithAccount(context, ACCOUNT_HBARBOSSA_DUMMY_OID, task, result);
addModificationToContextReplaceUserProperty(context, new ItemPath(UserType.F_ACTIVATION, ActivationType.F_ADMINISTRATIVE_STATUS), ActivationStatusType.DISABLED);
context.recompute();
display("Input context", context);
assertFocusModificationSanity(context);
// WHEN
projector.project(context, "test", task, result);
// THEN
display("Output context", context);
assertTrue(context.getFocusContext().getPrimaryDelta().getChangeType() == ChangeType.MODIFY);
assertSideEffectiveDeltasOnly(context.getFocusContext().getSecondaryDelta(), "user secondary delta", ActivationStatusType.DISABLED);
assertFalse("No account changes", context.getProjectionContexts().isEmpty());
Collection<LensProjectionContext> accountContexts = context.getProjectionContexts();
assertEquals(1, accountContexts.size());
LensProjectionContext accContext = accountContexts.iterator().next();
assertNull(accContext.getPrimaryDelta());
assertEquals(SynchronizationPolicyDecision.KEEP, accContext.getSynchronizationPolicyDecision());
ObjectDelta<ShadowType> accountSecondaryDelta = accContext.getSecondaryDelta();
assertNotNull("No account secondary delta", accountSecondaryDelta);
assertEquals(ChangeType.MODIFY, accountSecondaryDelta.getChangeType());
assertEquals("Unexpected number of account secondary changes", 6, accountSecondaryDelta.getModifications().size());
PropertyDelta<ActivationStatusType> enabledDelta = accountSecondaryDelta.findPropertyDelta(new ItemPath(ShadowType.F_ACTIVATION, ActivationType.F_ADMINISTRATIVE_STATUS));
PrismAsserts.assertReplace(enabledDelta, ActivationStatusType.DISABLED);
PrismAsserts.assertOrigin(enabledDelta, OriginType.OUTBOUND);
PrismAsserts.assertPropertyReplace(accountSecondaryDelta, SchemaConstants.PATH_ACTIVATION_DISABLE_REASON, SchemaConstants.MODEL_DISABLE_REASON_MAPPED);
ContainerDelta<TriggerType> triggerDelta = accountSecondaryDelta.findContainerDelta(ObjectType.F_TRIGGER);
assertNotNull("No trigger delta in account secondary delta", triggerDelta);
assertEquals("Wrong trigger delta size", 1, triggerDelta.getValuesToAdd().size());
TriggerType triggerType = triggerDelta.getValuesToAdd().iterator().next().asContainerable();
assertEquals("Wrong trigger URL", RecomputeTriggerHandler.HANDLER_URI, triggerType.getHandlerUri());
XMLGregorianCalendar start = clock.currentTimeXMLGregorianCalendar();
start.add(XmlTypeConverter.createDuration(true, 0, 0, 25, 0, 0, 0));
XMLGregorianCalendar end = clock.currentTimeXMLGregorianCalendar();
end.add(XmlTypeConverter.createDuration(true, 0, 0, 35, 0, 0, 0));
TestUtil.assertBetween("Wrong trigger timestamp", start, end, triggerType.getTimestamp());
}
Aggregations