@Test public void test053ModifyUserBarbossaDisable() throws Exception { final String TEST_NAME = "test053ModifyUserBarbossaDisable"; displayTestTile(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); 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); displayWhen(TEST_NAME); clockwork.run(context, task, result); displayThen(TEST_NAME); 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(); assertEquals(ChangeType.MODIFY, accountSecondaryDelta.getChangeType()); assertEquals("Unexpected number of account secondary changes", 4, accountSecondaryDelta.getModifications().size()); PrismAsserts.assertPropertyReplace(accountSecondaryDelta, new ItemPath(ShadowType.F_ACTIVATION, ActivationType.F_ADMINISTRATIVE_STATUS), ActivationStatusType.DISABLED); 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()); }
public <F extends ObjectType> HookOperationMode run(LensContext<F> context, Task task, OperationResult result) throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { LOGGER.trace("Running clockwork for context {}", context); if (InternalsConfig.consistencyChecks) { context.checkConsistence(); } int clicked = 0; boolean focusConflictPresent = false; HookOperationMode finalMode; try { context.reportProgress(new ProgressInformation(CLOCKWORK, ENTERING)); if (context.getFocusContext() != null && context.getFocusContext().getOid() != null) { context.createAndRegisterConflictWatcher(context.getFocusContext().getOid(), repositoryService); } FocusConstraintsChecker.enterCache(); enterAssociationSearchExpressionEvaluatorCache(); provisioningService.enterConstraintsCheckerCache(); while (context.getState() != ModelState.FINAL) { int maxClicks = getMaxClicks(context, result); if (clicked >= maxClicks) { throw new IllegalStateException("Model operation took too many clicks (limit is " + maxClicks + "). Is there a cycle?"); } clicked++; HookOperationMode mode = click(context, task, result); if (mode == HookOperationMode.BACKGROUND) { result.recordInProgress(); return mode; } else if (mode == HookOperationMode.ERROR) { return mode; } } finalMode = click(context, task, result); if (finalMode == HookOperationMode.FOREGROUND) { focusConflictPresent = checkFocusConflicts(context, task, result); } } finally { context.unregisterConflictWatchers(repositoryService); FocusConstraintsChecker.exitCache(); exitAssociationSearchExpressionEvaluatorCache(); provisioningService.exitConstraintsCheckerCache(); context.reportProgress(new ProgressInformation(CLOCKWORK, EXITING)); } if (focusConflictPresent) { assert finalMode == HookOperationMode.FOREGROUND; finalMode = resolveFocusConflict(context, task, result); } else if (context.getConflictResolutionAttemptNumber() > 0) { LOGGER.info("Resolved update conflict on attempt number {}", context.getConflictResolutionAttemptNumber()); } return finalMode; }
Clockwork { public <F extends ObjectType> HookOperationMode run(LensContext<F> context, Task task, OperationResult result) throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { LOGGER.trace("Running clockwork for context {}", context); if (InternalsConfig.consistencyChecks) { context.checkConsistence(); } int clicked = 0; boolean focusConflictPresent = false; HookOperationMode finalMode; try { context.reportProgress(new ProgressInformation(CLOCKWORK, ENTERING)); if (context.getFocusContext() != null && context.getFocusContext().getOid() != null) { context.createAndRegisterConflictWatcher(context.getFocusContext().getOid(), repositoryService); } FocusConstraintsChecker.enterCache(); enterAssociationSearchExpressionEvaluatorCache(); provisioningService.enterConstraintsCheckerCache(); while (context.getState() != ModelState.FINAL) { int maxClicks = getMaxClicks(context, result); if (clicked >= maxClicks) { throw new IllegalStateException("Model operation took too many clicks (limit is " + maxClicks + "). Is there a cycle?"); } clicked++; HookOperationMode mode = click(context, task, result); if (mode == HookOperationMode.BACKGROUND) { result.recordInProgress(); return mode; } else if (mode == HookOperationMode.ERROR) { return mode; } } finalMode = click(context, task, result); if (finalMode == HookOperationMode.FOREGROUND) { focusConflictPresent = checkFocusConflicts(context, task, result); } } finally { context.unregisterConflictWatchers(repositoryService); FocusConstraintsChecker.exitCache(); exitAssociationSearchExpressionEvaluatorCache(); provisioningService.exitConstraintsCheckerCache(); context.reportProgress(new ProgressInformation(CLOCKWORK, EXITING)); } if (focusConflictPresent) { assert finalMode == HookOperationMode.FOREGROUND; finalMode = resolveFocusConflict(context, task, result); } else if (context.getConflictResolutionAttemptNumber() > 0) { LOGGER.info("Resolved update conflict on attempt number {}", context.getConflictResolutionAttemptNumber()); } return finalMode; } }
Clockwork { public <F extends ObjectType> HookOperationMode run(LensContext<F> context, Task task, OperationResult result) throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { LOGGER.trace("Running clockwork for context {}", context); if (InternalsConfig.consistencyChecks) { context.checkConsistence(); } int clicked = 0; boolean focusConflictPresent = false; HookOperationMode finalMode; try { context.reportProgress(new ProgressInformation(CLOCKWORK, ENTERING)); if (context.getFocusContext() != null && context.getFocusContext().getOid() != null) { context.createAndRegisterConflictWatcher(context.getFocusContext().getOid(), repositoryService); } FocusConstraintsChecker.enterCache(); enterAssociationSearchExpressionEvaluatorCache(); provisioningService.enterConstraintsCheckerCache(); while (context.getState() != ModelState.FINAL) { int maxClicks = getMaxClicks(context, result); if (clicked >= maxClicks) { throw new IllegalStateException("Model operation took too many clicks (limit is " + maxClicks + "). Is there a cycle?"); } clicked++; HookOperationMode mode = click(context, task, result); if (mode == HookOperationMode.BACKGROUND) { result.recordInProgress(); return mode; } else if (mode == HookOperationMode.ERROR) { return mode; } } finalMode = click(context, task, result); if (finalMode == HookOperationMode.FOREGROUND) { focusConflictPresent = checkFocusConflicts(context, task, result); } } finally { context.unregisterConflictWatchers(repositoryService); FocusConstraintsChecker.exitCache(); exitAssociationSearchExpressionEvaluatorCache(); provisioningService.exitConstraintsCheckerCache(); context.reportProgress(new ProgressInformation(CLOCKWORK, EXITING)); } if (focusConflictPresent) { assert finalMode == HookOperationMode.FOREGROUND; finalMode = resolveFocusConflict(context, task, result); } else if (context.getConflictResolutionAttemptNumber() > 0) { LOGGER.info("Resolved update conflict on attempt number {}", context.getConflictResolutionAttemptNumber()); } return finalMode; }  }
Clockwork { public <F extends ObjectType> HookOperationMode run(LensContext<F> context, Task task, OperationResult result) throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { LOGGER.trace("Running clockwork for context {}", context); if (InternalsConfig.consistencyChecks) { context.checkConsistence(); } int clicked = 0; boolean focusConflictPresent = false; HookOperationMode finalMode; try { context.reportProgress(new ProgressInformation(CLOCKWORK, ENTERING)); if (context.getFocusContext() != null && context.getFocusContext().getOid() != null) { context.createAndRegisterConflictWatcher(context.getFocusContext().getOid(), repositoryService); } FocusConstraintsChecker.enterCache(); enterAssociationSearchExpressionEvaluatorCache(); provisioningService.enterConstraintsCheckerCache(); while (context.getState() != ModelState.FINAL) { int maxClicks = getMaxClicks(context, result); if (clicked >= maxClicks) { throw new IllegalStateException("Model operation took too many clicks (limit is " + maxClicks + "). Is there a cycle?"); } clicked++; HookOperationMode mode = click(context, task, result); if (mode == HookOperationMode.BACKGROUND) { result.recordInProgress(); return mode; } else if (mode == HookOperationMode.ERROR) { return mode; } } finalMode = click(context, task, result); if (finalMode == HookOperationMode.FOREGROUND) { focusConflictPresent = checkFocusConflicts(context, task, result); } } finally { context.unregisterConflictWatchers(repositoryService); FocusConstraintsChecker.exitCache(); exitAssociationSearchExpressionEvaluatorCache(); provisioningService.exitConstraintsCheckerCache(); context.reportProgress(new ProgressInformation(CLOCKWORK, EXITING)); } if (focusConflictPresent) { assert finalMode == HookOperationMode.FOREGROUND; finalMode = resolveFocusConflict(context, task, result); } else if (context.getConflictResolutionAttemptNumber() > 0) { LOGGER.info("Resolved update conflict on attempt number {}", context.getConflictResolutionAttemptNumber()); } return finalMode; }  LensDebugListener getDebugListener(); void setDebugListener(LensDebugListener debugListener); HookOperationMode run(LensContext<F> context, Task task, OperationResult result); HookOperationMode click(LensContext<F> context, Task task, OperationResult result); static void throwException(Throwable e); }
Clockwork { public <F extends ObjectType> HookOperationMode run(LensContext<F> context, Task task, OperationResult result) throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { LOGGER.trace("Running clockwork for context {}", context); if (InternalsConfig.consistencyChecks) { context.checkConsistence(); } int clicked = 0; boolean focusConflictPresent = false; HookOperationMode finalMode; try { context.reportProgress(new ProgressInformation(CLOCKWORK, ENTERING)); if (context.getFocusContext() != null && context.getFocusContext().getOid() != null) { context.createAndRegisterConflictWatcher(context.getFocusContext().getOid(), repositoryService); } FocusConstraintsChecker.enterCache(); enterAssociationSearchExpressionEvaluatorCache(); provisioningService.enterConstraintsCheckerCache(); while (context.getState() != ModelState.FINAL) { int maxClicks = getMaxClicks(context, result); if (clicked >= maxClicks) { throw new IllegalStateException("Model operation took too many clicks (limit is " + maxClicks + "). Is there a cycle?"); } clicked++; HookOperationMode mode = click(context, task, result); if (mode == HookOperationMode.BACKGROUND) { result.recordInProgress(); return mode; } else if (mode == HookOperationMode.ERROR) { return mode; } } finalMode = click(context, task, result); if (finalMode == HookOperationMode.FOREGROUND) { focusConflictPresent = checkFocusConflicts(context, task, result); } } finally { context.unregisterConflictWatchers(repositoryService); FocusConstraintsChecker.exitCache(); exitAssociationSearchExpressionEvaluatorCache(); provisioningService.exitConstraintsCheckerCache(); context.reportProgress(new ProgressInformation(CLOCKWORK, EXITING)); } if (focusConflictPresent) { assert finalMode == HookOperationMode.FOREGROUND; finalMode = resolveFocusConflict(context, task, result); } else if (context.getConflictResolutionAttemptNumber() > 0) { LOGGER.info("Resolved update conflict on attempt number {}", context.getConflictResolutionAttemptNumber()); } return finalMode; }  LensDebugListener getDebugListener(); void setDebugListener(LensDebugListener debugListener); HookOperationMode run(LensContext<F> context, Task task, OperationResult result); HookOperationMode click(LensContext<F> context, Task task, OperationResult result); static void throwException(Throwable e);  }