Search in sources :

Example 11 with TriggerType

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());
}
Also used : TriggerType(com.evolveum.midpoint.xml.ns._public.common.common_3.TriggerType) Task(com.evolveum.midpoint.task.api.Task) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ActivationStatusType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Aggregations

TriggerType (com.evolveum.midpoint.xml.ns._public.common.common_3.TriggerType)9 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)6 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)5 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)3 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)2 Task (com.evolveum.midpoint.task.api.Task)2 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)2 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)2 Mapping (com.evolveum.midpoint.model.common.mapping.Mapping)1 ItemValueWithOrigin (com.evolveum.midpoint.model.impl.lens.ItemValueWithOrigin)1 ItemDefinition (com.evolveum.midpoint.prism.ItemDefinition)1 PrismContainerValue (com.evolveum.midpoint.prism.PrismContainerValue)1 DeltaSetTriple (com.evolveum.midpoint.prism.delta.DeltaSetTriple)1 ROExtPolyString (com.evolveum.midpoint.repo.sql.data.common.any.ROExtPolyString)1 ROExtString (com.evolveum.midpoint.repo.sql.data.common.any.ROExtString)1 ROperationExecution (com.evolveum.midpoint.repo.sql.data.common.container.ROperationExecution)1 RTrigger (com.evolveum.midpoint.repo.sql.data.common.container.RTrigger)1 RPolyString (com.evolveum.midpoint.repo.sql.data.common.embedded.RPolyString)1 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)1 ObjectAlreadyExistsException (com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)1