Search in sources :

Example 26 with ActivationStatusType

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());
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ActivationStatusType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) PropertyDelta(com.evolveum.midpoint.prism.delta.PropertyDelta) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 27 with ActivationStatusType

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);
}
Also used : TimeIntervalStatusType(com.evolveum.midpoint.xml.ns._public.common.common_3.TimeIntervalStatusType) ActivationStatusType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType)

Example 28 with ActivationStatusType

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;
}
Also used : ActivationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType)

Example 29 with ActivationStatusType

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);
}
Also used : ActivationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType) ActivationStatusType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType) Test(org.testng.annotations.Test)

Example 30 with ActivationStatusType

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);
}
Also used : ActivationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType) ActivationStatusType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType) Test(org.testng.annotations.Test)

Aggregations

ActivationStatusType (com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType)32 ActivationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType)24 Test (org.testng.annotations.Test)17 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)7 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)6 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)6 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)4 Task (com.evolveum.midpoint.task.api.Task)4 PrismObject (com.evolveum.midpoint.prism.PrismObject)3 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)3 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)2 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)2 LockoutStatusType (com.evolveum.midpoint.xml.ns._public.common.common_3.LockoutStatusType)2 TimeIntervalStatusType (com.evolveum.midpoint.xml.ns._public.common.common_3.TimeIntervalStatusType)2 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)2 ActivationStatusCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationStatusCapabilityType)2 ArrayList (java.util.ArrayList)2 ModelExecuteOptions (com.evolveum.midpoint.model.api.ModelExecuteOptions)1 ModelProjectionContext (com.evolveum.midpoint.model.api.context.ModelProjectionContext)1 LensProjectionContext (com.evolveum.midpoint.model.impl.lens.LensProjectionContext)1