use of com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType in project midpoint by Evolveum.
the class ConsistencyTest method test250ModifyObjectTwoTimesCommunicationProblem.
@Test
public void test250ModifyObjectTwoTimesCommunicationProblem() throws Exception {
final String TEST_NAME = "test250ModifyObjectTwoTimesCommunicationProblem";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
openDJController.assumeStopped();
OperationResult parentResult = new OperationResult(TEST_NAME);
assertUserOneAccountRef(USER_JACK2_OID);
Collection<PropertyDelta> modifications = new ArrayList<PropertyDelta>();
PropertyDelta fullNameDelta = PropertyDelta.createModificationReplaceProperty(new ItemPath(UserType.F_FULL_NAME), getUserDefinition(), new PolyString("jackNew2"));
modifications.add(fullNameDelta);
PrismPropertyValue<ActivationStatusType> enabledUserAction = new PrismPropertyValue<ActivationStatusType>(ActivationStatusType.ENABLED, OriginType.USER_ACTION, null);
PropertyDelta<ActivationStatusType> enabledDelta = PropertyDelta.createDelta(SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, getUserDefinition());
enabledDelta.addValueToAdd(enabledUserAction);
modifications.add(enabledDelta);
ObjectDelta objectDelta = ObjectDelta.createModifyDelta(USER_JACK2_OID, modifications, UserType.class, prismContext);
Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(objectDelta);
Task task = taskManager.createTaskInstance();
modelService.executeChanges(deltas, null, task, parentResult);
parentResult.computeStatus();
String accountOid = assertUserOneAccountRef(USER_JACK2_OID);
PrismObject<ShadowType> account = modelService.getObject(ShadowType.class, accountOid, null, task, parentResult);
assertNotNull(account);
ShadowType shadow = account.asObjectable();
assertNotNull(shadow.getObjectChange());
display("shadow after communication problem", shadow);
Collection<PropertyDelta> newModifications = new ArrayList<PropertyDelta>();
PropertyDelta fullNameDeltaNew = PropertyDelta.createModificationReplaceProperty(new ItemPath(UserType.F_FULL_NAME), getUserDefinition(), new PolyString("jackNew2a"));
newModifications.add(fullNameDeltaNew);
PropertyDelta givenNameDeltaNew = PropertyDelta.createModificationReplaceProperty(new ItemPath(UserType.F_GIVEN_NAME), getUserDefinition(), new PolyString("jackNew2a"));
newModifications.add(givenNameDeltaNew);
PrismPropertyValue<ActivationStatusType> enabledOutboundAction = new PrismPropertyValue<ActivationStatusType>(ActivationStatusType.ENABLED, OriginType.USER_ACTION, null);
PropertyDelta<ActivationStatusType> enabledDeltaNew = PropertyDelta.createDelta(SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, getUserDefinition());
enabledDeltaNew.addValueToAdd(enabledOutboundAction);
newModifications.add(enabledDeltaNew);
ObjectDelta newObjectDelta = ObjectDelta.createModifyDelta(USER_JACK2_OID, newModifications, UserType.class, prismContext);
Collection<ObjectDelta<? extends ObjectType>> newDeltas = MiscSchemaUtil.createCollection(newObjectDelta);
modelService.executeChanges(newDeltas, null, task, parentResult);
account = modelService.getObject(ShadowType.class, accountOid, null, task, parentResult);
assertNotNull(account);
shadow = account.asObjectable();
assertNotNull(shadow.getObjectChange());
display("shadow after communication problem", shadow);
// parentResult.computeStatus();
// assertEquals("expected handled error in the result", OperationResultStatus.HANDLED_ERROR, parentResult.getStatus());
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType in project midpoint by Evolveum.
the class ActivationComputer method computeEffective.
public void computeEffective(String lifecycleStatus, ActivationType activationType, XMLGregorianCalendar referenceTime) {
ActivationStatusType effectiveStatus = null;
if (lifecycleStatus != null && !lifecycleStatus.equals(SchemaConstants.LIFECYCLE_ACTIVE) && !lifecycleStatus.equals(SchemaConstants.LIFECYCLE_DEPRECATED)) {
effectiveStatus = ActivationStatusType.DISABLED;
}
if (SchemaConstants.LIFECYCLE_ARCHIVED.equals(lifecycleStatus)) {
effectiveStatus = ActivationStatusType.ARCHIVED;
}
ActivationStatusType administrativeStatus = activationType.getAdministrativeStatus();
if (effectiveStatus == null && administrativeStatus != null) {
// Explicit administrative status overrides everything
effectiveStatus = administrativeStatus;
}
TimeIntervalStatusType validityStatus = getValidityStatus(activationType);
if (effectiveStatus == null) {
if (validityStatus == null) {
// No administrative status, no validity. Defaults to enabled.
effectiveStatus = ActivationStatusType.ENABLED;
} else {
switch(validityStatus) {
case AFTER:
case BEFORE:
effectiveStatus = ActivationStatusType.DISABLED;
break;
case IN:
effectiveStatus = ActivationStatusType.ENABLED;
break;
}
}
}
activationType.setEffectiveStatus(effectiveStatus);
activationType.setValidityStatus(validityStatus);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType in project midpoint by Evolveum.
the class TestActivationComputer method createActivationType.
private ActivationType createActivationType(ActivationStatusType administrativeStatus, XMLGregorianCalendar validFrom, XMLGregorianCalendar validTo) {
ActivationType activationType = new ActivationType();
activationType.setAdministrativeStatus(administrativeStatus);
activationType.setValidFrom(validFrom);
activationType.setValidTo(validTo);
return activationType;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType in project midpoint by Evolveum.
the class TestActivationComputer method testGetDraftAdministrativeEnabled.
@Test
public void testGetDraftAdministrativeEnabled() throws Exception {
System.out.println("\n===[ testGetDraftAdministrativeEnabled ]===\n");
// GIVEN
Clock clock = createClock(YEAR_START);
ActivationComputer activationComputer = createActivationComputer(clock);
ActivationType activationType = createActivationType(ActivationStatusType.DISABLED, SPRING_EQUINOX, AUTUMN_EQUINOX);
// WHEN
ActivationStatusType effectiveStatus = activationComputer.getEffectiveStatus(SchemaConstants.LIFECYCLE_DRAFT, activationType);
// THEN
assertEquals("Unexpected effective status", ActivationStatusType.DISABLED, effectiveStatus);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType in project midpoint by Evolveum.
the class TestActivationComputer method testGetAdministrativeArchived.
@Test
public void testGetAdministrativeArchived() throws Exception {
System.out.println("\n===[ testGetAdministrativeArchived ]===\n");
// GIVEN
Clock clock = createClock(SUMMER_SOLSTICE);
ActivationComputer activationComputer = createActivationComputer(clock);
ActivationType activationType = createActivationType(ActivationStatusType.ARCHIVED, SPRING_EQUINOX, AUTUMN_EQUINOX);
// WHEN
ActivationStatusType effectiveStatus = activationComputer.getEffectiveStatus(null, activationType);
// THEN
assertEquals("Unexpected effective status", ActivationStatusType.ARCHIVED, effectiveStatus);
}
Aggregations