From e3b79c0ba6518e7dfa3ba969d4ff46c116bddf80 Mon Sep 17 00:00:00 2001 From: Radovan Semancik Date: Fri, 29 Sep 2017 00:01:08 +0200 Subject: [PATCH] More parallelism improvements, bugfixies and test improvements (MID-4154) ... but still work in progress --- .../xml/ns/public/common/common-core-3.xsd | 14 + .../midpoint/schema/util/SchemaTestUtil.java | 2 +- .../impl/controller/ModelController.java | 45 +- .../ModelInteractionServiceImpl.java | 10 + .../controller/ModelOperationTaskHandler.java | 3 +- .../model/impl/lens/ChangeExecutor.java | 70 ++- .../midpoint/model/impl/lens/Clockwork.java | 98 ++-- .../midpoint/model/impl/lens/LensContext.java | 18 + .../model/impl/lens/LensElementContext.java | 9 +- .../midpoint/model/impl/lens/LensUtil.java | 7 +- .../model/impl/lens/PersonaProcessor.java | 24 +- .../impl/lens/ProjectorComponentRunnable.java | 3 +- .../lens/projector/ActivationProcessor.java | 17 +- .../impl/lens/projector/ContextLoader.java | 2 +- .../impl/lens/projector/FocusProcessor.java | 13 +- .../impl/lens/projector/MappingEvaluator.java | 4 +- .../projector/ProjectionMappingLoader.java | 15 +- .../projector/ProjectionValuesProcessor.java | 2 + .../model/impl/lens/projector/Projector.java | 19 +- .../sync/FocusValidityScannerTaskHandler.java | 5 +- .../model/impl/sync/RecomputeTaskHandler.java | 5 +- .../impl/sync/SynchronizationServiceImpl.java | 3 +- .../impl/trigger/RecomputeTriggerHandler.java | 18 +- .../AbstractSearchIterativeResultHandler.java | 7 +- .../model/impl/lens/TestClockwork.java | 3 +- .../midpoint/model/intest/TestActivation.java | 13 +- .../midpoint/model/intest/TestAudit.java | 135 +++--- .../midpoint/model/intest/TestDeputy.java | 230 +++++---- .../midpoint/model/intest/TestIntent.java | 23 +- .../midpoint/model/intest/TestMapping.java | 20 +- .../intest/TestModelServiceContract.java | 45 +- .../model/intest/TestMultiResource.java | 442 +++++++++--------- .../model/intest/TestUserTemplate.java | 4 +- .../src/test/resources/logback-test.xml | 8 +- .../mapping/resource-dummy-crimson.xml | 4 +- .../mapping/resource-dummy-light-crimson.xml | 4 +- .../provisioning/impl/ShadowManager.java | 2 +- .../manual/AbstractManualResourceTest.java | 16 +- 38 files changed, 712 insertions(+), 650 deletions(-) diff --git a/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd b/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd index 11254bad103..9c422b482e1 100644 --- a/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd +++ b/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd @@ -11880,6 +11880,18 @@ + + + + Operation should be end with an error. + This is a recoverable error (precondition failed). + TODO: align with "fail" + + + + + + @@ -11915,6 +11927,8 @@ The whole operation should fail. This is to be used mainly for testing purposes, to check if conflict detection algorithm does not yield false positive results. + This fails with a system error. This is a definitive, non-recoverable fauilure. + TODO: align with "error" diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/util/SchemaTestUtil.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/util/SchemaTestUtil.java index 5b108c5c15e..c7589a1e1d5 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/util/SchemaTestUtil.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/util/SchemaTestUtil.java @@ -101,7 +101,7 @@ public static void assertFocusDefinition(ComplexTypeDefinition complexTypeDefini assertFalse("Metadata is runtime", metadataContainer.isRuntimeSchema()); assertFalse("Metadata is dynamic", metadataContainer.isDynamic()); assertTrue("Metadata is NOT operational", metadataContainer.isOperational()); - assertEquals("Metadata size", 12, metadataContainer.getDefinitions().size()); + assertEquals("Metadata size", 13, metadataContainer.getDefinitions().size()); PrismReferenceDefinition tenantRefDef = complexTypeDefinition.findItemDefinition(UserType.F_TENANT_REF, PrismReferenceDefinition.class); PrismAsserts.assertDefinition(tenantRefDef, UserType.F_TENANT_REF, ObjectReferenceType.COMPLEX_TYPE, 0, 1); diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/ModelController.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/ModelController.java index a886c39bbc5..c76cb0ec510 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/ModelController.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/ModelController.java @@ -47,6 +47,7 @@ import com.evolveum.midpoint.prism.util.CloneUtil; import com.evolveum.midpoint.provisioning.api.ProvisioningOperationOptions; import com.evolveum.midpoint.provisioning.api.ProvisioningService; +import com.evolveum.midpoint.repo.api.PreconditionViolationException; import com.evolveum.midpoint.repo.api.RepoAddOptions; import com.evolveum.midpoint.repo.api.RepositoryService; import com.evolveum.midpoint.repo.cache.RepositoryCache; @@ -604,6 +605,15 @@ public Collection> executeChanges(fin CommunicationException|ConfigurationException|PolicyViolationException|SecurityViolationException|RuntimeException e) { ModelUtils.recordFatalError(result, e); throw e; + + } catch (PreconditionViolationException e) { + ModelUtils.recordFatalError(result, e); + // TODO: Temporary fix for 3.6.1 + // We do not want to propagate PreconditionViolationException to model API as that might break compatiblity + // ... and we do not really need that in 3.6.1 + // TODO: expose PreconditionViolationException in 3.7 + throw new SystemException(e); + } finally { task.markObjectActionExecutedBoundary(); } @@ -720,33 +730,20 @@ public void recompute(Class type, String oid, ModelExe result.cleanupResult(); - } catch (ExpressionEvaluationException e) { - ModelUtils.recordFatalError(result, e); - throw e; - } catch (SchemaException e) { - ModelUtils.recordFatalError(result, e); - throw e; - } catch (PolicyViolationException e) { - ModelUtils.recordFatalError(result, e); - throw e; - } catch (ObjectNotFoundException e) { + } catch (ExpressionEvaluationException | SchemaException | PolicyViolationException | ObjectNotFoundException | + ObjectAlreadyExistsException | CommunicationException | ConfigurationException | SecurityViolationException | + RuntimeException | Error e) { ModelUtils.recordFatalError(result, e); throw e; - } catch (ObjectAlreadyExistsException e) { + + } catch (PreconditionViolationException e) { ModelUtils.recordFatalError(result, e); - throw e; - } catch (CommunicationException e) { - ModelUtils.recordFatalError(result, e); - throw e; - } catch (ConfigurationException e) { - ModelUtils.recordFatalError(result, e); - throw e; - } catch (SecurityViolationException e) { - ModelUtils.recordFatalError(result, e); - throw e; - } catch (RuntimeException e) { - ModelUtils.recordFatalError(result, e); - throw e; + // TODO: Temporary fix for 3.6.1 + // We do not want to propagate PreconditionViolationException to model API as that might break compatiblity + // ... and we do not really need that in 3.6.1 + // TODO: expose PreconditionViolationException in 3.7 + throw new SystemException(e); + } finally { RepositoryCache.exit(); } diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/ModelInteractionServiceImpl.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/ModelInteractionServiceImpl.java index 8f90e6d3580..d9613f16c32 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/ModelInteractionServiceImpl.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/ModelInteractionServiceImpl.java @@ -87,6 +87,7 @@ import com.evolveum.midpoint.prism.query.RefFilter; import com.evolveum.midpoint.prism.query.TypeFilter; import com.evolveum.midpoint.provisioning.api.ProvisioningService; +import com.evolveum.midpoint.repo.api.PreconditionViolationException; import com.evolveum.midpoint.repo.api.RepositoryService; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.result.OperationResultStatus; @@ -195,6 +196,15 @@ public ModelContext previewChanges( ExpressionEvaluationException e) { ModelUtils.recordFatalError(result, e); throw e; + + } catch (PreconditionViolationException e) { + ModelUtils.recordFatalError(result, e); + // TODO: Temporary fix for 3.6.1 + // We do not want to propagate PreconditionViolationException to model API as that might break compatiblity + // ... and we do not really need that in 3.6.1 + // TODO: expose PreconditionViolationException in 3.7 + throw new SystemException(e); + } finally { RepositoryCache.exit(); } diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/ModelOperationTaskHandler.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/ModelOperationTaskHandler.java index 5a3c795beb6..7fb45b0d3a6 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/ModelOperationTaskHandler.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/ModelOperationTaskHandler.java @@ -23,6 +23,7 @@ import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.prism.delta.ObjectDelta; import com.evolveum.midpoint.provisioning.api.ProvisioningService; +import com.evolveum.midpoint.repo.api.PreconditionViolationException; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.task.api.TaskCategory; @@ -122,7 +123,7 @@ public TaskRunResult run(Task task) { result.computeStatus(); } runResult.setRunResultStatus(TaskRunResult.TaskRunResultStatus.FINISHED); - } catch (RuntimeException|CommonException e) { + } catch (CommonException | PreconditionViolationException | RuntimeException | Error e) { String message = "An exception occurred within model operation, in task " + task; LoggingUtils.logUnexpectedException(LOGGER, message, e); result.recordPartialError(message, e); diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/ChangeExecutor.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/ChangeExecutor.java index 733c26d5c0d..b6898e4ceb0 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/ChangeExecutor.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/ChangeExecutor.java @@ -181,7 +181,13 @@ public boolean executeChanges(LensContext context, Tas policySituationUpdater.storeFocusPolicySituation(context); } - if (focusDelta != null) { + if (focusDelta == null && !context.hasProjectionChange()) { + LOGGER.trace("Skipping focus change execute, because user delta is null"); + } else { + + if (focusDelta == null) { + focusDelta = focusContext.getObjectAny().createModifyDelta(); + } ObjectPolicyConfigurationType objectPolicyConfigurationType = focusContext .getObjectPolicyConfigurationType(); @@ -221,6 +227,9 @@ public boolean executeChanges(LensContext context, Tas } catch (PreconditionViolationException e) { + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Modification precondition failed for {}: {}", focusContext.getHumanReadableName(), e.getMessage()); + } // TODO: fatal error if the conflict resolution is "error" (later) result.recordHandledError(e); throw e; @@ -235,8 +244,6 @@ public boolean executeChanges(LensContext context, Tas } finally { context.reportProgress(new ProgressInformation(FOCUS_OPERATION, subResult)); } - } else { - LOGGER.trace("Skipping focus change execute, because user delta is null"); } } @@ -254,7 +261,7 @@ public boolean executeChanges(LensContext context, Tas if (!projCtx.isCanProject()) { continue; } - + // we should not get here, but just to be sure if (projCtx.getSynchronizationPolicyDecision() == SynchronizationPolicyDecision.IGNORE) { LOGGER.trace("Skipping ignored projection context {}", projCtx.toHumanReadableString()); @@ -318,7 +325,7 @@ public boolean executeChanges(LensContext context, Tas subResult.computeStatus(); subResult.recordNotApplicableIfUnknown(); continue; - + } else if (projDelta.isDelete() && projCtx.getResourceShadowDiscriminator() != null && projCtx.getResourceShadowDiscriminator().getOrder() > 0) { // HACK ... for higher-order context check if this was @@ -377,26 +384,12 @@ public boolean executeChanges(LensContext context, Tas restartRequested = true; break; // we will process remaining projections when retrying // the wave - } catch (CommunicationException e) { - recordProjectionExecutionException(e, projCtx, subResult, - SynchronizationPolicyDecision.BROKEN); - continue; - } catch (ConfigurationException e) { - recordProjectionExecutionException(e, projCtx, subResult, - SynchronizationPolicyDecision.BROKEN); - continue; - } catch (SecurityViolationException e) { - recordProjectionExecutionException(e, projCtx, subResult, - SynchronizationPolicyDecision.BROKEN); - continue; - } catch (ExpressionEvaluationException e) { - recordProjectionExecutionException(e, projCtx, subResult, - SynchronizationPolicyDecision.BROKEN); - continue; - } catch (RuntimeException e) { + + } catch (CommunicationException | ConfigurationException | SecurityViolationException | ExpressionEvaluationException | RuntimeException | Error e) { recordProjectionExecutionException(e, projCtx, subResult, SynchronizationPolicyDecision.BROKEN); continue; + } finally { context.reportProgress(new ProgressInformation(RESOURCE_OBJECT_OPERATION, projCtx.getResourceShadowDiscriminator(), subResult)); @@ -410,18 +403,7 @@ public boolean executeChanges(LensContext context, Tas } private void applyLastProvisioningTimestamp(LensContext context, ObjectDelta focusDelta) throws SchemaException { - Collection projectionContexts = context.getProjectionContexts(); - if (projectionContexts == null) { - return; - } - boolean hasProjectionChange = false; - for (LensProjectionContext projectionContext: projectionContexts) { - if (projectionContext.hasPrimaryDelta() || projectionContext.hasSecondaryDelta()) { - hasProjectionChange = true; - break; - } - } - if (!hasProjectionChange) { + if (!context.hasProjectionChange()) { return; } if (focusDelta.isAdd()) { @@ -520,7 +502,7 @@ private void applyObjectPolicy(LensFocusContext focusC } } - private

void recordProjectionExecutionException(Exception e, + private

void recordProjectionExecutionException(Throwable e, LensProjectionContext accCtx, OperationResult subResult, SynchronizationPolicyDecision decision) { subResult.recordFatalError(e); LOGGER.error("Error executing changes for {}: {}", @@ -584,7 +566,7 @@ private void updateLinks( // Already linked, nothing to do, only be sure, the // situation is set with the good value LOGGER.trace("Updating situation in already linked shadow."); - updateSituationInShadow(task, SynchronizationSituationType.LINKED, focusObjectContext, + updateSituationInShadow(task, SynchronizationSituationType.LINKED, null, focusObjectContext, projCtx, result); return; } @@ -594,7 +576,7 @@ private void updateLinks( linkShadow(focusContext.getOid(), projOid, focusObjectContext, projCtx, task, result); // be sure, that the situation is set correctly LOGGER.trace("Updating situation after shadow was linked."); - updateSituationInShadow(task, SynchronizationSituationType.LINKED, focusObjectContext, projCtx, + updateSituationInShadow(task, SynchronizationSituationType.LINKED, null, focusObjectContext, projCtx, result); } else { // Link should NOT exist @@ -621,7 +603,7 @@ private void updateLinks( LOGGER.trace("Resource object {} deleted, updating also situation in shadow.", projOid); // HACK HACK? try { - updateSituationInShadow(task, SynchronizationSituationType.DELETED, focusObjectContext, + updateSituationInShadow(task, SynchronizationSituationType.DELETED, true, focusObjectContext, projCtx, result); } catch (ObjectNotFoundException e) { // HACK HACK? @@ -635,7 +617,7 @@ private void updateLinks( // situation here. Reflect that in the shadow. LOGGER.trace("Resource object {} unlinked from the user, updating also situation in shadow.", projOid); - updateSituationInShadow(task, null, focusObjectContext, projCtx, result); + updateSituationInShadow(task, null, null, focusObjectContext, projCtx, result); } // Not linked, that's OK } @@ -760,7 +742,7 @@ private void unlinkShadow(String focusOid, PrismReference } private void updateSituationInShadow(Task task, - SynchronizationSituationType situation, LensFocusContext focusContext, + SynchronizationSituationType situation, Boolean dead, LensFocusContext focusContext, LensProjectionContext projectionCtx, OperationResult parentResult) throws ObjectNotFoundException, SchemaException { @@ -783,6 +765,11 @@ private void updateSituationInShadow(Task task, List> syncSituationDeltas = SynchronizationUtils .createSynchronizationSituationAndDescriptionDelta(account, situation, task.getChannel(), projectionCtx.hasFullShadow()); + + if (dead != null) { + PropertyDelta deadDelta = PropertyDelta.createModificationReplaceProperty(ShadowType.F_DEAD, account.getDefinition(), dead); + syncSituationDeltas.add(deadDelta); + } try { Utils.setRequestee(task, focusContext); @@ -1337,7 +1324,8 @@ private void executeModification(Ob if (conflictResolution != null) { String readVersion = objectContext.getObjectReadVersion(); if (readVersion != null) { - precondition = new VersionPrecondition<>(readVersion); + LOGGER.trace("Modification with precondition, readVersion={}", readVersion); + precondition = new VersionPrecondition<>(readVersion); } else { LOGGER.warn("Requested careful modification of {}, but there is no read version", objectContext.getHumanReadableName()); } diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/Clockwork.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/Clockwork.java index b873986cba0..33d5e75a273 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/Clockwork.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/Clockwork.java @@ -122,6 +122,7 @@ public class Clockwork { private static final int DEFAULT_MAX_CONFLICT_RESOLUTION_ATTEMPTS = 1; // synchronize with common-core-3.xsd private static final int DEFAULT_CONFLICT_RESOLUTION_DELAY_UNIT = 5000; // synchronize with common-core-3.xsd + private static final int MAX_PRECONDITION_CONFLICT_RESOLUTION_ATTEMPTS = 3; private static final Trace LOGGER = TraceManager.getTrace(Clockwork.class); @@ -163,7 +164,9 @@ public void setDebugListener(LensDebugListener debugListener) { private static final int DEFAULT_MAX_CLICKS = 200; - public HookOperationMode run(LensContext context, Task task, OperationResult result) throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { + public HookOperationMode run(LensContext context, Task task, OperationResult result) + throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, + ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException, PreconditionViolationException { LOGGER.trace("Running clockwork for context {}", context); if (InternalsConfig.consistencyChecks) { context.checkConsistence(); @@ -257,7 +260,7 @@ private HookOperationMode resolveFocusConflict(LensContex } // so, recompute is the action - LOGGER.debug("Conflict detected while updating {}, recomputing (options={})", focusObject, options); + LOGGER.debug("CONFLICT: Conflict detected while updating {}, recomputing (options={})", focusObject, options); if (context.getFocusContext() == null) { LOGGER.warn("No focus context, not possible to resolve conflict by focus recomputation"); // should really never occur @@ -282,37 +285,69 @@ private HookOperationMode resolveFocusConflict(LensContex } ConflictResolutionType focusConflictResolution = new ConflictResolutionType(); - focusConflictResolution.setAction(ConflictResolutionActionType.RESTART); + focusConflictResolution.setAction(ConflictResolutionActionType.ERROR); options.setFocusConflictResolution(focusConflictResolution); - PrismObject focus = repositoryService.getObject(focusClass, oid, null, result); - LensContext contextNew = contextFactory.createRecomputeContext(focus, options, task, result); - contextNew.setProgressListeners(new ArrayList<>(emptyIfNull(context.getProgressListeners()))); - int attemptOld = context.getConflictResolutionAttemptNumber(); - int attemptNew = attemptOld + 1; - boolean shouldExecuteAttempt = shouldExecuteAttempt(resolutionPolicy, attemptNew, context); - if (shouldExecuteAttempt) { + int preconditionAttempts = 0; + while (true) { + + PrismObject focus = repositoryService.getObject(focusClass, oid, null, result); + LensContext contextNew = contextFactory.createRecomputeContext(focus, options, task, result); + contextNew.setProgressListeners(new ArrayList<>(emptyIfNull(context.getProgressListeners()))); + + int attemptOld = context.getConflictResolutionAttemptNumber(); + int attemptNew = attemptOld + 1; + boolean shouldExecuteAttempt = shouldExecuteAttempt(context, resolutionPolicy, attemptNew); + if (!shouldExecuteAttempt) { + LOGGER.warn("CONFLICT: Couldn't resolve conflict even after {} resolution attempt(s), giving up.", attemptOld); + return HookOperationMode.FOREGROUND; + } contextNew.setConflictResolutionAttemptNumber(attemptNew); // this is a recursion; but limited to max attempts which should not be a large number - return run(contextNew, task, result); - } else { - LOGGER.warn("Couldn't resolve conflict even after {} resolution attempt(s), giving up.", attemptOld); - return HookOperationMode.FOREGROUND; + + delay(context, resolutionPolicy, attemptNew + preconditionAttempts); + + LOGGER.debug("CONFLICT: Recomputing {} as reaction to conflict (options={}, attempts={},{})", + context.getFocusContext().getHumanReadableName(), attemptNew, preconditionAttempts); + + try { + + HookOperationMode hookOperationMode = run(contextNew, task, result); + + // This may be in fact a giveup after recompute that was not able to cleanly proceed. + LOGGER.debug("CONFLICT: Clean recompute (or giveup) of {} achieved (options={}, attempts={},{})", + context.getFocusContext().getHumanReadableName(), options, attemptNew, preconditionAttempts); + + return hookOperationMode; + + } catch (PreconditionViolationException e) { + preconditionAttempts++; + LOGGER.debug("CONFLICT: Recompute precondition failed (attempt {}, precondition attempt {}), trying again", attemptNew, preconditionAttempts); + if (preconditionAttempts < MAX_PRECONDITION_CONFLICT_RESOLUTION_ATTEMPTS) { + continue; + } + LOGGER.warn("CONFLICT: Couldn't resolve conflict even after {} resolution attempt(s) and {} precondition attempts, giving up.", + attemptOld, preconditionAttempts); + return HookOperationMode.FOREGROUND; + } } } - private boolean shouldExecuteAttempt(@NotNull ConflictResolutionType resolutionPolicy, int attemptNew, - LensContext context) { + private boolean shouldExecuteAttempt(LensContext context, @NotNull ConflictResolutionType resolutionPolicy, int attemptNew) { int maxAttempts = defaultIfNull(resolutionPolicy.getMaxAttempts(), DEFAULT_MAX_CONFLICT_RESOLUTION_ATTEMPTS); if (attemptNew > maxAttempts) { return false; } + return true; + } + + private void delay(LensContext context, @NotNull ConflictResolutionType resolutionPolicy, int attempts) { long delayUnit = defaultIfNull(resolutionPolicy.getDelayUnit(), DEFAULT_CONFLICT_RESOLUTION_DELAY_UNIT); - for (int i = 0; i < attemptNew; i++) { + for (int i = 0; i < attempts; i++) { delayUnit *= 2; } long delay = (long) (Math.random() * delayUnit); - String message = "Waiting "+delay+" milliseconds before starting conflict resolution attempt "+attemptNew+" of "+maxAttempts; + String message = "CONFLICT: Waiting "+delay+" milliseconds before starting conflict resolution (delay exponent: "+attempts+")"; // TODO convey information about waiting time after some GUI mechanism for displaying it is available // (showing text messages is currently really ugly) context.reportProgress(new ProgressInformation(WAITING, EXITING)); @@ -323,7 +358,6 @@ private boolean shouldExecuteAttempt(@NotNull ConflictRes // ignore } context.reportProgress(new ProgressInformation(WAITING, EXITING)); - return true; } private void enterAssociationSearchExpressionEvaluatorCache() { @@ -357,7 +391,9 @@ private int getMaxClicks(LensContext context, Operatio } } - public HookOperationMode click(LensContext context, Task task, OperationResult result) throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { + public HookOperationMode click(LensContext context, Task task, OperationResult result) + throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, + ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException, PreconditionViolationException { // DO NOT CHECK CONSISTENCY of the context here. The context may not be fresh and consistent yet. Project will fix // that. Check consistency afterwards (and it is also checked inside projector several times). @@ -450,7 +486,7 @@ public HookOperationMode click(LensContext context, Ta } catch (CommunicationException | ConfigurationException | ExpressionEvaluationException | ObjectNotFoundException | PolicyViolationException | SchemaException | SecurityViolationException | RuntimeException | - ObjectAlreadyExistsException e) { + ObjectAlreadyExistsException | PreconditionViolationException e) { processClockworkException(context, e, task, result); throw e; } @@ -579,7 +615,9 @@ private void processPrimaryToSecondary(LensContext con context.setState(ModelState.SECONDARY); } - private void processSecondary(LensContext context, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException, PolicyViolationException { + private void processSecondary(LensContext context, Task task, OperationResult result) + throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, + SecurityViolationException, ExpressionEvaluationException, PolicyViolationException, PreconditionViolationException { if (context.getExecutionWave() > context.getMaxWave() + 1) { context.setState(ModelState.FINAL); return; @@ -588,16 +626,8 @@ private void processSecondary(LensContext context, Tas Holder restartRequestedHolder = new Holder<>(); LensUtil.partialExecute("execution", - () -> { - boolean restartRequested; - try { - - restartRequested = changeExecutor.executeChanges(context, task, result); - - } catch (PreconditionViolationException e) { - LOGGER.debug("Precondition violation, will restart"); - restartRequested = true; - } + () -> { + boolean restartRequested = changeExecutor.executeChanges(context, task, result); restartRequestedHolder.setValue(restartRequested); }, context.getPartialProcessingOptions()::getExecution); @@ -697,7 +727,9 @@ private

boolean isShadowDeltaSignificant(ObjectDelta

d return false; } - private HookOperationMode processFinal(LensContext context, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException, PolicyViolationException { + private HookOperationMode processFinal(LensContext context, Task task, OperationResult result) + throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, + SecurityViolationException, ExpressionEvaluationException, PolicyViolationException, PreconditionViolationException { auditFinalExecution(context, task, result); logFinalReadable(context, task, result); recordOperationExecution(context, null, task, result); diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensContext.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensContext.java index e438a685e99..a43259ecccc 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensContext.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensContext.java @@ -1368,4 +1368,22 @@ public void unregisterConflictWatchers(RepositoryService repositoryService) { conflictWatchers.forEach(w -> repositoryService.unregisterConflictWatcher(w)); conflictWatchers.clear(); } + + public boolean hasProjectionChange() { + for (LensProjectionContext projectionContext: getProjectionContexts()) { + if (projectionContext.getWave() != getExecutionWave()) { + continue; + } + if (!projectionContext.isCanProject()) { + continue; + } + if (projectionContext.isThombstone()) { + continue; + } + if (projectionContext.hasPrimaryDelta() || projectionContext.hasSecondaryDelta()) { + return true; + } + } + return false; + } } diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensElementContext.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensElementContext.java index e806d0b7880..c0decff2e84 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensElementContext.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensElementContext.java @@ -709,9 +709,12 @@ protected String getDebugDumpTitle(String suffix) { public abstract String getHumanReadableName(); public String getObjectReadVersion() { - if (getObjectCurrent() != null) { - return getObjectCurrent().getVersion(); - } + // Do NOT use version from object current. + // Current object may be re-read, but the computation + // might be based on older data (objectOld). +// if (getObjectCurrent() != null) { +// return getObjectCurrent().getVersion(); +// } if (getObjectOld() != null) { return getObjectOld().getVersion(); } diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensUtil.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensUtil.java index 37ba88f412a..d01439351d8 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensUtil.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensUtil.java @@ -63,6 +63,7 @@ import com.evolveum.midpoint.prism.delta.PropertyDelta; import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.provisioning.api.ProvisioningService; +import com.evolveum.midpoint.repo.api.PreconditionViolationException; import com.evolveum.midpoint.repo.common.expression.Expression; import com.evolveum.midpoint.repo.common.expression.ExpressionEvaluationContext; import com.evolveum.midpoint.repo.common.expression.ExpressionFactory; @@ -1231,14 +1232,14 @@ public static void processRuleWithException(@NotNull EvaluatedPolicyRule rule, C public static void partialExecute(String componentName, ProjectorComponentRunnable runnable, Supplier optionSupplier) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, - PolicyViolationException, ExpressionEvaluationException, ObjectAlreadyExistsException { + PolicyViolationException, ExpressionEvaluationException, ObjectAlreadyExistsException, PreconditionViolationException { partialExecute(componentName, runnable, optionSupplier, null); } public static void partialExecute(String componentName, ProjectorComponentRunnable runnable, Supplier optionSupplier, OperationResult result) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, - PolicyViolationException, ExpressionEvaluationException, ObjectAlreadyExistsException { + PolicyViolationException, ExpressionEvaluationException, ObjectAlreadyExistsException, PreconditionViolationException { PartialProcessingTypeType option = optionSupplier.get(); if (option == PartialProcessingTypeType.SKIP) { LOGGER.debug("Skipping projector component {} because partial execution option is set to {}", componentName, option); @@ -1248,7 +1249,7 @@ public static void partialExecute(String componentName, ProjectorComponentRunnab runnable.run(); LOGGER.trace("Projector component finished: {}", componentName); } catch (SchemaException | ObjectNotFoundException | CommunicationException | ConfigurationException | SecurityViolationException - | PolicyViolationException | ExpressionEvaluationException | ObjectAlreadyExistsException | RuntimeException | Error e) { + | PolicyViolationException | ExpressionEvaluationException | ObjectAlreadyExistsException | PreconditionViolationException | RuntimeException | Error e) { LOGGER.trace("Projector component error: {}: {}: {}", componentName, e.getClass().getSimpleName(), e.getMessage()); if (result != null) { result.recordFatalError(e); diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/PersonaProcessor.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/PersonaProcessor.java index acfecb83250..b5563a21c32 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/PersonaProcessor.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/PersonaProcessor.java @@ -41,6 +41,7 @@ import com.evolveum.midpoint.prism.delta.DeltaSetTriple; import com.evolveum.midpoint.prism.delta.ItemDelta; import com.evolveum.midpoint.prism.delta.ObjectDelta; +import com.evolveum.midpoint.repo.api.PreconditionViolationException; import com.evolveum.midpoint.repo.api.RepositoryService; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.util.FocusTypeUtil; @@ -105,7 +106,9 @@ public class PersonaProcessor { private PrismContext prismContext; @SuppressWarnings({ "unchecked", "rawtypes" }) - public HookOperationMode processPersonaChanges(LensContext context, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException, PolicyViolationException { + public HookOperationMode processPersonaChanges(LensContext context, Task task, OperationResult result) + throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, CommunicationException, + ConfigurationException, SecurityViolationException, ExpressionEvaluationException, PolicyViolationException, PreconditionViolationException { LensFocusContext focusContext = context.getFocusContext(); if (focusContext == null) { @@ -127,7 +130,9 @@ public HookOperationMode processPersonaChanges(LensContex return processPersonaChangesFocus((LensContext) context, task, result); } - public HookOperationMode processPersonaChangesFocus(LensContext context, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException, PolicyViolationException { + public HookOperationMode processPersonaChangesFocus(LensContext context, Task task, OperationResult result) + throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, CommunicationException, + ConfigurationException, SecurityViolationException, ExpressionEvaluationException, PolicyViolationException, PreconditionViolationException { DeltaSetTriple> evaluatedAssignmentTriple = (DeltaSetTriple)context.getEvaluatedAssignmentTriple(); if (evaluatedAssignmentTriple == null || evaluatedAssignmentTriple.isEmpty()) { return HookOperationMode.FOREGROUND; @@ -262,7 +267,8 @@ private boolean personaMatches(FocusType persona, PersonaKey key) { public void personaAdd(LensContext context, PersonaKey key, PersonaConstruction construction, Task task, OperationResult result) - throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, PolicyViolationException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { + throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, PolicyViolationException, ObjectAlreadyExistsException, + CommunicationException, ConfigurationException, SecurityViolationException, PreconditionViolationException { PrismObject focus = context.getFocusContext().getObjectNew(); LOGGER.debug("Adding persona {} for {} using construction {}", key, focus, construction); PersonaConstructionType constructionType = construction.getConstructionType(); @@ -302,7 +308,8 @@ public void personaAdd(LensContext public void personaModify(LensContext context, PersonaKey key, PersonaConstruction construction, PrismObject existingPersona, Task task, OperationResult result) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, PolicyViolationException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, PolicyViolationException, + ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException, PreconditionViolationException { PrismObject focus = context.getFocusContext().getObjectNew(); LOGGER.debug("Modifying persona {} for {} using construction {}", key, focus, construction); PersonaConstructionType constructionType = construction.getConstructionType(); @@ -328,7 +335,10 @@ public void personaModify(LensContext executePersonaDelta(targetDelta, task, result); } - public void personaDelete(LensContext context, PersonaKey key, FocusType existingPersona, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + public void personaDelete(LensContext context, PersonaKey key, FocusType existingPersona, + Task task, OperationResult result) + throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, + CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, PreconditionViolationException { PrismObject focus = context.getFocusContext().getObjectOld(); LOGGER.debug("Deleting persona {} for {}: ", key, focus, existingPersona); ObjectDelta targetDelta = existingPersona.asPrismObject().createDeleteDelta(); @@ -358,7 +368,9 @@ private void unlink(LensContext context, FocusType per repositoryService.modifyObject(delta.getObjectTypeClass(), delta.getOid(), delta.getModifications(), result); } - private void executePersonaDelta(ObjectDelta delta, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, PolicyViolationException, ExpressionEvaluationException, ObjectAlreadyExistsException, SecurityViolationException { + private void executePersonaDelta(ObjectDelta delta, Task task, OperationResult result) + throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, + PolicyViolationException, ExpressionEvaluationException, ObjectAlreadyExistsException, SecurityViolationException, PreconditionViolationException { Collection> deltas = MiscSchemaUtil.createCollection(delta); LensContext context = contextFactory.createContext(deltas, null, task, result); // Persona changes are all "secondary" changes, trigerred by roles and policies. We do not want to authorize diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/ProjectorComponentRunnable.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/ProjectorComponentRunnable.java index a20226a39ae..65898c787d7 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/ProjectorComponentRunnable.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/ProjectorComponentRunnable.java @@ -15,6 +15,7 @@ */ package com.evolveum.midpoint.model.impl.lens; +import com.evolveum.midpoint.repo.api.PreconditionViolationException; import com.evolveum.midpoint.util.exception.CommunicationException; import com.evolveum.midpoint.util.exception.ConfigurationException; import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; @@ -33,6 +34,6 @@ public interface ProjectorComponentRunnable { void run() throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, - SecurityViolationException, PolicyViolationException, ExpressionEvaluationException, ObjectAlreadyExistsException; + SecurityViolationException, PolicyViolationException, ExpressionEvaluationException, ObjectAlreadyExistsException, PreconditionViolationException; } diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ActivationProcessor.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ActivationProcessor.java index 345d1ef1e15..dc383c1d266 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ActivationProcessor.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ActivationProcessor.java @@ -122,9 +122,20 @@ private void processActivationFocal(LensContext context processActivationMetadata(context, projectionContext, now, result); return; } - processActivationUserCurrent(context, projectionContext, now, task, result); - processActivationMetadata(context, projectionContext, now, result); - processActivationUserFuture(context, projectionContext, now, task, result); + try { + + processActivationUserCurrent(context, projectionContext, now, task, result); + processActivationMetadata(context, projectionContext, now, result); + processActivationUserFuture(context, projectionContext, now, task, result); + + } catch (ObjectNotFoundException e) { + if (projectionContext.isThombstone()) { + // This is not critical. The projection is marked as thombstone and we can go on with processing + // No extra action is needed. + } else { + throw e; + } + } } public void processActivationUserCurrent(LensContext context, LensProjectionContext projCtx, diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ContextLoader.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ContextLoader.java index 32653c97e11..7e56d7f5793 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ContextLoader.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ContextLoader.java @@ -1277,7 +1277,7 @@ public void loadFullShadow(LensContext context, LensPr projCtx.setOid(objectCurrent.getOid()); } catch (ObjectNotFoundException ex) { - LOGGER.trace("Load of full resource object {} ended with ObjectNotFoundException (options={})", projCtx, getOptions); + LOGGER.debug("Load of full resource object {} ended with ObjectNotFoundException (options={})", projCtx, getOptions); if (projCtx.isDelete()){ //this is OK, shadow was deleted, but we will continue in processing with old shadow..and set it as full so prevent from other full loading projCtx.setFullShadow(true); diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/FocusProcessor.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/FocusProcessor.java index 2416410aede..ce28de1e9b7 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/FocusProcessor.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/FocusProcessor.java @@ -57,6 +57,7 @@ import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.path.NameItemPathSegment; import com.evolveum.midpoint.prism.polystring.PolyString; +import com.evolveum.midpoint.repo.api.PreconditionViolationException; import com.evolveum.midpoint.repo.api.RepositoryService; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; @@ -113,9 +114,6 @@ public class FocusProcessor { @Autowired private ObjectTemplateProcessor objectTemplateProcessor; - @Autowired - private MappingFactory mappingFactory; - @Autowired private PrismContext prismContext; @@ -145,8 +143,9 @@ public class FocusProcessor { private PolicyRuleProcessor policyRuleProcessor; void processFocus(LensContext context, String activityDescription, - XMLGregorianCalendar now, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, PolicyViolationException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { + XMLGregorianCalendar now, Task task, OperationResult result) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, PolicyViolationException, + ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException, PreconditionViolationException { LensFocusContext focusContext = context.getFocusContext(); if (focusContext == null) { @@ -163,8 +162,8 @@ void processFocus(LensContext con private void processFocusFocus(LensContext context, String activityDescription, XMLGregorianCalendar now, Task task, OperationResult result) - throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, PolicyViolationException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, PolicyViolationException, + ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException, PreconditionViolationException { LensFocusContext focusContext = context.getFocusContext(); ObjectTemplateType objectTemplate = context.getFocusTemplate(); PartialProcessingOptionsType partialProcessingOptions = context.getPartialProcessingOptions(); diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/MappingEvaluator.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/MappingEvaluator.java index 00082e2ba0d..57d1dd758bb 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/MappingEvaluator.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/MappingEvaluator.java @@ -303,7 +303,7 @@ public implements MappingLoader { + + private static final Trace LOGGER = TraceManager.getTrace(ProjectionMappingLoader.class); private LensProjectionContext projectionContext; private ContextLoader contextLoader; @@ -55,9 +59,14 @@ public boolean isLoaded() { @Override public PrismObject load(String loadReason, Task task, OperationResult result) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { contextLoader.loadFullShadow(context, projectionContext, loadReason, task, result); - if (projectionContext.getSynchronizationPolicyDecision() == SynchronizationPolicyDecision.BROKEN) { - // TODO - } + if (SynchronizationPolicyDecision.BROKEN.equals(projectionContext.getSynchronizationPolicyDecision())) { + LOGGER.debug("Attempt to load full object for {} failed, projection context is broken", projectionContext.getHumanReadableName()); + throw new ObjectNotFoundException("Projection loading failed, projection broken"); + } + if (projectionContext.isThombstone()) { + LOGGER.debug("Projection {} got thombstoned", projectionContext.getHumanReadableName()); + throw new ObjectNotFoundException("Projection loading failed, projection thombstoned"); + } return projectionContext.getObjectCurrent(); } diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ProjectionValuesProcessor.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ProjectionValuesProcessor.java index 14762911fb3..c45afe99b16 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ProjectionValuesProcessor.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ProjectionValuesProcessor.java @@ -313,6 +313,7 @@ private void processProjections(LensContext context, projContext.setSynchronizationPolicyDecision(SynchronizationPolicyDecision.KEEP); projContext.setObjectOld(fullConflictingShadow.clone()); projContext.setObjectCurrent(fullConflictingShadow); + projContext.setOid(fullConflictingShadow.getOid()); projContext.setFullShadow(true); ObjectDelta secondaryDelta = projContext.getSecondaryDelta(); if (secondaryDelta != null && projContext.getOid() != null) { @@ -381,6 +382,7 @@ private void processProjections(LensContext context, cleanupContext(projContext, fullConflictingShadow); projContext.setObjectOld(fullConflictingShadow.clone()); projContext.setObjectCurrent(fullConflictingShadow); + projContext.setOid(fullConflictingShadow.getOid()); projContext.setFullShadow(true); projContext.setSynchronizationPolicyDecision(SynchronizationPolicyDecision.KEEP); ObjectDelta secondaryDelta = projContext.getSecondaryDelta(); diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/Projector.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/Projector.java index 17d4e7ecb11..f2a611ea237 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/Projector.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/Projector.java @@ -36,6 +36,7 @@ import com.evolveum.midpoint.model.impl.lens.LensUtil; import com.evolveum.midpoint.model.impl.lens.projector.credentials.ProjectionCredentialsProcessor; import com.evolveum.midpoint.prism.xml.XmlTypeConverter; +import com.evolveum.midpoint.repo.api.PreconditionViolationException; import com.evolveum.midpoint.schema.ResourceShadowDiscriminator; import com.evolveum.midpoint.schema.internals.InternalCounters; import com.evolveum.midpoint.schema.internals.InternalMonitor; @@ -109,7 +110,7 @@ public class Projector { public void project(LensContext context, String activityDescription, Task task, OperationResult parentResult) throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, - ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { + ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException, PreconditionViolationException { projectInternal(context, activityDescription, true, false, task, parentResult); } @@ -119,7 +120,7 @@ public void project(LensContext context, String activi public void resume(LensContext context, String activityDescription, Task task, OperationResult parentResult) throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, - ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { + ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException, PreconditionViolationException { if (context.getProjectionWave() != context.getExecutionWave()) { throw new IllegalStateException("Projector.resume called in illegal wave state: execution wave = " + context.getExecutionWave() + @@ -139,14 +140,14 @@ public void resume(LensContext context, String activit public void projectAllWaves(LensContext context, String activityDescription, Task task, OperationResult parentResult) throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, - ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { + ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException, PreconditionViolationException { projectInternal(context, activityDescription, true, true, task, parentResult); } private void projectInternal(LensContext context, String activityDescription, boolean fromStart, boolean allWaves, Task task, OperationResult parentResult) throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, - ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { + ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException, PreconditionViolationException { context.checkAbortRequested(); @@ -290,7 +291,7 @@ private void projectInternal(LensContext context, Stri computeResultStatus(now, result); } catch (SchemaException | PolicyViolationException | ExpressionEvaluationException | ObjectAlreadyExistsException | - ObjectNotFoundException | CommunicationException | ConfigurationException | SecurityViolationException e) { + ObjectNotFoundException | CommunicationException | ConfigurationException | SecurityViolationException | PreconditionViolationException e) { recordFatalError(e, now, result); throw e; } catch (RuntimeException e) { @@ -310,7 +311,9 @@ private void projectInternal(LensContext context, Stri private void projectProjection(LensContext context, LensProjectionContext projectionContext, PartialProcessingOptionsType partialProcessingOptions, - XMLGregorianCalendar now, String activityDescription, Task task, OperationResult parentResult) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, PolicyViolationException, ExpressionEvaluationException, ObjectAlreadyExistsException { + XMLGregorianCalendar now, String activityDescription, Task task, OperationResult parentResult) + throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, + SecurityViolationException, PolicyViolationException, ExpressionEvaluationException, ObjectAlreadyExistsException, PreconditionViolationException { if (projectionContext.getWave() != context.getProjectionWave()) { // Let's skip accounts that do not belong into this wave. @@ -364,6 +367,10 @@ private void projectProjection(LensContext context, Le }, partialProcessingOptions::getProjectionValues); + if (projectionContext.isThombstone()) { + result.recordStatus(OperationResultStatus.NOT_APPLICABLE, "Skipping projection because it is a thombstone"); + return; + } LensUtil.partialExecute("projectionCredentials", () -> { diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/sync/FocusValidityScannerTaskHandler.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/sync/FocusValidityScannerTaskHandler.java index 6e9b2fadc8f..01e87efbe80 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/sync/FocusValidityScannerTaskHandler.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/sync/FocusValidityScannerTaskHandler.java @@ -31,6 +31,7 @@ import com.evolveum.midpoint.prism.query.ObjectFilter; import com.evolveum.midpoint.prism.query.ObjectQuery; import com.evolveum.midpoint.prism.query.builder.QueryBuilder; +import com.evolveum.midpoint.repo.api.PreconditionViolationException; import com.evolveum.midpoint.schema.result.OperationConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.util.ObjectTypeUtil; @@ -238,7 +239,7 @@ protected AbstractScannerResultHandler createHandler(TaskRunResult run AbstractScannerResultHandler handler = new AbstractScannerResultHandler( coordinatorTask, FocusValidityScannerTaskHandler.class.getName(), "recompute", "recompute task", taskManager) { @Override - protected boolean handleObject(PrismObject object, Task workerTask, OperationResult result) throws CommonException { + protected boolean handleObject(PrismObject object, Task workerTask, OperationResult result) throws CommonException, PreconditionViolationException { if (oidAlreadySeen(coordinatorTask, object.getOid())) { LOGGER.trace("Recomputation already executed for {}", ObjectTypeUtil.toShortString(object)); } else { @@ -253,7 +254,7 @@ protected boolean handleObject(PrismObject object, Task workerTask, Op private void reconcileUser(PrismObject user, Task workerTask, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ObjectAlreadyExistsException, - ConfigurationException, PolicyViolationException, SecurityViolationException { + ConfigurationException, PolicyViolationException, SecurityViolationException, PreconditionViolationException { LOGGER.trace("Recomputing user {}", user); // We want reconcile option here. There may be accounts that are in wrong activation state. // We will not notice that unless we go with reconcile. diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/sync/RecomputeTaskHandler.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/sync/RecomputeTaskHandler.java index b4f4a4d6698..9e7cc220a15 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/sync/RecomputeTaskHandler.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/sync/RecomputeTaskHandler.java @@ -36,6 +36,7 @@ import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.query.ObjectQuery; +import com.evolveum.midpoint.repo.api.PreconditionViolationException; import com.evolveum.midpoint.schema.result.OperationConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; @@ -111,7 +112,7 @@ protected AbstractSearchIterativeResultHandler createHandler(TaskRunR AbstractSearchIterativeResultHandler handler = new AbstractSearchIterativeResultHandler( coordinatorTask, RecomputeTaskHandler.class.getName(), "recompute", "recompute task", taskManager) { @Override - protected boolean handleObject(PrismObject object, Task workerTask, OperationResult result) throws CommonException { + protected boolean handleObject(PrismObject object, Task workerTask, OperationResult result) throws CommonException, PreconditionViolationException { recompute(object, getOptions(coordinatorTask), workerTask, result); return true; } @@ -134,7 +135,7 @@ private ModelExecuteOptions getOptions(Task coordinatorTask) throws SchemaExcept private void recompute(PrismObject focalObject, ModelExecuteOptions options, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ObjectAlreadyExistsException, - ConfigurationException, PolicyViolationException, SecurityViolationException { + ConfigurationException, PolicyViolationException, SecurityViolationException, PreconditionViolationException { LOGGER.trace("Recomputing object {}", focalObject); LensContext syncContext = contextFactory.createRecomputeContext(focalObject, options, task, result); diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/sync/SynchronizationServiceImpl.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/sync/SynchronizationServiceImpl.java index a793f87b584..0e74029c857 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/sync/SynchronizationServiceImpl.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/sync/SynchronizationServiceImpl.java @@ -56,6 +56,7 @@ import com.evolveum.midpoint.prism.delta.PropertyDelta; import com.evolveum.midpoint.prism.polystring.PolyString; import com.evolveum.midpoint.provisioning.api.ResourceObjectShadowChangeDescription; +import com.evolveum.midpoint.repo.api.PreconditionViolationException; import com.evolveum.midpoint.repo.api.RepositoryService; import com.evolveum.midpoint.schema.GetOperationOptions; import com.evolveum.midpoint.schema.ResourceShadowDiscriminator; @@ -781,7 +782,7 @@ private SynchronizationSituationType reactToChange(Class void handle(PrismObject object, TriggerType tri clockwork.run(lensContext, task, result); LOGGER.trace("Recomputing of {}: {}", object, result.getStatus()); - } catch (SchemaException e) { - LOGGER.error(e.getMessage(), e); - } catch (ObjectNotFoundException e) { - LOGGER.error(e.getMessage(), e); - } catch (ExpressionEvaluationException e) { - LOGGER.error(e.getMessage(), e); - } catch (CommunicationException e) { - LOGGER.error(e.getMessage(), e); - } catch (ObjectAlreadyExistsException e) { - LOGGER.error(e.getMessage(), e); - } catch (ConfigurationException e) { - LOGGER.error(e.getMessage(), e); - } catch (PolicyViolationException e) { - LOGGER.error(e.getMessage(), e); - } catch (SecurityViolationException e) { + } catch (CommonException | PreconditionViolationException | RuntimeException | Error e) { LOGGER.error(e.getMessage(), e); } diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/util/AbstractSearchIterativeResultHandler.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/util/AbstractSearchIterativeResultHandler.java index ef2de0be915..58d1308cc8f 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/util/AbstractSearchIterativeResultHandler.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/util/AbstractSearchIterativeResultHandler.java @@ -17,6 +17,7 @@ import com.evolveum.midpoint.prism.PrismProperty; import com.evolveum.midpoint.prism.polystring.PolyString; +import com.evolveum.midpoint.repo.api.PreconditionViolationException; import com.evolveum.midpoint.repo.cache.RepositoryCache; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResultStatus; @@ -353,7 +354,7 @@ private void processRequest(ProcessingRequest request, Task workerTask, Operatio } } - } catch (CommonException|RuntimeException e) { + } catch (CommonException | PreconditionViolationException | Error | RuntimeException e) { if (isRecordIterationStatistics()) { workerTask.recordIterativeOperationEnd(objectName, objectDisplayName, null /* TODO */, object.getOid(), startTime, e); @@ -430,7 +431,7 @@ private boolean shouldReportProgress() { } } - private boolean processError(PrismObject object, Exception ex, OperationResult result) { + private boolean processError(PrismObject object, Throwable ex, OperationResult result) { int errorsCount = errors.incrementAndGet(); LOGGER.trace("Processing error, count: {}", errorsCount); @@ -480,7 +481,7 @@ public void setLogErrors(boolean logErrors) { this.logErrors = logErrors; } - protected abstract boolean handleObject(PrismObject object, Task workerTask, OperationResult result) throws CommonException; + protected abstract boolean handleObject(PrismObject object, Task workerTask, OperationResult result) throws CommonException, PreconditionViolationException; public class ProcessingRequest { public PrismObject object; diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestClockwork.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestClockwork.java index 8fec5f5df04..2f17ae28ff3 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestClockwork.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestClockwork.java @@ -60,6 +60,7 @@ import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.xml.XmlTypeConverter; +import com.evolveum.midpoint.repo.api.PreconditionViolationException; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.util.ResourceTypeUtil; import com.evolveum.midpoint.schema.util.SchemaTestConstants; @@ -402,7 +403,7 @@ private LensContext createJackAssignAccountContext(OperationResult res return context; } - private void unassignJackAccount() throws SchemaException, ObjectNotFoundException, IOException, JAXBException, PolicyViolationException, ExpressionEvaluationException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { + private void unassignJackAccount() throws SchemaException, ObjectNotFoundException, IOException, JAXBException, PolicyViolationException, ExpressionEvaluationException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException, PreconditionViolationException { Task task = taskManager.createTaskInstance(TestClockwork.class.getName() + ".unassignJackAccount"); LensContext context = createUserLensContext(); OperationResult result = task.getResult(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestActivation.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestActivation.java index b8a4def6458..48883376cfd 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestActivation.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestActivation.java @@ -1913,8 +1913,8 @@ public void test217ModifyLargoRemoveValidFrom() throws Exception { /** * Delete assignment from repo. Model should not notice. - * The change should be NOT applied after recompute. - * Accounts are not retrieved, therefore the change is not noticed. + * The change should be applied after recompute, because RED resource has + * strong mappings, which trigger account to be loaded. */ @Test public void test230JackUnassignRepoRecompute() throws Exception { @@ -1940,14 +1940,12 @@ public void test230JackUnassignRepoRecompute() throws Exception { // THEN displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); + assertSuccess(result); - assertDummyAccount(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME, "Jack Sparrow", true); + assertDummyAccount(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME, "Jack Sparrow", false); } /** - * Deleted assignment from the repo (previous test). Model haven't noticed. * Now recompute with reconcile. The change should be applied after recompute. */ @Test @@ -1965,8 +1963,7 @@ public void test231JackRecomputeReconcile() throws Exception { // THEN displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); + assertSuccess(result); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME, "Jack Sparrow", false); } diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestAudit.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestAudit.java index 65143b6b44d..3a1e9f9c3c0 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestAudit.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestAudit.java @@ -105,7 +105,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); assertTrue(modelAuditService.supportsRetrieval()); @@ -122,7 +122,7 @@ public void test000Sanity() throws Exception { @Test public void test010SanityJack() throws Exception { final String TEST_NAME = "test010SanityJack"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); // WHEN List auditRecords = getObjectAuditRecords(USER_JACK_OID); @@ -136,20 +136,20 @@ public void test010SanityJack() throws Exception { @Test public void test100ModifyUserJackKid() throws Exception { final String TEST_NAME = "test100ModifyUserJackKid"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); - Task task = taskManager.createTaskInstance(TestAudit.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); initialTs = getTimeSafely(); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); modifyUserReplace(USER_JACK_OID, UserType.F_TITLE, task, result, createPolyString("Kid")); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -165,9 +165,9 @@ public void test100ModifyUserJackKid() throws Exception { @Test public void test105CreateUserHerman() throws Exception { final String TEST_NAME = "test105CreateUserHerman"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); - Task task = taskManager.createTaskInstance(TestAudit.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); PrismObject userHermanBefore = PrismTestUtil.parseObject(USER_HERMAN_FILE); @@ -177,12 +177,12 @@ public void test105CreateUserHerman() throws Exception { hermanInitialTs = getTimeSafely(); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); addObject(userHermanBefore, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -197,9 +197,9 @@ public void test105CreateUserHerman() throws Exception { @Test public void test110ModifyUserJackSailor() throws Exception { final String TEST_NAME = "test110ModifyUserJackSailor"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); - Task task = taskManager.createTaskInstance(TestAudit.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); @@ -210,12 +210,12 @@ public void test110ModifyUserJackSailor() throws Exception { ActivationStatusType.DISABLED); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); modelService.executeChanges(MiscSchemaUtil.createCollection(objectDelta), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -230,9 +230,9 @@ public void test110ModifyUserJackSailor() throws Exception { @Test public void test115ModifyUserHermanMarooned() throws Exception { final String TEST_NAME = "test115ModifyUserHermanMarooned"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); - Task task = taskManager.createTaskInstance(TestAudit.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); ObjectDelta objectDelta = createModifyUserReplaceDelta(USER_HERMAN_OID, UserType.F_TITLE, @@ -241,14 +241,13 @@ public void test115ModifyUserHermanMarooned() throws Exception { objectDelta.addModification(createAssignmentModification(RESOURCE_DUMMY_OID, ShadowKindType.ACCOUNT, null, true)); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); modelService.executeChanges(MiscSchemaUtil.createCollection(objectDelta), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); + displayThen(TEST_NAME); + assertSuccess(result); PrismObject user = getUser(USER_HERMAN_OID); display("Herman (marooned)", user); @@ -262,9 +261,9 @@ public void test115ModifyUserHermanMarooned() throws Exception { @Test public void test120ModifyUserJackCaptain() throws Exception { final String TEST_NAME = "test120ModifyUserJackCaptain"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); - Task task = taskManager.createTaskInstance(TestAudit.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); ObjectDelta objectDelta = createModifyUserReplaceDelta(USER_JACK_OID, UserType.F_TITLE, @@ -274,14 +273,13 @@ public void test120ModifyUserJackCaptain() throws Exception { ActivationStatusType.ENABLED); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); modelService.executeChanges(MiscSchemaUtil.createCollection(objectDelta), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); + displayThen(TEST_NAME); + assertSuccess(result); jackCaptainTs = getTimeSafely(); jackCaptainEid = assertObjectAuditRecords(USER_JACK_OID, 6); @@ -294,9 +292,9 @@ public void test120ModifyUserJackCaptain() throws Exception { @Test public void test125ModifyUserHermanHermit() throws Exception { final String TEST_NAME = "test125ModifyUserHermanHermit"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); - Task task = taskManager.createTaskInstance(TestAudit.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); ObjectDelta objectDelta = createModifyUserReplaceDelta(USER_HERMAN_OID, UserType.F_TITLE, @@ -311,15 +309,14 @@ public void test125ModifyUserHermanHermit() throws Exception { null, null, null, true)); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); modelService.executeChanges(MiscSchemaUtil.createCollection(objectDelta), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); + displayThen(TEST_NAME); + assertSuccess(result); PrismObject user = getUser(USER_HERMAN_OID); display("Herman (hermit)", user); @@ -332,9 +329,9 @@ public void test125ModifyUserHermanHermit() throws Exception { @Test public void test135ModifyUserHermanCivilisedHermit() throws Exception { final String TEST_NAME = "test135ModifyUserHermanCivilisedHermit"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); - Task task = taskManager.createTaskInstance(TestAudit.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); ObjectDelta objectDelta = createModifyUserReplaceDelta(USER_HERMAN_OID, UserType.F_TITLE, @@ -344,30 +341,29 @@ public void test135ModifyUserHermanCivilisedHermit() throws Exception { null, null, null, false)); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); modelService.executeChanges(MiscSchemaUtil.createCollection(objectDelta), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); + displayThen(TEST_NAME); + assertSuccess(result); PrismObject user = getUser(USER_HERMAN_OID); display("Herman (civilised hermit)", user); hermanCivilisedHermitTs = getTimeSafely(); - hermanCivilisedHermitEid = assertObjectAuditRecords(USER_HERMAN_OID, 8); - assertRecordsFromInitial(hermanCivilisedHermitTs, 14); + hermanCivilisedHermitEid = assertObjectAuditRecords(USER_HERMAN_OID, 9); + assertRecordsFromInitial(hermanCivilisedHermitTs, 15); } @Test public void test200ReconstructJackSailor() throws Exception { final String TEST_NAME = "test200ReconstructJackSailor"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); - Task task = taskManager.createTaskInstance(TestAudit.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -376,15 +372,14 @@ public void test200ReconstructJackSailor() throws Exception { PrismAsserts.assertPropertyValue(userBefore, UserType.F_TITLE, createPolyString("Captain")); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); PrismObject jackReconstructed = modelAuditService.reconstructObject(UserType.class, USER_JACK_OID, jackSailorEid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); + displayThen(TEST_NAME); + assertSuccess(result); display("Reconstructed jack", jackReconstructed); @@ -397,9 +392,9 @@ public void test200ReconstructJackSailor() throws Exception { @Test public void test210ReconstructJackKid() throws Exception { final String TEST_NAME = "test210ReconstructJackKid"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); - Task task = taskManager.createTaskInstance(TestAudit.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -408,15 +403,14 @@ public void test210ReconstructJackKid() throws Exception { PrismAsserts.assertPropertyValue(userBefore, UserType.F_TITLE, createPolyString("Captain")); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); PrismObject jackReconstructed = modelAuditService.reconstructObject(UserType.class, USER_JACK_OID, jackKidEid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); + displayThen(TEST_NAME); + assertSuccess(result); display("Reconstructed jack", jackReconstructed); @@ -431,9 +425,9 @@ public void test210ReconstructJackKid() throws Exception { @Test public void test250ReconstructHermanCreated() throws Exception { final String TEST_NAME = "test250ReconstructHermanCreated"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); - Task task = taskManager.createTaskInstance(TestAudit.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_HERMAN_OID); @@ -445,15 +439,14 @@ public void test250ReconstructHermanCreated() throws Exception { assertAssignments(userBefore, 1); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); PrismObject hermanReconstructed = modelAuditService.reconstructObject(UserType.class, USER_HERMAN_OID, hermanCreatedEid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); + displayThen(TEST_NAME); + assertSuccess(result); display("Reconstructed herman", hermanReconstructed); @@ -472,21 +465,20 @@ public void test250ReconstructHermanCreated() throws Exception { @Test public void test252ReconstructHermanMarooned() throws Exception { final String TEST_NAME = "test252ReconstructHermanMarooned"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); - Task task = taskManager.createTaskInstance(TestAudit.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); PrismObject hermanReconstructed = modelAuditService.reconstructObject(UserType.class, USER_HERMAN_OID, hermanMaroonedEid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); + displayThen(TEST_NAME); + assertSuccess(result); display("Reconstructed herman", hermanReconstructed); @@ -506,21 +498,20 @@ public void test252ReconstructHermanMarooned() throws Exception { @Test public void test254ReconstructHermanHermit() throws Exception { final String TEST_NAME = "test254ReconstructHermanHermit"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); - Task task = taskManager.createTaskInstance(TestAudit.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); PrismObject hermanReconstructed = modelAuditService.reconstructObject(UserType.class, USER_HERMAN_OID, hermanHermitEid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); + displayThen(TEST_NAME); + assertSuccess(result); display("Reconstructed herman", hermanReconstructed); @@ -588,7 +579,7 @@ public void test300ConcurrentAudits() throws Exception { Thread thread = new Thread(() -> { try { login(userAdministrator); - Task threadTask = taskManager.createTaskInstance(TestAudit.class.getName() + "." + TEST_NAME); + Task threadTask = createTask(TEST_NAME); OperationResult threadResult = threadTask.getResult(); for (int iteration = 0; iteration < ITERATIONS; iteration++) { display("Executing iteration " + iteration + " on user " + index); @@ -659,7 +650,7 @@ public void test310ConcurrentAuditsRaw() throws Exception { Thread thread = new Thread(() -> { try { login(userAdministrator); - Task threadTask = taskManager.createTaskInstance(TestAudit.class.getName() + "." + TEST_NAME); + Task threadTask = createTask(TEST_NAME); OperationResult threadResult = threadTask.getResult(); for (int iteration = 0; iteration < ITERATIONS; iteration++) { display("Executing iteration " + iteration + " in worker " + index); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestDeputy.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestDeputy.java index 87909e3b786..ca24db2d83c 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestDeputy.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestDeputy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Evolveum + * Copyright (c) 2016-2017 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -71,7 +71,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); PrismObject userJack = getUser(USER_JACK_OID); display("User Jack", userJack); @@ -93,18 +93,18 @@ public void test000Sanity() throws Exception { @Test public void test100AssignDeputyNoBigDeal() throws Exception { final String TEST_NAME = "test100AssignDeputyNoBigDeal"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); - Task task = taskManager.createTaskInstance(TestDeputy.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); assignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -130,18 +130,18 @@ public void test100AssignDeputyNoBigDeal() throws Exception { @Test public void test109UnassignDeputyNoBigDeal() throws Exception { final String TEST_NAME = "test109UnassignDeputyNoBigDeal"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); - Task task = taskManager.createTaskInstance(TestDeputy.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); unassignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -166,18 +166,18 @@ public void test109UnassignDeputyNoBigDeal() throws Exception { @Test public void test110AssignJackPirate() throws Exception { final String TEST_NAME = "test110AssignJackPirate"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); - Task task = taskManager.createTaskInstance(TestDeputy.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); assignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -204,18 +204,18 @@ public void test110AssignJackPirate() throws Exception { @Test public void test112AssignDeputyPirate() throws Exception { final String TEST_NAME = "test112AssignDeputyPirate"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); - Task task = taskManager.createTaskInstance(TestDeputy.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); assignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -247,18 +247,18 @@ public void test112AssignDeputyPirate() throws Exception { @Test public void test119UnassignDeputyPirate() throws Exception { final String TEST_NAME = "test119UnassignDeputyPirate"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); - Task task = taskManager.createTaskInstance(TestDeputy.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); unassignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -285,9 +285,9 @@ public void test119UnassignDeputyPirate() throws Exception { @Test public void test120AssignbarbossaDeputyOfGuybrush() throws Exception { final String TEST_NAME = "test120AssignbarbossaDeputyOfGuybrush"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); - Task task = taskManager.createTaskInstance(TestDeputy.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); PrismObject userGuybrushBefore = getUser(USER_GUYBRUSH_OID); @@ -295,12 +295,12 @@ public void test120AssignbarbossaDeputyOfGuybrush() throws Exception { assertLinks(userGuybrushBefore, 1); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); assignDeputy(USER_BARBOSSA_OID, USER_GUYBRUSH_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -328,18 +328,18 @@ public void test120AssignbarbossaDeputyOfGuybrush() throws Exception { @Test public void test122AssignGuybrushPirate() throws Exception { final String TEST_NAME = "test122AssignGuybrushPirate"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); - Task task = taskManager.createTaskInstance(TestDeputy.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); assignRole(USER_GUYBRUSH_OID, ROLE_PIRATE_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -367,18 +367,18 @@ public void test122AssignGuybrushPirate() throws Exception { @Test public void test124RecomputeBarbossa() throws Exception { final String TEST_NAME = "test124RecomputeBarbossa"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); - Task task = taskManager.createTaskInstance(TestDeputy.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); recomputeUser(USER_BARBOSSA_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -408,18 +408,18 @@ public void test124RecomputeBarbossa() throws Exception { @Test public void test126UnassignGuybrushPirate() throws Exception { final String TEST_NAME = "test126UnassignGuybrushPirate"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); - Task task = taskManager.createTaskInstance(TestDeputy.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); unassignRole(USER_GUYBRUSH_OID, ROLE_PIRATE_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -446,19 +446,19 @@ public void test126UnassignGuybrushPirate() throws Exception { @Test public void test128RecomputeBarbossa() throws Exception { final String TEST_NAME = "test128RecomputeBarbossa"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); - Task task = taskManager.createTaskInstance(TestDeputy.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); recomputeUser(USER_BARBOSSA_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -480,18 +480,18 @@ public void test128RecomputeBarbossa() throws Exception { @Test public void test129UnassignBarbossaDeputyOfGuybrush() throws Exception { final String TEST_NAME = "test129UnassignBarbossaDeputyOfGuybrush"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); - Task task = taskManager.createTaskInstance(TestDeputy.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); unassignDeputy(USER_BARBOSSA_OID, USER_GUYBRUSH_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -516,9 +516,9 @@ public void test129UnassignBarbossaDeputyOfGuybrush() throws Exception { @Test public void test150AssignJackMoreRoles() throws Exception { final String TEST_NAME = "test150AssignJackMoreRoles"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); - Task task = taskManager.createTaskInstance(TestDeputy.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); ObjectDelta userDelta = createAssignmentUserDelta(USER_JACK_OID, ROLE_PIRATE_OID, RoleType.COMPLEX_TYPE, @@ -538,12 +538,12 @@ public void test150AssignJackMoreRoles() throws Exception { null, null, (ActivationType) null, true))); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); modelService.executeChanges(MiscSchemaUtil.createCollection(userDelta), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -570,20 +570,20 @@ public void test150AssignJackMoreRoles() throws Exception { @Test public void test152AssignbarbossaDeputyLimitedDeputy() throws Exception { final String TEST_NAME = "test152AssignbarbossaDeputyLimitedDeputy"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); - Task task = taskManager.createTaskInstance(TestDeputy.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); assignDeputyLimits(USER_BARBOSSA_OID, USER_JACK_OID, task, result, createRoleReference(ROLE_PIRATE_OID), createOrgReference(ORG_MINISTRY_OF_RUM_OID, SchemaConstants.ORG_MANAGER)); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -607,20 +607,20 @@ public void test152AssignbarbossaDeputyLimitedDeputy() throws Exception { @Test public void test154UnassignbarbossaDeputyLimitedDeputy() throws Exception { final String TEST_NAME = "test154UnassignbarbossaDeputyLimitedDeputy"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); - Task task = taskManager.createTaskInstance(TestDeputy.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); unassignDeputyLimits(USER_BARBOSSA_OID, USER_JACK_OID, task, result, createRoleReference(ROLE_PIRATE_OID), createOrgReference(ORG_MINISTRY_OF_RUM_OID, SchemaConstants.ORG_MANAGER)); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -641,13 +641,13 @@ public void test154UnassignbarbossaDeputyLimitedDeputy() throws Exception { @Test public void test156AssignbarbossaDeputyLimitedDeputyRed() throws Exception { final String TEST_NAME = "test156AssignbarbossaDeputyLimitedDeputyRed"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); - Task task = taskManager.createTaskInstance(TestDeputy.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); assignDeputyLimits(USER_BARBOSSA_OID, USER_JACK_OID, task, result, createRoleReference(ROLE_RED_SAILOR_OID), @@ -655,7 +655,7 @@ public void test156AssignbarbossaDeputyLimitedDeputyRed() throws Exception { ); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -679,16 +679,16 @@ public void test156AssignbarbossaDeputyLimitedDeputyRed() throws Exception { @Test public void test159UnassignbarbossaDeputyLimitedDeputyRed() throws Exception { final String TEST_NAME = "test159UnassignbarbossaDeputyLimitedDeputyRed"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); - Task task = taskManager.createTaskInstance(TestDeputy.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); unassignDeputyLimits(USER_BARBOSSA_OID, USER_JACK_OID, task, result, createRoleReference(ROLE_RED_SAILOR_OID), @@ -696,7 +696,7 @@ public void test159UnassignbarbossaDeputyLimitedDeputyRed() throws Exception { ); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -721,20 +721,20 @@ public void test159UnassignbarbossaDeputyLimitedDeputyRed() throws Exception { @Test public void test160AssignbarbossaDeputyLimitedDeputyEmpty() throws Exception { final String TEST_NAME = "test160AssignbarbossaDeputyLimitedDeputyEmpty"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); - Task task = taskManager.createTaskInstance(TestDeputy.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); assignDeputyLimits(USER_BARBOSSA_OID, USER_JACK_OID, task, result, createRoleReference(ROLE_EMPTY_OID) ); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -758,23 +758,23 @@ public void test160AssignbarbossaDeputyLimitedDeputyEmpty() throws Exception { @Test public void test162UnassignbarbossaDeputyLimitedDeputyEmpty() throws Exception { final String TEST_NAME = "test162UnassignbarbossaDeputyLimitedDeputyEmpty"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); - Task task = taskManager.createTaskInstance(TestDeputy.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); unassignDeputyLimits(USER_BARBOSSA_OID, USER_JACK_OID, task, result, createRoleReference(ROLE_EMPTY_OID) ); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -799,20 +799,20 @@ public void test162UnassignbarbossaDeputyLimitedDeputyEmpty() throws Exception { @Test public void test170AddRoleDrinker() throws Exception { final String TEST_NAME = "test170AssignJackRoleDrinker"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); - Task task = taskManager.createTaskInstance(TestDeputy.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); PrismObject role = PrismTestUtil.parseObject(ROLE_DRINKER_FILE); display("Adding role", role); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); addObject(role, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -825,17 +825,17 @@ public void test170AddRoleDrinker() throws Exception { @Test public void test172AssignJackRoleDrinker() throws Exception { final String TEST_NAME = "test170AssignJackRoleDrinker"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); - Task task = taskManager.createTaskInstance(TestDeputy.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); assignRole(USER_JACK_OID, ROLE_DRINKER_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -856,20 +856,20 @@ public void test172AssignJackRoleDrinker() throws Exception { @Test public void test172AssignbarbossaDeputyLimitedDeputyDrinker() throws Exception { final String TEST_NAME = "test172AssignbarbossaDeputyLimitedDeputyDrinker"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); - Task task = taskManager.createTaskInstance(TestDeputy.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); assignDeputyLimits(USER_BARBOSSA_OID, USER_JACK_OID, task, result, createRoleReference(ROLE_DRINKER_OID) ); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -885,23 +885,23 @@ public void test172AssignbarbossaDeputyLimitedDeputyDrinker() throws Exception { @Test public void test178UnassignbarbossaDeputyLimitedDeputyDrinker() throws Exception { final String TEST_NAME = "test178UnassignbarbossaDeputyLimitedDeputyDrinker"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); - Task task = taskManager.createTaskInstance(TestDeputy.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); unassignDeputyLimits(USER_BARBOSSA_OID, USER_JACK_OID, task, result, createRoleReference(ROLE_DRINKER_OID) ); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -926,13 +926,13 @@ public void test178UnassignbarbossaDeputyLimitedDeputyDrinker() throws Exception @Test public void test180AssignbarbossaDeputyLimitedDeputyEmptyDrinker() throws Exception { final String TEST_NAME = "test180AssignbarbossaDeputyLimitedDeputyEmptyDrinker"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); - Task task = taskManager.createTaskInstance(TestDeputy.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); assignDeputyLimits(USER_BARBOSSA_OID, USER_JACK_OID, task, result, createRoleReference(ROLE_EMPTY_OID), @@ -940,7 +940,7 @@ public void test180AssignbarbossaDeputyLimitedDeputyEmptyDrinker() throws Except ); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -964,16 +964,16 @@ public void test180AssignbarbossaDeputyLimitedDeputyEmptyDrinker() throws Except @Test public void test182UnassignbarbossaDeputyLimitedDeputyEmptyDrinker() throws Exception { final String TEST_NAME = "test182UnassignbarbossaDeputyLimitedDeputyEmptyDrinker"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); - Task task = taskManager.createTaskInstance(TestDeputy.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); unassignDeputyLimits(USER_BARBOSSA_OID, USER_JACK_OID, task, result, createRoleReference(ROLE_EMPTY_OID), @@ -981,9 +981,8 @@ public void test182UnassignbarbossaDeputyLimitedDeputyEmptyDrinker() throws Exce ); // THEN - TestUtil.displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); + displayThen(TEST_NAME); + assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -1007,7 +1006,7 @@ public void test182UnassignbarbossaDeputyLimitedDeputyEmptyDrinker() throws Exce @Test public void test800ImportValidityScannerTask() throws Exception { final String TEST_NAME = "test800ImportValidityScannerTask"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TestValidityRecomputeTask.class.getName() + "." + TEST_NAME); @@ -1016,14 +1015,14 @@ public void test800ImportValidityScannerTask() throws Exception { XMLGregorianCalendar startCal = clock.currentTimeXMLGregorianCalendar(); /// WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); importObjectFromFile(TASK_VALIDITY_SCANNER_FILENAME); waitForTaskStart(TASK_VALIDITY_SCANNER_OID, false); waitForTaskFinish(TASK_VALIDITY_SCANNER_OID, true); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); assertLastRecomputeTimestamp(TASK_VALIDITY_SCANNER_OID, startCal, endCal); } @@ -1035,9 +1034,9 @@ public void test800ImportValidityScannerTask() throws Exception { @Test public void test802AssignBarbossaDeputyOfJack() throws Exception { final String TEST_NAME = "test802AssignBarbossaDeputyOfJack"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); - Task task = taskManager.createTaskInstance(TestDeputy.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); PrismObject userJackBefore = getUser(USER_JACK_OID); @@ -1052,15 +1051,14 @@ public void test802AssignBarbossaDeputyOfJack() throws Exception { activationType.setValidTo(XmlTypeConverter.addDuration(startTs, "PT2H")); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); assignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, assignment -> assignment.setActivation(activationType), task, result); // THEN - TestUtil.displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); + displayThen(TEST_NAME); + assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -1085,15 +1083,14 @@ public void test802AssignBarbossaDeputyOfJack() throws Exception { } /** - * Assign Barbossa as Jack's deputy. Barbossa should have all the privileges now. - * But they will expire soon ... + * Assign Barbossa as Jack's deputy. Barbossa privileges are about to expire. */ @Test public void test804BarbosaThreeHoursLater() throws Exception { final String TEST_NAME = "test804BarbosaThreeHoursLater"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); - Task task = taskManager.createTaskInstance(TestDeputy.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); clock.overrideDuration("PT3H"); @@ -1101,14 +1098,13 @@ public void test804BarbosaThreeHoursLater() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); waitForTaskNextRunAssertSuccess(TASK_VALIDITY_SCANNER_OID, true); // THEN - TestUtil.displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); + displayThen(TEST_NAME); + assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIntent.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIntent.java index 00c3aeaf7f1..64cf9f33acd 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIntent.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIntent.java @@ -67,10 +67,10 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test131ModifyUserJackAssignAccountDefault() throws Exception { final String TEST_NAME="test131ModifyUserJackAssignAccountDefault"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); // GIVEN - Task task = taskManager.createTaskInstance(TestIntent.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.RELATIVE); @@ -128,10 +128,10 @@ public void test131ModifyUserJackAssignAccountDefault() throws Exception { @Test public void test132ModifyUserJackAssignAccountTest() throws Exception { final String TEST_NAME="test132ModifyUserJackAssignAccountTest"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); // GIVEN - Task task = taskManager.createTaskInstance(TestIntent.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.RELATIVE); @@ -202,10 +202,10 @@ public void test132ModifyUserJackAssignAccountTest() throws Exception { @Test public void test135ModifyUserJackFullName() throws Exception { final String TEST_NAME="test135ModifyUserJackFullName"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); // GIVEN - Task task = taskManager.createTaskInstance(TestIntent.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.RELATIVE); @@ -265,10 +265,10 @@ public void test135ModifyUserJackFullName() throws Exception { @Test public void test147ModifyUserJackUnAssignAccountDefault() throws Exception { final String TEST_NAME="test147ModifyUserJackUnAssignAccountDefault"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); // GIVEN - Task task = taskManager.createTaskInstance(TestIntent.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.RELATIVE); @@ -326,10 +326,10 @@ public void test147ModifyUserJackUnAssignAccountDefault() throws Exception { @Test public void test149ModifyUserJackUnassignAccountTest() throws Exception { final String TEST_NAME = "test149ModifyUserJackUnassignAccountTest"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); // GIVEN - Task task = taskManager.createTaskInstance(TestIntent.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.RELATIVE); @@ -342,8 +342,7 @@ public void test149ModifyUserJackUnassignAccountTest() throws Exception { modelService.executeChanges(deltas, null, task, result); // THEN - result.computeStatus(); - TestUtil.assertSuccess("executeChanges result", result); + assertSuccess(result); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0); PrismObject userJack = getUser(USER_JACK_OID); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestMapping.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestMapping.java index 0565e5318de..a454e33ee2d 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestMapping.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestMapping.java @@ -326,7 +326,8 @@ accountOid, getDummyResourceController(RESOURCE_DUMMY_BLUE_NAME).getAttributePat dummyAuditService.assertSimpleRecordSanity(); dummyAuditService.assertRecords(2); dummyAuditService.assertAnyRequestDeltas(); - dummyAuditService.assertExecutionDeltas(1); + dummyAuditService.assertExecutionDeltas(2); + dummyAuditService.assertHasDelta(ChangeType.MODIFY, UserType.class); dummyAuditService.assertHasDelta(ChangeType.MODIFY, ShadowType.class); dummyAuditService.assertExecutionSuccess(); } @@ -371,7 +372,8 @@ accountOid, getDummyResourceController(RESOURCE_DUMMY_BLUE_NAME).getAttributePat dummyAuditService.assertSimpleRecordSanity(); dummyAuditService.assertRecords(2); dummyAuditService.assertAnyRequestDeltas(); - dummyAuditService.assertExecutionDeltas(1); + dummyAuditService.assertExecutionDeltas(2); + dummyAuditService.assertHasDelta(ChangeType.MODIFY, UserType.class); dummyAuditService.assertHasDelta(ChangeType.MODIFY, ShadowType.class); dummyAuditService.assertExecutionSuccess(); } @@ -412,7 +414,8 @@ accountOid, getDummyResourceController(RESOURCE_DUMMY_BLUE_NAME).getAttributePat dummyAuditService.assertSimpleRecordSanity(); dummyAuditService.assertRecords(2); dummyAuditService.assertAnyRequestDeltas(); - dummyAuditService.assertExecutionDeltas(1); + dummyAuditService.assertExecutionDeltas(2); + dummyAuditService.assertHasDelta(ChangeType.MODIFY, UserType.class); dummyAuditService.assertHasDelta(ChangeType.MODIFY, ShadowType.class); dummyAuditService.assertExecutionSuccess(); } @@ -457,7 +460,8 @@ accountOid, getDummyResourceController(RESOURCE_DUMMY_BLUE_NAME).getAttributePat dummyAuditService.assertSimpleRecordSanity(); dummyAuditService.assertRecords(2); dummyAuditService.assertAnyRequestDeltas(); - dummyAuditService.assertExecutionDeltas(1); + dummyAuditService.assertExecutionDeltas(2); + dummyAuditService.assertHasDelta(ChangeType.MODIFY, UserType.class); dummyAuditService.assertHasDelta(ChangeType.MODIFY, ShadowType.class); dummyAuditService.assertExecutionSuccess(); } @@ -717,7 +721,8 @@ accountOid, getDummyResourceController(RESOURCE_DUMMY_RED_NAME).getAttributePath dummyAuditService.assertSimpleRecordSanity(); dummyAuditService.assertRecords(2); dummyAuditService.assertAnyRequestDeltas(); - dummyAuditService.assertExecutionDeltas(1); + dummyAuditService.assertExecutionDeltas(2); + dummyAuditService.assertHasDelta(ChangeType.MODIFY, UserType.class); dummyAuditService.assertHasDelta(ChangeType.MODIFY, ShadowType.class); dummyAuditService.assertExecutionSuccess(); } @@ -907,7 +912,7 @@ public void test139DeleteAccountRed() throws Exception { dummyAuditService.assertSimpleRecordSanity(); dummyAuditService.assertRecords(2); dummyAuditService.assertAnyRequestDeltas(); - dummyAuditService.assertExecutionDeltas(2); + dummyAuditService.assertExecutionDeltas(3); dummyAuditService.assertHasDelta(ChangeType.MODIFY, UserType.class); dummyAuditService.assertHasDelta(ChangeType.DELETE, ShadowType.class); dummyAuditService.assertExecutionSuccess(); @@ -1130,7 +1135,8 @@ public void test144ModifyAccountLocationReplaceEmpty() throws Exception { dummyAuditService.assertSimpleRecordSanity(); dummyAuditService.assertRecords(2); dummyAuditService.assertAnyRequestDeltas(); - dummyAuditService.assertExecutionDeltas(1); + dummyAuditService.assertExecutionDeltas(2); + dummyAuditService.assertHasDelta(ChangeType.MODIFY, UserType.class); dummyAuditService.assertHasDelta(ChangeType.MODIFY, ShadowType.class); dummyAuditService.assertExecutionSuccess(); } diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelServiceContract.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelServiceContract.java index 6f24030504b..798190b5eae 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelServiceContract.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelServiceContract.java @@ -258,8 +258,7 @@ public void test100ModifyUserAddAccount() throws Exception { // THEN displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); + assertSuccess(result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0); @@ -295,7 +294,7 @@ public void test100ModifyUserAddAccount() throws Exception { dummyAuditService.assertRecords(2); dummyAuditService.assertSimpleRecordSanity(); dummyAuditService.assertAnyRequestDeltas(); - dummyAuditService.assertExecutionDeltas(2); + dummyAuditService.assertExecutionDeltas(3); // lastProvisioningTimestamp, add account, link dummyAuditService.assertHasDelta(ChangeType.MODIFY, UserType.class); dummyAuditService.assertHasDelta(ChangeType.ADD, ShadowType.class); dummyAuditService.assertTarget(USER_JACK_OID); @@ -358,8 +357,7 @@ public void test101GetAccount() throws Exception { display("Account attributes def complex type def", accountContainer.getDefinition().getComplexTypeDefinition()); assertDummyAccountShadowModel(account, accountJackOid, "jack", "Jack Sparrow"); - result.computeStatus(); - TestUtil.assertSuccess("getObject result", result); + assertSuccess("getObject result", result); account.checkConsistence(true, true, ConsistencyCheckScope.THOROUGH); @@ -414,8 +412,7 @@ public void test102GetAccountNoFetch() throws Exception { display("Account attributes def complex type def", accountContainer.getDefinition().getComplexTypeDefinition()); assertDummyAccountShadowRepo(account, accountJackOid, "jack"); - result.computeStatus(); - TestUtil.assertSuccess("getObject result", result); + assertSuccess("getObject result", result); assertSteadyResources(); } @@ -442,8 +439,7 @@ public void test103GetAccountRaw() throws Exception { display("Account attributes def complex type def", accountContainer.getDefinition().getComplexTypeDefinition()); assertDummyAccountShadowRepo(account, accountJackOid, "jack"); - result.computeStatus(); - TestUtil.assertSuccess("getObject result", result); + assertSuccess("getObject result", result); assertSteadyResources(); } @@ -785,7 +781,7 @@ public void test119ModifyUserDeleteAccount() throws Exception { dummyAuditService.assertRecords(2); dummyAuditService.assertSimpleRecordSanity(); dummyAuditService.assertAnyRequestDeltas(); - dummyAuditService.assertExecutionDeltas(2); + dummyAuditService.assertExecutionDeltas(3); // lastProvisioningTimestamp, delete account, unlink dummyAuditService.assertHasDelta(ChangeType.MODIFY, UserType.class); dummyAuditService.assertHasDelta(ChangeType.DELETE, ShadowType.class); dummyAuditService.assertTarget(USER_JACK_OID); @@ -898,8 +894,7 @@ public void test121ModifyUserAddAccountRef() throws Exception { modelService.executeChanges(deltas, null, task, result); // THEN - result.computeStatus(); - TestUtil.assertSuccess("executeChanges result", result); + assertSuccess(result); // There is strong mapping. Complete account is fetched. assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 1); @@ -924,7 +919,7 @@ public void test121ModifyUserAddAccountRef() throws Exception { dummyAuditService.assertRecords(2); dummyAuditService.assertSimpleRecordSanity(); dummyAuditService.assertAnyRequestDeltas(); - dummyAuditService.assertExecutionDeltas(2); + dummyAuditService.assertExecutionDeltas(3); // lastProvisioningTimestamp, modify account, link dummyAuditService.assertHasDelta(ChangeType.MODIFY, UserType.class); dummyAuditService.assertHasDelta(ChangeType.MODIFY, ShadowType.class); dummyAuditService.assertTarget(USER_JACK_OID); @@ -1256,7 +1251,8 @@ public void test132ModifyAccountJackDummy() throws Exception { dummyAuditService.assertRecords(3); dummyAuditService.assertAnyRequestDeltas(); - dummyAuditService.assertExecutionDeltas(0, 1); + dummyAuditService.assertExecutionDeltas(0, 2); // lastProvisioningTimestamp, modify account + dummyAuditService.assertHasDelta(0, ChangeType.MODIFY, UserType.class); dummyAuditService.assertHasDelta(0, ChangeType.MODIFY, ShadowType.class); dummyAuditService.assertOldValue(0, ChangeType.MODIFY, ShadowType.class, dummyResourceCtl.getAttributeFullnamePath(), "Jack Sparrow"); @@ -1669,8 +1665,7 @@ public void test149ModifyUserJackDeleteAccount() throws Exception { modelService.executeChanges(deltas, null, task, result); // THEN - result.computeStatus(); - TestUtil.assertSuccess("executeChanges result", result); + assertSuccess(result); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0); PrismObject userJack = getUser(USER_JACK_OID); @@ -1691,7 +1686,7 @@ public void test149ModifyUserJackDeleteAccount() throws Exception { dummyAuditService.assertSimpleRecordSanity(); dummyAuditService.assertRecords(2); dummyAuditService.assertAnyRequestDeltas(); - dummyAuditService.assertExecutionDeltas(2); + dummyAuditService.assertExecutionDeltas(3); // lastProvisioningTimestamp, delete account, unlink dummyAuditService.assertHasDelta(ChangeType.MODIFY, UserType.class); dummyAuditService.assertHasDelta(ChangeType.DELETE, ShadowType.class); dummyAuditService.assertTarget(USER_JACK_OID); @@ -1949,8 +1944,7 @@ public void test163ModifyUserJackAddAccountNoneEnforcement() throws Exception { modelService.executeChanges(deltas, null, task, result); // THEN - result.computeStatus(); - TestUtil.assertSuccess("executeChanges result", result); + assertSuccess(result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0); @@ -1979,7 +1973,7 @@ public void test163ModifyUserJackAddAccountNoneEnforcement() throws Exception { dummyAuditService.assertRecords(2); dummyAuditService.assertSimpleRecordSanity(); dummyAuditService.assertAnyRequestDeltas(); - dummyAuditService.assertExecutionDeltas(2); + dummyAuditService.assertExecutionDeltas(3); // lastProvisioningTimestamp, add account, link dummyAuditService.assertHasDelta(ChangeType.MODIFY, UserType.class); dummyAuditService.assertHasDelta(ChangeType.ADD, ShadowType.class); dummyAuditService.assertTarget(USER_JACK_OID); @@ -2091,8 +2085,7 @@ public void test169ModifyUserJackDeleteAccountNoneEnforcement() throws Exception modelService.executeChanges(deltas, null, task, result); // THEN - result.computeStatus(); - TestUtil.assertSuccess("executeChanges result", result); + assertSuccess(result); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0); PrismObject userJack = getUser(USER_JACK_OID); @@ -2113,7 +2106,7 @@ public void test169ModifyUserJackDeleteAccountNoneEnforcement() throws Exception dummyAuditService.assertSimpleRecordSanity(); dummyAuditService.assertRecords(2); dummyAuditService.assertAnyRequestDeltas(); - dummyAuditService.assertExecutionDeltas(2); + dummyAuditService.assertExecutionDeltas(3); // lastProvisioningTimestamp, delete account, unlink dummyAuditService.assertHasDelta(ChangeType.MODIFY, UserType.class); dummyAuditService.assertHasDelta(ChangeType.DELETE, ShadowType.class); dummyAuditService.assertTarget(USER_JACK_OID); @@ -3242,8 +3235,7 @@ accountJackBlueOid, getDummyResourceController(RESOURCE_DUMMY_BLUE_NAME).getAttr modelService.executeChanges(deltas, options, task, result); // THEN - result.computeStatus(); - TestUtil.assertSuccess("executeChanges result", result); + assertSuccess(result); // Not sure why 2 ... but this is not a big problem now assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 2); @@ -3271,7 +3263,8 @@ accountJackBlueOid, getDummyResourceController(RESOURCE_DUMMY_BLUE_NAME).getAttr dummyAuditService.assertRecords(2); dummyAuditService.assertAnyRequestDeltas(); - dummyAuditService.assertExecutionDeltas(0, 1); + dummyAuditService.assertExecutionDeltas(0, 2); // lastProvisioningTimestamp, modify account + dummyAuditService.assertHasDelta(0, ChangeType.MODIFY, UserType.class); dummyAuditService.assertHasDelta(0, ChangeType.MODIFY, ShadowType.class); dummyAuditService.assertOldValue(0, ChangeType.MODIFY, ShadowType.class, getDummyResourceController(RESOURCE_DUMMY_BLUE_NAME).getAttributeFullnamePath(), "Jack Sparrow"); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestMultiResource.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestMultiResource.java index 687578046c2..367371e8017 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestMultiResource.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestMultiResource.java @@ -273,7 +273,7 @@ public void test120JackAssignRoleDummiesRelative() throws Exception { getDummyResource().resetBreakMode(); // Clean up user - Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); modifyUserReplace(USER_JACK_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result); @@ -292,7 +292,7 @@ public void test121JackTryDeleteAccount() throws Exception { getDummyResource().resetBreakMode(); // Clean up user - Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); PrismObject userJack = getUser(USER_JACK_OID); String accountJackDummyOid = getLinkRefOid(userJack, RESOURCE_DUMMY_OID); @@ -333,7 +333,7 @@ public void test200JackAssignDummyIvory() throws Exception { final String TEST_NAME = "test200JackAssignDummyIvory"; // GIVEN - Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -367,7 +367,7 @@ public void test209JackUnAssignDummyIvory() throws Exception { final String TEST_NAME = "test209JackUnAssignDummyIvory"; // GIVEN - Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -397,10 +397,10 @@ public void test209JackUnAssignDummyIvory() throws Exception { @Test public void test210JackAssignDummyBeige() throws Exception { final String TEST_NAME = "test210JackAssignDummyBeige"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); // GIVEN - Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -408,11 +408,11 @@ public void test210JackAssignDummyBeige() throws Exception { modifyUserReplace(USER_JACK_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); assignAccount(USER_JACK_OID, RESOURCE_DUMMY_BEIGE_OID, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -435,10 +435,10 @@ public void test210JackAssignDummyBeige() throws Exception { @Test public void test219JackUnAssignDummyBeige() throws Exception { final String TEST_NAME = "test219JackUnAssignDummyBeige"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); // GIVEN - Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -446,11 +446,11 @@ public void test219JackUnAssignDummyBeige() throws Exception { modifyUserReplace(USER_JACK_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); unassignAccount(USER_JACK_OID, RESOURCE_DUMMY_BEIGE_OID, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -470,10 +470,10 @@ public void test219JackUnAssignDummyBeige() throws Exception { @Test public void test220JackAssignDummyBeigeAndDefault() throws Exception { final String TEST_NAME = "test220JackAssignDummyBeigeAndDefault"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); // GIVEN - Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -484,11 +484,11 @@ public void test220JackAssignDummyBeigeAndDefault() throws Exception { userDelta.addModification(createAssignmentModification(RESOURCE_DUMMY_OID, ShadowKindType.ACCOUNT, null, true)); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); executeChanges(userDelta, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -510,18 +510,18 @@ public void test220JackAssignDummyBeigeAndDefault() throws Exception { @Test public void test221JackRecompute() throws Exception { final String TEST_NAME = "test221JackRecompute"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); // GIVEN - Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); recomputeUser(USER_JACK_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -539,27 +539,27 @@ public void test221JackRecompute() throws Exception { /** * Delete account on default dummy resource (but keep it assigned and keep the shadow). - * The recompute the user. The account should be re-created. + * Then recompute the user. The account should be re-created. * MID-2134, MID-3093 */ @Test public void test223JackKillDefaultDummyAccounAndRecompute() throws Exception { final String TEST_NAME = "test223JackKillDefaultDummyAccounAndRecompute"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); // GIVEN - Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); getDummyResource().deleteAccountByName(ACCOUNT_JACK_DUMMY_USERNAME); display("dummy resource before", getDummyResource()); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); recomputeUser(USER_JACK_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -586,21 +586,21 @@ public void test223JackKillDefaultDummyAccounAndRecompute() throws Exception { @Test public void test224JackKillBeigeAccounAndRecompute() throws Exception { final String TEST_NAME = "test224JackKillBeigeAccounAndRecompute"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); // GIVEN - Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); dummyResourceBeige.deleteAccountByName(ACCOUNT_JACK_DUMMY_USERNAME); display("beige dummy resource before", dummyResourceBeige); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); recomputeUser(USER_JACK_OID, ModelExecuteOptions.createReconcile(), task, result); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -620,16 +620,16 @@ public void test224JackKillBeigeAccounAndRecompute() throws Exception { /** * Delete both accounts on beige and default dummy resource (but keep it assigned and keep the shadows). - * The recompute the user. The accounts should be re-created. + * Then recompute the user. The accounts should be re-created. * MID-2134, MID-3093 */ @Test public void test225JackKillBothAccounsAndRecompute() throws Exception { final String TEST_NAME = "test225JackKillBothAccounsAndRecompute"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); // GIVEN - Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); getDummyResource().deleteAccountByName(ACCOUNT_JACK_DUMMY_USERNAME); @@ -639,13 +639,12 @@ public void test225JackKillBothAccounsAndRecompute() throws Exception { display("beige dummy resource before", dummyResourceBeige); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); recomputeUser(USER_JACK_OID, ModelExecuteOptions.createReconcile(), task, result); // THEN - TestUtil.displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); + displayThen(TEST_NAME); + assertSuccess(result); PrismObject userJack = getUser(USER_JACK_OID); assertLinks(userJack, 2); @@ -671,7 +670,7 @@ public void test225JackKillBothAccounsAndRecompute() throws Exception { @Test public void test227ModifyUserJackDefaultDummyBrokenSchemaViolation() throws Exception { final String TEST_NAME = "test227ModifyUserJackDefaultDummyBrokenSchemaViolation"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestMultiResource.class.getName() + "." + TEST_NAME); @@ -681,12 +680,12 @@ public void test227ModifyUserJackDefaultDummyBrokenSchemaViolation() throws Exce getDummyResource().setModifyBreakMode(BreakMode.SCHEMA); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); modifyUserReplace(USER_JACK_OID, UserType.F_FULL_NAME, task, result, new PolyString("Cpt. Jack Sparrow", null)); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); display("Result", result); TestUtil.assertPartialError(result); @@ -715,7 +714,7 @@ public void test227ModifyUserJackDefaultDummyBrokenSchemaViolation() throws Exce @Test public void test228ModifyUserJackDefaultDummyNoError() throws Exception { final String TEST_NAME = "test228ModifyUserJackDefaultDummyNoError"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestMultiResource.class.getName() + "." + TEST_NAME); @@ -724,12 +723,12 @@ public void test228ModifyUserJackDefaultDummyNoError() throws Exception { getDummyResource().resetBreakMode(); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); modifyUserReplace(USER_JACK_OID, UserType.F_FULL_NAME, task, result, new PolyString(USER_JACK_FULL_NAME, null)); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); display("Result", result); TestUtil.assertSuccess(result); @@ -756,10 +755,10 @@ public void test228ModifyUserJackDefaultDummyNoError() throws Exception { @Test public void test229JackUnassignDummyBeigeAndDefault() throws Exception { final String TEST_NAME = "test229JackUnassignDummyBeigeAndDefault"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); // GIVEN - Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); getDummyResource().resetBreakMode(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -768,11 +767,11 @@ public void test229JackUnassignDummyBeigeAndDefault() throws Exception { userDelta.addModification(createAssignmentModification(RESOURCE_DUMMY_OID, ShadowKindType.ACCOUNT, null, false)); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); executeChanges(userDelta, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -792,10 +791,10 @@ public void test229JackUnassignDummyBeigeAndDefault() throws Exception { @Test public void test250JackAssignDummyLavender() throws Exception { final String TEST_NAME = "test250JackAssignDummyLavender"; - TestUtil.displayTestTitle(TEST_NAME); + displayTestTitle(TEST_NAME); // GIVEN - Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -829,9 +828,9 @@ public void test250JackAssignDummyLavender() throws Exception { * resource through the user to the other resource. If dependency does not work then no value is propagated. */ public void jackAssignRoleDummies(final String TEST_NAME) throws Exception { - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); - Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); clearJackOrganizationalUnit(task, result); @@ -874,9 +873,9 @@ public void jackAssignRoleDummies(final String TEST_NAME) throws Exception { } public void jackRename(final String TEST_NAME) throws Exception { - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); - Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); jackRename(TEST_NAME, "jackie", "Jackie Sparrow", task, result); @@ -891,11 +890,11 @@ public void jackRename(final String TEST_NAME, String toName, String toFullName, Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); modelService.executeChanges(deltas, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -932,9 +931,9 @@ public void jackRename(final String TEST_NAME, String toName, String toFullName, } public void jackUnAssignRoleDummies(final String TEST_NAME) throws Exception { - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); - Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); // WHEN @@ -962,9 +961,9 @@ public void jackUnAssignRoleDummies(final String TEST_NAME) throws Exception { */ public void jackAssignRoleDummiesError(final String TEST_NAME, String roleOid, String dummyResourceName, boolean expectAccount) throws Exception { - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); - Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); clearJackOrganizationalUnit(task, result); @@ -1003,17 +1002,17 @@ private void clearJackOrganizationalUnit(Task task, OperationResult result) thro } public void jackUnAssignRoleDummiesError(final String TEST_NAME, String roleOid) throws Exception { - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); - Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); unassignRole(USER_JACK_OID, roleOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); display(result); // there is a failure while reading dummy account - it was not created @@ -1038,10 +1037,10 @@ public void jackUnAssignRoleDummiesError(final String TEST_NAME, String roleOid) @Test public void test300AddAndAssignRelative() throws Exception { final String TEST_NAME = "test300AddAndAssignRelative"; - TestUtil.displayTestTitle(TEST_NAME); + displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); // Add default dummy account to jack without assigning it. @@ -1064,11 +1063,11 @@ public void test300AddAndAssignRelative() throws Exception { assertDefaultDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, true); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); assignAccount(USER_JACK_OID, RESOURCE_DUMMY_BLUE_OID, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1096,18 +1095,18 @@ public void test300AddAndAssignRelative() throws Exception { @Test public void test310AddedAccountAndUnassignRelative() throws Exception { final String TEST_NAME = "test310AddedAccountAndUnassignRelative"; - TestUtil.displayTestTitle(TEST_NAME); + displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); unassignAccount(USER_JACK_OID, RESOURCE_DUMMY_BLUE_OID, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1137,18 +1136,18 @@ public void test310AddedAccountAndUnassignRelative() throws Exception { @Test public void test319UnassignDummyRelative() throws Exception { final String TEST_NAME = "test319UnassignDummyRelative"; - TestUtil.displayTestTitle(TEST_NAME); + displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); unassignAccount(USER_JACK_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1173,17 +1172,17 @@ public void test319UnassignDummyRelative() throws Exception { @Test public void test350AddAccountLavender() throws Exception { final String TEST_NAME = "test350AddAccountLavender"; - TestUtil.displayTestTitle(TEST_NAME); + displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); - Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); ObjectDelta userDelta = createModifyUserAddAccount(USER_JACK_OID, resourceDummyLavender); // WHEN try { - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); modelService.executeChanges(MiscSchemaUtil.createCollection(userDelta), null, task, result); AssertJUnit.fail("Unexpected success"); @@ -1193,7 +1192,7 @@ public void test350AddAccountLavender() throws Exception { } // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertFailure(result); @@ -1204,20 +1203,20 @@ public void test350AddAccountLavender() throws Exception { @Test public void test352AddAccountIvory() throws Exception { final String TEST_NAME = "test352AddAccountIvory"; - TestUtil.displayTestTitle(TEST_NAME); + displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); - Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); ObjectDelta userDelta = createModifyUserAddAccount(USER_JACK_OID, resourceDummyIvory); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); modelService.executeChanges(MiscSchemaUtil.createCollection(userDelta), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1228,20 +1227,20 @@ public void test352AddAccountIvory() throws Exception { @Test public void test354AddAccountBeige() throws Exception { final String TEST_NAME = "test354AddAccountBeige"; - TestUtil.displayTestTitle(TEST_NAME); + displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); - Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); ObjectDelta userDelta = createModifyUserAddAccount(USER_JACK_OID, resourceDummyBeige); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); modelService.executeChanges(MiscSchemaUtil.createCollection(userDelta), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1252,20 +1251,20 @@ public void test354AddAccountBeige() throws Exception { @Test public void test360AddAccountDummy() throws Exception { final String TEST_NAME = "test360AddAccountDummy"; - TestUtil.displayTestTitle(TEST_NAME); + displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); - Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); ObjectDelta userDelta = createModifyUserAddAccount(USER_JACK_OID, getDummyResourceObject()); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); modelService.executeChanges(MiscSchemaUtil.createCollection(userDelta), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1279,20 +1278,20 @@ public void test360AddAccountDummy() throws Exception { @Test public void test362AddAccountLavender() throws Exception { final String TEST_NAME = "test362AddAccountLavender"; - TestUtil.displayTestTitle(TEST_NAME); + displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); - Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); ObjectDelta userDelta = createModifyUserAddAccount(USER_JACK_OID, resourceDummyLavender); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); modelService.executeChanges(MiscSchemaUtil.createCollection(userDelta), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1306,17 +1305,17 @@ public void test362AddAccountLavender() throws Exception { @Test public void test370DeleteAccountDummy() throws Exception { final String TEST_NAME = "test370DeleteAccountDummy"; - TestUtil.displayTestTitle(TEST_NAME); + displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); - Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); ObjectDelta userDelta = createModifyUserDeleteAccount(USER_JACK_OID, getDummyResourceObject()); // WHEN try { - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); modelService.executeChanges(MiscSchemaUtil.createCollection(userDelta), null, task, result); AssertJUnit.fail("Unexpected success"); @@ -1326,7 +1325,7 @@ public void test370DeleteAccountDummy() throws Exception { } // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertFailure(result); @@ -1343,17 +1342,17 @@ public void test370DeleteAccountDummy() throws Exception { @Test public void test372UnlinkAccountDummy() throws Exception { final String TEST_NAME = "test372UnlinkAccountDummy"; - TestUtil.displayTestTitle(TEST_NAME); + displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); - Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); ObjectDelta userDelta = createModifyUserUnlinkAccount(USER_JACK_OID, getDummyResourceObject()); // WHEN try { - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); modelService.executeChanges(MiscSchemaUtil.createCollection(userDelta), null, task, result); AssertJUnit.fail("Unexpected success"); @@ -1363,9 +1362,8 @@ public void test372UnlinkAccountDummy() throws Exception { } // THEN - TestUtil.displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertFailure(result); + displayThen(TEST_NAME); + assertFailure(result); PrismObject user = getUser(USER_JACK_OID); assertAccount(user, RESOURCE_DUMMY_OID); @@ -1377,21 +1375,20 @@ public void test372UnlinkAccountDummy() throws Exception { @Test public void test374DeleteAccountLavender() throws Exception { final String TEST_NAME = "test374DeleteAccountLavender"; - TestUtil.displayTestTitle(TEST_NAME); + displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); - Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); ObjectDelta userDelta = createModifyUserDeleteAccount(USER_JACK_OID, resourceDummyLavender); - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); modelService.executeChanges(MiscSchemaUtil.createCollection(userDelta), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); + displayThen(TEST_NAME); + assertSuccess(result); PrismObject user = getUser(USER_JACK_OID); assertAccount(user, RESOURCE_DUMMY_OID); @@ -1407,21 +1404,20 @@ public void test374DeleteAccountLavender() throws Exception { @Test public void test376DeleteAccountDummy() throws Exception { final String TEST_NAME = "test376DeleteAccountDummy"; - TestUtil.displayTestTitle(TEST_NAME); + displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); - Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); ObjectDelta userDelta = createModifyUserDeleteAccount(USER_JACK_OID, getDummyResourceObject()); - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); modelService.executeChanges(MiscSchemaUtil.createCollection(userDelta), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); + displayThen(TEST_NAME); + assertSuccess(result); assertNoDummyAccount(RESOURCE_DUMMY_LAVENDER_NAME, ACCOUNT_JACK_DUMMY_USERNAME); assertNoDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME); @@ -1434,21 +1430,20 @@ public void test376DeleteAccountDummy() throws Exception { @Test public void test378DeleteAccountBeige() throws Exception { final String TEST_NAME = "test378DeleteAccountBeige"; - TestUtil.displayTestTitle(TEST_NAME); + displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); - Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); ObjectDelta userDelta = createModifyUserDeleteAccount(USER_JACK_OID, resourceDummyBeige); - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); modelService.executeChanges(MiscSchemaUtil.createCollection(userDelta), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); + displayThen(TEST_NAME); + assertSuccess(result); assertNoDummyAccount(RESOURCE_DUMMY_LAVENDER_NAME, ACCOUNT_JACK_DUMMY_USERNAME); assertNoDummyAccount(RESOURCE_DUMMY_BEIGE_NAME, ACCOUNT_JACK_DUMMY_USERNAME); @@ -1462,21 +1457,20 @@ public void test378DeleteAccountBeige() throws Exception { @Test public void test379DeleteAccountIvory() throws Exception { final String TEST_NAME = "test379DeleteAccountIvory"; - TestUtil.displayTestTitle(TEST_NAME); + displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); - Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); ObjectDelta userDelta = createModifyUserDeleteAccount(USER_JACK_OID, resourceDummyIvory); - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); modelService.executeChanges(MiscSchemaUtil.createCollection(userDelta), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); + displayThen(TEST_NAME); + assertSuccess(result); assertNoDummyAccount(RESOURCE_DUMMY_LAVENDER_NAME, ACCOUNT_JACK_DUMMY_USERNAME); assertNoDummyAccount(RESOURCE_DUMMY_BEIGE_NAME, ACCOUNT_JACK_DUMMY_USERNAME); @@ -1491,26 +1485,25 @@ public void test379DeleteAccountIvory() throws Exception { @Test public void test380AddAccountPeru() throws Exception { final String TEST_NAME = "test380AddAccountPeru"; - TestUtil.displayTestTitle(TEST_NAME); + displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); getDummyResource().resetBreakMode(); // precondition assertEncryptedUserPassword(USER_JACK_OID, USER_JACK_PASSWORD); - Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); ObjectDelta userDelta = createModifyUserAddAccount(USER_JACK_OID, resourceDummyPeru); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); modelService.executeChanges(MiscSchemaUtil.createCollection(userDelta), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); + displayThen(TEST_NAME); + assertSuccess(result); assertDummyAccount(RESOURCE_DUMMY_PERU_NAME, ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, true); assertDummyPassword(RESOURCE_DUMMY_PERU_NAME, ACCOUNT_JACK_DUMMY_USERNAME, USER_JACK_PASSWORD); @@ -1519,22 +1512,21 @@ public void test380AddAccountPeru() throws Exception { @Test public void test382AddAccountYellow() throws Exception { final String TEST_NAME = "test382AddAccountYellow"; - TestUtil.displayTestTitle(TEST_NAME); + displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); - Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); ObjectDelta userDelta = createModifyUserAddAccount(USER_JACK_OID, getDummyResourceObject(RESOURCE_DUMMY_YELLOW_NAME)); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); modelService.executeChanges(MiscSchemaUtil.createCollection(userDelta), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); + displayThen(TEST_NAME); + assertSuccess(result); PrismObject userJack = getUser(USER_JACK_OID); display("User after change execution", userJack); @@ -1556,7 +1548,7 @@ public void test382AddAccountYellow() throws Exception { @Test public void test385ModifyUserJackPasswordA() throws Exception { final String TEST_NAME = "test385ModifyUserJackPasswordA"; - TestUtil.displayTestTitle(this, TEST_NAME); + displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(AbstractPasswordTest.class.getName() + "." + TEST_NAME); @@ -1567,8 +1559,7 @@ public void test385ModifyUserJackPasswordA() throws Exception { modifyUserChangePassword(USER_JACK_OID, USER_PASSWORD_A_CLEAR, task, result); // THEN - result.computeStatus(); - TestUtil.assertPartialError(result); + assertPartialError(result); PrismObject userJack = getUser(USER_JACK_OID); display("User after change execution", userJack); @@ -1590,21 +1581,20 @@ public void test385ModifyUserJackPasswordA() throws Exception { @Test public void test389DeleteAccountPeru() throws Exception { final String TEST_NAME = "test389DeleteAccountPeru"; - TestUtil.displayTestTitle(TEST_NAME); + displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); - Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); ObjectDelta userDelta = createModifyUserDeleteAccount(USER_JACK_OID, resourceDummyPeru); - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); modelService.executeChanges(MiscSchemaUtil.createCollection(userDelta), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); + displayThen(TEST_NAME); + assertSuccess(result); assertNoDummyAccount(RESOURCE_DUMMY_PERU_NAME, ACCOUNT_JACK_DUMMY_USERNAME); @@ -1618,12 +1608,12 @@ public void test389DeleteAccountPeru() throws Exception { @Test public void test400DavidAndGoliathAssignRole() throws Exception { final String TEST_NAME = "test400DavidAndGoliathAssignRole"; - TestUtil.displayTestTitle(TEST_NAME); + displayTestTitle(TEST_NAME); // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); PrismObject userBefore = createUser(USER_WORLD_NAME, USER_WORLD_FULL_NAME, true); @@ -1633,13 +1623,12 @@ public void test400DavidAndGoliathAssignRole() throws Exception { dummyAuditService.clear(); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); assignRole(userBefore.getOid(), ROLE_FIGHT_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); + displayThen(TEST_NAME); + assertSuccess(result); assertDavidGoliath(userBefore.getOid(), "stone", USER_WORLD_NAME, true, true, true); @@ -1663,7 +1652,7 @@ public void test400DavidAndGoliathAssignRole() throws Exception { ObjectDeltaOperation executionDeltaOp = dummyAuditService.getExecutionDelta(2, ChangeType.MODIFY, ShadowType.class); ObjectDelta executionDelta = executionDeltaOp.getObjectDelta(); display("Last execution delta", executionDelta); - PrismAsserts.assertModifications("Phantom changes in last delta:", executionDelta, 2); + PrismAsserts.assertModifications("Phantom changes in last delta:", executionDelta, 4); } private void assertDavidGoliath(String userOid, String ou, String name, boolean userEnabled, boolean davidEnabled, boolean goliathEnabled) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, SchemaViolationException, ConflictException, ExpressionEvaluationException { @@ -1705,25 +1694,24 @@ private void assertDavidGoliath(String userOid, String ou, String name, boolean @Test public void test401DavidAndGoliathModifyOu() throws Exception { final String TEST_NAME = "test401DavidAndGoliathModifyOu"; - TestUtil.displayTestTitle(TEST_NAME); + displayTestTitle(TEST_NAME); // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_WORLD_NAME); dummyAuditService.clear(); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); modifyUserReplace(userBefore.getOid(), UserType.F_ORGANIZATIONAL_UNIT, task, result, PrismTestUtil.createPolyString("rock")); // THEN - TestUtil.displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); + displayThen(TEST_NAME); + assertSuccess(result); assertDavidGoliath(userBefore.getOid(), "rock", USER_WORLD_NAME, true, true, true); @@ -1747,18 +1735,18 @@ public void test401DavidAndGoliathModifyOu() throws Exception { ObjectDeltaOperation executionDeltaOp = dummyAuditService.getExecutionDelta(2, ChangeType.MODIFY, ShadowType.class); ObjectDelta executionDelta = executionDeltaOp.getObjectDelta(); display("Last execution delta", executionDelta); - PrismAsserts.assertModifications("Phantom changes in last delta:", executionDelta, 2); + PrismAsserts.assertModifications("Phantom changes in last delta:", executionDelta, 4); } @Test public void test403DavidAndGoliathDisableUser() throws Exception { final String TEST_NAME = "test403DavidAndGoliathDisableUser"; - TestUtil.displayTestTitle(TEST_NAME); + displayTestTitle(TEST_NAME); // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_WORLD_NAME); @@ -1766,13 +1754,12 @@ public void test403DavidAndGoliathDisableUser() throws Exception { dummyAuditService.clear(); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); modifyUserReplace(userBefore.getOid(), ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.DISABLED); // THEN - TestUtil.displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); + displayThen(TEST_NAME); + assertSuccess(result); assertDavidGoliath(userBefore.getOid(), "rock", USER_WORLD_NAME, false, false, false); @@ -1784,7 +1771,8 @@ public void test403DavidAndGoliathDisableUser() throws Exception { dummyAuditService.assertExecutionDeltas(0,2); dummyAuditService.assertHasDelta(0,ChangeType.MODIFY, UserType.class); dummyAuditService.assertHasDelta(0,ChangeType.MODIFY, ShadowType.class); - dummyAuditService.assertExecutionDeltas(1,1); // user is again disabled here + dummyAuditService.assertExecutionDeltas(1,2); // user is again disabled here + dummyAuditService.assertHasDelta(1,ChangeType.MODIFY, UserType.class); // lastProvisioningTimestamp dummyAuditService.assertHasDelta(1,ChangeType.MODIFY, ShadowType.class); dummyAuditService.assertExecutionSuccess(); } @@ -1792,25 +1780,24 @@ public void test403DavidAndGoliathDisableUser() throws Exception { @Test public void test404DavidAndGoliathEnableUser() throws Exception { final String TEST_NAME = "test404DavidAndGoliathEnableUser"; - TestUtil.displayTestTitle(TEST_NAME); + displayTestTitle(TEST_NAME); // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_WORLD_NAME); dummyAuditService.clear(); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); modifyUserReplace(userBefore.getOid(), ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.ENABLED); // THEN - TestUtil.displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); + displayThen(TEST_NAME); + assertSuccess(result); assertDavidGoliath(userBefore.getOid(), "rock", USER_WORLD_NAME, true, true, true); @@ -1822,7 +1809,8 @@ public void test404DavidAndGoliathEnableUser() throws Exception { dummyAuditService.assertExecutionDeltas(0,2); dummyAuditService.assertHasDelta(0,ChangeType.MODIFY, UserType.class); dummyAuditService.assertHasDelta(0,ChangeType.MODIFY, ShadowType.class); - dummyAuditService.assertExecutionDeltas(1,1); // user is again disabled here + dummyAuditService.assertExecutionDeltas(1,2); // user is again disabled here + dummyAuditService.assertHasDelta(1,ChangeType.MODIFY, UserType.class); // lastProvisioningTimestamp dummyAuditService.assertHasDelta(1,ChangeType.MODIFY, ShadowType.class); dummyAuditService.assertExecutionSuccess(); } @@ -1830,12 +1818,12 @@ public void test404DavidAndGoliathEnableUser() throws Exception { @Test public void test405DavidAndGoliathDisableAccountDavid() throws Exception { final String TEST_NAME = "test405DavidAndGoliathDisableAccountDavid"; - TestUtil.displayTestTitle(TEST_NAME); + displayTestTitle(TEST_NAME); // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_WORLD_NAME); @@ -1844,13 +1832,12 @@ public void test405DavidAndGoliathDisableAccountDavid() throws Exception { dummyAuditService.clear(); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); modifyAccountShadowReplace(accountDavidOid, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.DISABLED); // THEN - TestUtil.displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); + displayThen(TEST_NAME); + assertSuccess(result); assertDavidGoliath(userBefore.getOid(), "rock", USER_WORLD_NAME, true, false, true); @@ -1859,7 +1846,8 @@ public void test405DavidAndGoliathDisableAccountDavid() throws Exception { dummyAuditService.assertRecords(2); dummyAuditService.assertSimpleRecordSanity(); dummyAuditService.assertAnyRequestDeltas(); - dummyAuditService.assertExecutionDeltas(0,1); + dummyAuditService.assertExecutionDeltas(0,2); + dummyAuditService.assertHasDelta(0,ChangeType.MODIFY, UserType.class); // lastProvisioningTimestamp dummyAuditService.assertHasDelta(0,ChangeType.MODIFY, ShadowType.class); dummyAuditService.assertExecutionSuccess(); } @@ -1870,12 +1858,12 @@ public void test405DavidAndGoliathDisableAccountDavid() throws Exception { @Test public void test406DavidAndGoliathRecompute() throws Exception { final String TEST_NAME = "test406DavidAndGoliathRecompute"; - TestUtil.displayTestTitle(TEST_NAME); + displayTestTitle(TEST_NAME); // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_WORLD_NAME); @@ -1883,13 +1871,12 @@ public void test406DavidAndGoliathRecompute() throws Exception { dummyAuditService.clear(); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); recomputeUser(userBefore.getOid(), task, result); // THEN - TestUtil.displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); + displayThen(TEST_NAME); + assertSuccess(result); assertDavidGoliath(userBefore.getOid(), "rock", USER_WORLD_NAME, true, false, true); @@ -1901,12 +1888,12 @@ public void test406DavidAndGoliathRecompute() throws Exception { @Test public void test408DavidAndGoliathEnableAccountDavid() throws Exception { final String TEST_NAME = "test408DavidAndGoliathEnableAccountDavid"; - TestUtil.displayTestTitle(TEST_NAME); + displayTestTitle(TEST_NAME); // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_WORLD_NAME); @@ -1915,13 +1902,12 @@ public void test408DavidAndGoliathEnableAccountDavid() throws Exception { dummyAuditService.clear(); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); modifyAccountShadowReplace(accountDavidOid, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.ENABLED); // THEN - TestUtil.displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); + displayThen(TEST_NAME); + assertSuccess(result); assertDavidGoliath(userBefore.getOid(), "rock", USER_WORLD_NAME, true, true, true); @@ -1930,7 +1916,8 @@ public void test408DavidAndGoliathEnableAccountDavid() throws Exception { dummyAuditService.assertRecords(2); dummyAuditService.assertSimpleRecordSanity(); dummyAuditService.assertAnyRequestDeltas(); - dummyAuditService.assertExecutionDeltas(0,1); + dummyAuditService.assertExecutionDeltas(0,2); + dummyAuditService.assertHasDelta(0,ChangeType.MODIFY, UserType.class); // lastProvisioningTimestamp dummyAuditService.assertHasDelta(0,ChangeType.MODIFY, ShadowType.class); dummyAuditService.assertExecutionSuccess(); } @@ -1938,25 +1925,24 @@ public void test408DavidAndGoliathEnableAccountDavid() throws Exception { @Test public void test410DavidAndGoliathRename() throws Exception { final String TEST_NAME = "test410DavidAndGoliathRename"; - TestUtil.displayTestTitle(TEST_NAME); + displayTestTitle(TEST_NAME); // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_WORLD_NAME); dummyAuditService.clear(); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); modifyUserReplace(userBefore.getOid(), UserType.F_NAME, task, result, PrismTestUtil.createPolyString(USER_FIELD_NAME)); - // THEN - TestUtil.displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); + // THEN + displayThen(TEST_NAME); + assertSuccess(result); assertDavidGoliath(userBefore.getOid(), "rock", USER_FIELD_NAME, true, true, true); @@ -1980,29 +1966,29 @@ public void test410DavidAndGoliathRename() throws Exception { ObjectDeltaOperation executionDeltaOp = dummyAuditService.getExecutionDelta(2, ChangeType.MODIFY, ShadowType.class); ObjectDelta executionDelta = executionDeltaOp.getObjectDelta(); display("Last execution delta", executionDelta); - PrismAsserts.assertModifications("Phantom changes in last delta:", executionDelta, 2); + PrismAsserts.assertModifications("Phantom changes in last delta:", executionDelta, 4); } @Test public void test419DavidAndGoliathUnassignRole() throws Exception { final String TEST_NAME = "test419DavidAndGoliathUnassignRole"; - TestUtil.displayTestTitle(TEST_NAME); + displayTestTitle(TEST_NAME); // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_FIELD_NAME); dummyAuditService.clear(); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); unassignRole(userBefore.getOid(), ROLE_FIGHT_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result, 2); @@ -2032,12 +2018,12 @@ public void test419DavidAndGoliathUnassignRole() throws Exception { @Test public void test420DavidAndGoliathAssignRoleGoliathDown() throws Exception { final String TEST_NAME = "test420DavidAndGoliathAssignRoleGoliathDown"; - TestUtil.displayTestTitle(TEST_NAME); + displayTestTitle(TEST_NAME); // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_FIELD_NAME); @@ -2056,11 +2042,11 @@ public void test420DavidAndGoliathAssignRoleGoliathDown() throws Exception { dummyAuditService.clear(); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); assignRole(userBefore.getOid(), ROLE_FIGHT_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); // Inner errors are expected TestUtil.assertPartialError(result); @@ -2100,12 +2086,12 @@ public void test420DavidAndGoliathAssignRoleGoliathDown() throws Exception { @Test(enabled=false) public void test422DavidAndGoliathAssignRoleGoliathUpRecompute() throws Exception { final String TEST_NAME = "test422DavidAndGoliathAssignRoleGoliathUpRecompute"; - TestUtil.displayTestTitle(TEST_NAME); + displayTestTitle(TEST_NAME); // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_FIELD_NAME); @@ -2116,7 +2102,7 @@ public void test422DavidAndGoliathAssignRoleGoliathUpRecompute() throws Exceptio recomputeUser(userBefore.getOid(), task, result); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2143,23 +2129,23 @@ public void test422DavidAndGoliathAssignRoleGoliathUpRecompute() throws Exceptio @Test public void test429DavidAndGoliathUnassignRole() throws Exception { final String TEST_NAME = "test429DavidAndGoliathUnassignRole"; - TestUtil.displayTestTitle(TEST_NAME); + displayTestTitle(TEST_NAME); // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_FIELD_NAME); dummyAuditService.clear(); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); unassignRole(userBefore.getOid(), ROLE_FIGHT_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); // TestUtil.assertSuccess(result, 2); @@ -2191,12 +2177,12 @@ public void test429DavidAndGoliathUnassignRole() throws Exception { @Test public void test430DavidAndGoliathAssignRoleDavidDown() throws Exception { final String TEST_NAME = "test430DavidAndGoliathAssignRoleDavidDown"; - TestUtil.displayTestTitle(TEST_NAME); + displayTestTitle(TEST_NAME); // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_FIELD_NAME); @@ -2216,11 +2202,11 @@ public void test430DavidAndGoliathAssignRoleDavidDown() throws Exception { dummyAuditService.clear(); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); assignRole(userBefore.getOid(), ROLE_FIGHT_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); // Inner errors are expected TestUtil.assertPartialError(result); @@ -2256,12 +2242,12 @@ public void test430DavidAndGoliathAssignRoleDavidDown() throws Exception { @Test public void test440DavidAndGoliathAssignRoleAndCreateUserInOneStep() throws Exception { final String TEST_NAME = "test440DavidAndGoliathAssignRoleAndCreateUserInOneStep"; - TestUtil.displayTestTitle(TEST_NAME); + displayTestTitle(TEST_NAME); dummyResourceGoliath.setBreakMode(BreakMode.NONE); dummyResourceDavid.setBreakMode(BreakMode.NONE); try{ - Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); + Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); // delete user and his roles which were added before @@ -2306,11 +2292,11 @@ public void test440DavidAndGoliathAssignRoleAndCreateUserInOneStep() throws Exce dummyAuditService.clear(); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); // assignRole(userBefore.getOid(), ROLE_FIGHT_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplate.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplate.java index 7f297aa93d6..10d08ef3d61 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplate.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplate.java @@ -1019,7 +1019,7 @@ public void test160ModifyUserGivenNameAgain() throws Exception { dummyAuditService.assertTarget(USER_JACK_OID); dummyAuditService.assertExecutionSuccess(); ObjectDeltaOperation objectDeltaOperation = dummyAuditService.getExecutionDelta(0, ChangeType.MODIFY, UserType.class); - assertEquals("unexpected number of modifications in audited delta", 4, objectDeltaOperation.getObjectDelta().getModifications().size()); // givenName + badLuck + modifyTimestamp + assertEquals("unexpected number of modifications in audited delta", 5, objectDeltaOperation.getObjectDelta().getModifications().size()); // givenName + badLuck + modifyTimestamp PropertyDelta badLuckDelta = objectDeltaOperation.getObjectDelta().findPropertyDelta(new ItemPath(UserType.F_EXTENSION, PIRACY_BAD_LUCK)); assertNotNull("badLuck delta was not found", badLuckDelta); List oldValues = (List) badLuckDelta.getEstimatedOldValues(); @@ -1069,7 +1069,7 @@ public void test162ModifyUserGivenNameAgainPhantomChange() throws Exception { dummyAuditService.assertTarget(USER_JACK_OID); dummyAuditService.assertExecutionSuccess(); ObjectDeltaOperation objectDeltaOperation = dummyAuditService.getExecutionDelta(0, ChangeType.MODIFY, UserType.class); - assertEquals("unexpected number of modifications in audited delta", 4, objectDeltaOperation.getObjectDelta().getModifications().size()); // givenName + modifyTimestamp, modifyChannel, modifierRef + assertEquals("unexpected number of modifications in audited delta", 5, objectDeltaOperation.getObjectDelta().getModifications().size()); // givenName + modifyTimestamp, modifyChannel, modifierRef } @Test diff --git a/model/model-intest/src/test/resources/logback-test.xml b/model/model-intest/src/test/resources/logback-test.xml index 28c0a548e7d..90d10261aeb 100644 --- a/model/model-intest/src/test/resources/logback-test.xml +++ b/model/model-intest/src/test/resources/logback-test.xml @@ -47,7 +47,7 @@ - + @@ -57,7 +57,7 @@ - + @@ -67,7 +67,7 @@ - + @@ -80,7 +80,7 @@ - + diff --git a/model/model-intest/src/test/resources/mapping/resource-dummy-crimson.xml b/model/model-intest/src/test/resources/mapping/resource-dummy-crimson.xml index 01b372e3064..393046152f8 100644 --- a/model/model-intest/src/test/resources/mapping/resource-dummy-crimson.xml +++ b/model/model-intest/src/test/resources/mapping/resource-dummy-crimson.xml @@ -190,9 +190,7 @@ - - strong - + diff --git a/model/model-intest/src/test/resources/mapping/resource-dummy-light-crimson.xml b/model/model-intest/src/test/resources/mapping/resource-dummy-light-crimson.xml index f905f957fed..dd4f5f858cf 100644 --- a/model/model-intest/src/test/resources/mapping/resource-dummy-light-crimson.xml +++ b/model/model-intest/src/test/resources/mapping/resource-dummy-light-crimson.xml @@ -181,9 +181,7 @@ - - strong - + diff --git a/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ShadowManager.java b/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ShadowManager.java index 1da42514288..412c27ead5f 100644 --- a/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ShadowManager.java +++ b/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ShadowManager.java @@ -1319,7 +1319,7 @@ public void modifyShadowAttributes(ProvisioningContext ctx, PrismObject shadowChanges = extractRepoShadowChanges(ctx, shadow, modifications); if (shadowChanges != null && !shadowChanges.isEmpty()) { LOGGER.trace( - "Detected shadow changes. Start to modify shadow in the repository, applying modifications {}", + "There are repository shadow changes, applying modifications {}", DebugUtil.debugDump(shadowChanges)); try { ConstraintsChecker.onShadowModifyOperation(shadowChanges); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/manual/AbstractManualResourceTest.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/manual/AbstractManualResourceTest.java index 3aac919147f..5280e4af290 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/manual/AbstractManualResourceTest.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/manual/AbstractManualResourceTest.java @@ -1342,13 +1342,13 @@ public void test240CloseDisableCaseAndReadAccountWill() throws Exception { OperationResult result = task.getResult(); syncServiceMock.reset(); + accountWillCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); + closeCase(willLastCaseOid); PrismObject shadowBefore = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, task, result); display("Shadow before", shadowBefore); - accountWillCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); - // WHEN displayWhen(TEST_NAME); PrismObject shadowProvisioning = provisioningService.getObject(ShadowType.class, @@ -1678,18 +1678,18 @@ public void test260ClosePasswordChangeCaseAndRefreshAccountWill() throws Excepti } /** - * ff 10min. Refresh. Oldest delta should expire. + * ff 7min. Refresh. Oldest delta should expire. */ @Test - public void test270RefreshAccountWillAfter10min() throws Exception { - final String TEST_NAME = "test130RefreshAccountWillAfter10min"; + public void test270RefreshAccountWillAfter7min() throws Exception { + final String TEST_NAME = "test130RefreshAccountWillAfter7min"; displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); syncServiceMock.reset(); - clock.overrideDuration("PT10M"); + clock.overrideDuration("PT7M"); PrismObject shadowBefore = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, task, result); display("Shadow before", shadowBefore); @@ -2128,13 +2128,13 @@ public void test310CloseCaseAndRefreshAccountWill() throws Exception { OperationResult result = task.getResult(); syncServiceMock.reset(); + accountWillCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); + closeCase(willLastCaseOid); PrismObject shadowBefore = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, task, result); display("Shadow before", shadowBefore); - accountWillCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); - // WHEN displayWhen(TEST_NAME); provisioningService.refreshShadow(shadowBefore, null, task, result);