Skip to content

Commit

Permalink
fixing MID-3456
Browse files Browse the repository at this point in the history
  • Loading branch information
katkav committed Jun 19, 2017
1 parent f63f5e9 commit 64bf0b2
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 1 deletion.
Expand Up @@ -668,6 +668,14 @@ private <F extends FocusType> void processActivationAdministrativeAndValidity(Le
// some of the mappings will use effectiveStatus as a source, therefore there has to be a delta for the mapping to work correctly
recordEffectiveStatusDelta(focusContext, effectiveStatusNew, now);
} else {
//check computed effective status current with the saved one - e.g. there can be some inconsistencies so we need to check and force the change.. in other cases, effectvie status will be stored with
// incorrect value. Maybe another option is to not compute effectiveStatusCurrent if there is an existing (saved) effective status in the user.. TODO
if (activationCurrent != null && activationCurrent.getEffectiveStatus() != null) {
ActivationStatusType effectiveStatusSaved = activationCurrent.getEffectiveStatus();
if (effectiveStatusSaved != effectiveStatusNew) {
recordEffectiveStatusDelta(focusContext, effectiveStatusNew, now);
}
}
LOGGER.trace("Skipping effective status processing because there was no change ({} -> {})", effectiveStatusCurrent, effectiveStatusNew);
}
}
Expand Down
Expand Up @@ -264,6 +264,59 @@ public void test055ModifyUserJackEnable() throws Exception {
TestUtil.assertModifyTimestamp(userJack, start, end);
}

@Test
public void test056RecomputeUserJackEffectiveEnable() throws Exception {
final String TEST_NAME = "test056RecomputeUserJackEffectiveEnable";
TestUtil.displayTestTile(this, TEST_NAME);

// GIVEN
Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
XMLGregorianCalendar start = clock.currentTimeXMLGregorianCalendar();

assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL);

PrismObject<UserType> userJackBefore = getUser(USER_JACK_OID);
display("User after change execution", userJackBefore);
assertUserJack(userJackBefore, "Jack Sparrow");

assertAdministrativeStatusEnabled(userJackBefore);
assertValidity(userJackBefore, null);
assertEffectiveStatus(userJackBefore, ActivationStatusType.ENABLED);
assertEnableTimestampFocus(userJackBefore, null, start);

// WHEN
modifyUserReplace(USER_JACK_OID, SchemaConstants.PATH_ACTIVATION_EFFECTIVE_STATUS, ModelExecuteOptions.createRaw(), task, result, ActivationStatusType.DISABLED);
PrismObject<UserType> userJack = getUser(USER_JACK_OID);
display("User after change execution", userJack);
assertUserJack(userJack, "Jack Sparrow");

assertAdministrativeStatusEnabled(userJack);
assertValidity(userJack, null);
assertEffectiveStatus(userJack, ActivationStatusType.DISABLED);

recomputeUser(USER_JACK_OID, task, result);

// THEN
XMLGregorianCalendar end = clock.currentTimeXMLGregorianCalendar();
result.computeStatus();
TestUtil.assertSuccess(result);

PrismObject<UserType> userJackAfter = getUser(USER_JACK_OID);
display("User after change execution", userJackAfter);
assertUserJack(userJackAfter, "Jack Sparrow");

assertAdministrativeStatusEnabled(userJackAfter);
assertValidity(userJackAfter, null);
assertEffectiveStatus(userJackAfter, ActivationStatusType.ENABLED);


TestUtil.assertModifyTimestamp(userJackAfter, start, end);



}

@Test
public void test060ModifyUserJackLifecycleActive() throws Exception {
final String TEST_NAME = "test060ModifyUserJackLifecycleActive";
Expand Down
Expand Up @@ -682,9 +682,15 @@ protected void modifyUserReplace(String userOid, QName propertyName, Task task,
protected void modifyUserReplace(String userOid, ItemPath propertyPath, Task task, OperationResult result, Object... newRealValue)
throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException,
ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException {
modifyUserReplace(userOid, propertyPath, null, task, result, newRealValue);
}

protected void modifyUserReplace(String userOid, ItemPath propertyPath, ModelExecuteOptions options, Task task, OperationResult result, Object... newRealValue)
throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException,
ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException {
ObjectDelta<UserType> objectDelta = createModifyUserReplaceDelta(userOid, propertyPath, newRealValue);
Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(objectDelta);
modelService.executeChanges(deltas, null, task, result);
modelService.executeChanges(deltas, options, task, result);
}

protected <O extends ObjectType> void modifyObjectReplaceProperty(Class<O> type, String oid, QName propertyName, Task task, OperationResult result, Object... newRealValue) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException {
Expand Down

0 comments on commit 64bf0b2

Please sign in to comment.