Search in sources :

Example 16 with ActivationType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType in project midpoint by Evolveum.

the class TestActivationComputer method testGetActiveAdministrativeArchived.

@Test
public void testGetActiveAdministrativeArchived() 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(SchemaConstants.LIFECYCLE_ACTIVE, 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)

Example 17 with ActivationType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType in project midpoint by Evolveum.

the class TestIntegrationObjectWrapperFactory method test220AssignRoleLandluberToWally.

@Test
public void test220AssignRoleLandluberToWally() throws Exception {
    final String TEST_NAME = "test220AssignRoleLandluberToWally";
    TestUtil.displayTestTile(this, TEST_NAME);
    Task task = taskManager.createTaskInstance(TestIntegrationObjectWrapperFactory.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    DummyGroup mapmakers = new DummyGroup(GROUP_DUMMY_MAPMAKERS_NAME);
    dummyResource.addGroup(mapmakers);
    PrismObject<UserType> user = createUser(USER_WALLY_NAME, USER_WALLY_FULLNAME, true);
    addObject(user);
    userWallyOid = user.getOid();
    assignRole(userWallyOid, ROLE_MAPMAKER_OID, task, result);
    // preconditions
    result.computeStatus();
    TestUtil.assertSuccess(result);
    PrismObject<UserType> userAfter = getUser(userWallyOid);
    display("User after change execution", userAfter);
    accountWallyOid = getSingleLinkOid(userAfter);
    PrismObject<ShadowType> shadow = getShadowModel(accountWallyOid);
    shadow.findReference(ShadowType.F_RESOURCE_REF).getValue().setObject(resourceDummy);
    display("Shadow", shadow);
    DummyGroup dummyGroup = dummyResource.getGroupByName(GROUP_DUMMY_MAPMAKERS_NAME);
    assertNotNull("No group on dummy resource", dummyGroup);
    display("Group", dummyGroup);
    assertGroupMember(dummyGroup, USER_WALLY_NAME);
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    ObjectWrapperFactory factory = new ObjectWrapperFactory(getServiceLocator());
    ObjectWrapper<ShadowType> objectWrapper = factory.createObjectWrapper("shadow display name", "shadow description", shadow, ContainerStatus.MODIFYING, task);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    display("Wrapper after", objectWrapper);
    WrapperTestUtil.assertWrapper(objectWrapper, "shadow display name", "shadow description", shadow, ContainerStatus.MODIFYING);
    assertEquals("wrong number of containers in " + objectWrapper, 9, objectWrapper.getContainers().size());
    ContainerWrapper attributesContainerWrapper = objectWrapper.findContainerWrapper(new ItemPath(ShadowType.F_ATTRIBUTES));
    WrapperTestUtil.assertWrapper(attributesContainerWrapper, "prismContainer.shadow.mainPanelDisplayName", new ItemPath(ShadowType.F_ATTRIBUTES), shadow.findContainer(ShadowType.F_ATTRIBUTES), true, ContainerStatus.MODIFYING);
    WrapperTestUtil.assertPropertyWrapper(attributesContainerWrapper, dummyResourceCtl.getAttributeFullnameQName(), USER_WALLY_FULLNAME);
    WrapperTestUtil.assertPropertyWrapper(attributesContainerWrapper, SchemaConstants.ICFS_NAME, USER_WALLY_NAME);
    assertEquals("wrong number of items in " + attributesContainerWrapper, 16, attributesContainerWrapper.getItems().size());
    ContainerWrapper<ActivationType> activationContainerWrapper = objectWrapper.findContainerWrapper(new ItemPath(UserType.F_ACTIVATION));
    WrapperTestUtil.assertWrapper(activationContainerWrapper, "ShadowType.activation", UserType.F_ACTIVATION, shadow, ContainerStatus.MODIFYING);
    WrapperTestUtil.assertPropertyWrapper(activationContainerWrapper, ActivationType.F_ADMINISTRATIVE_STATUS, ActivationStatusType.ENABLED);
    WrapperTestUtil.assertPropertyWrapper(activationContainerWrapper, ActivationType.F_LOCKOUT_STATUS, null);
    ContainerWrapper<ShadowAssociationType> associationContainerWrapper = objectWrapper.findContainerWrapper(new ItemPath(ShadowType.F_ASSOCIATION));
    assertNotNull("No association container wrapper", associationContainerWrapper);
    assertEquals("wrong number of items in " + associationContainerWrapper, 2, associationContainerWrapper.getItems().size());
    ItemWrapper groupAssociationWrapper = associationContainerWrapper.findPropertyWrapper(RESOURCE_DUMMY_ASSOCIATION_GROUP_QNAME);
    assertNotNull("No group association property wrapper", groupAssociationWrapper);
    assertTrue("Wrong type of group association property wrapper: " + groupAssociationWrapper.getClass(), groupAssociationWrapper instanceof AssociationWrapper);
    List<ValueWrapper> groupAssociationValues = groupAssociationWrapper.getValues();
    assertEquals("wrong number of values in " + groupAssociationWrapper, 1, groupAssociationValues.size());
    ValueWrapper groupAssociationValue = groupAssociationValues.get(0);
    PrismContainerValue<ShadowAssociationType> groupAssociationValuePVal = (PrismContainerValue<ShadowAssociationType>) groupAssociationValue.getValue();
    display("groupAssociationValuePVal", groupAssociationValuePVal);
    assertEquals("wrong number of values in " + groupAssociationValue, ValueStatus.NOT_CHANGED, groupAssociationValue.getStatus());
    assertEquals("Wrong group association name", RESOURCE_DUMMY_ASSOCIATION_GROUP_QNAME, groupAssociationValuePVal.findProperty(ShadowAssociationType.F_NAME).getRealValue());
    PrismContainer<ShadowIdentifiersType> groupAssociationValueIdentifiers = groupAssociationValuePVal.findContainer(ShadowAssociationType.F_IDENTIFIERS);
    PrismProperty<String> groupAssociationUidProp = groupAssociationValueIdentifiers.findProperty(new QName(null, "uid"));
    PrismAsserts.assertPropertyValue(groupAssociationUidProp, GROUP_DUMMY_MAPMAKERS_NAME);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ValueWrapper(com.evolveum.midpoint.web.component.prism.ValueWrapper) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ContainerWrapper(com.evolveum.midpoint.web.component.prism.ContainerWrapper) ItemWrapper(com.evolveum.midpoint.web.component.prism.ItemWrapper) ShadowAssociationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAssociationType) DummyGroup(com.evolveum.icf.dummy.resource.DummyGroup) PrismContainerValue(com.evolveum.midpoint.prism.PrismContainerValue) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) QName(javax.xml.namespace.QName) AssociationWrapper(com.evolveum.midpoint.web.component.prism.AssociationWrapper) ShadowIdentifiersType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowIdentifiersType) ActivationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType) ObjectWrapperFactory(com.evolveum.midpoint.web.component.prism.ObjectWrapperFactory) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Example 18 with ActivationType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType in project midpoint by Evolveum.

the class TestDiffEquals method testAssignmentEquivalent.

@Test
public void testAssignmentEquivalent() throws Exception {
    System.out.println("\n\n===[ testAssignmentEquivalent ]===\n");
    PrismContext prismContext = PrismTestUtil.getPrismContext();
    AssignmentType a1 = new AssignmentType(prismContext);
    ActivationType a1a = new ActivationType(prismContext);
    a1a.setValidFrom(XmlTypeConverter.createXMLGregorianCalendar(new Date()));
    a1a.setEffectiveStatus(ActivationStatusType.ENABLED);
    a1.setActivation(a1a);
    AssignmentType a2 = new AssignmentType(prismContext);
    ActivationType a2a = new ActivationType(prismContext);
    a2a.setEffectiveStatus(ActivationStatusType.ENABLED);
    a2.setActivation(a2a);
    // WHEN
    assertFalse(a1.equals(a2));
    // a bit redundant
    assertFalse(a1.asPrismContainerValue().equivalent(a2.asPrismContainerValue()));
    assertFalse(a2.equals(a1));
    // a bit redundant
    assertFalse(a2.asPrismContainerValue().equivalent(a1.asPrismContainerValue()));
}
Also used : PrismContext(com.evolveum.midpoint.prism.PrismContext) ActivationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType) Date(java.util.Date) Test(org.testng.annotations.Test)

Example 19 with ActivationType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType in project midpoint by Evolveum.

the class UserComputer method recompute.

public void recompute(PrismObject<UserType> user) {
    UserType userType = user.asObjectable();
    ActivationType activationType = userType.getActivation();
    if (activationType != null) {
        activationComputer.computeEffective(userType.getLifecycleState(), activationType);
    }
}
Also used : ActivationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)

Example 20 with ActivationType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType in project midpoint by Evolveum.

the class TestIntegrationObjectWrapperFactory method test102CreateWrapperUserEmpty.

@Test
public void test102CreateWrapperUserEmpty() throws Exception {
    final String TEST_NAME = "test102CreateWrapperUserEmpty";
    TestUtil.displayTestTile(TEST_NAME);
    PrismObject<UserType> user = getUser(USER_EMPTY_OID);
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    Task task = taskManager.createTaskInstance(TEST_NAME);
    ObjectWrapperFactory factory = new ObjectWrapperFactory(getServiceLocator());
    ObjectWrapper<UserType> objectWrapper = factory.createObjectWrapper("user display name", "user description", user, ContainerStatus.MODIFYING, task);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    IntegrationTestTools.display("Wrapper after", objectWrapper);
    WrapperTestUtil.assertWrapper(objectWrapper, "user display name", "user description", user, ContainerStatus.MODIFYING);
    assertEquals("wrong number of containers in " + objectWrapper, 11, objectWrapper.getContainers().size());
    ContainerWrapper<UserType> mainContainerWrapper = objectWrapper.findContainerWrapper(null);
    WrapperTestUtil.assertWrapper(mainContainerWrapper, "prismContainer.mainPanelDisplayName", (ItemPath) null, user, ContainerStatus.MODIFYING);
    WrapperTestUtil.assertPropertyWrapper(mainContainerWrapper, UserType.F_NAME, PrismTestUtil.createPolyString(USER_EMPTY_USERNAME));
    WrapperTestUtil.assertPropertyWrapper(mainContainerWrapper, UserType.F_TIMEZONE, null);
    // Not sure about this
    //		ContainerWrapper<ActivationType> activationContainerWrapper = objectWrapper.findContainerWrapper(new ItemPath(UserType.F_ACTIVATION));
    //		assertNull("Unexpected activation "+activationContainerWrapper, activationContainerWrapper);
    assertEquals("Wrong main container wrapper readOnly", Boolean.FALSE, (Boolean) mainContainerWrapper.isReadonly());
    assertItemWrapperFullConrol(mainContainerWrapper, UserType.F_NAME, true);
    // emphasized
    assertItemWrapperFullConrol(mainContainerWrapper, UserType.F_GIVEN_NAME, true);
    // emphasized
    assertItemWrapperFullConrol(mainContainerWrapper, UserType.F_FULL_NAME, true);
    // empty
    assertItemWrapperFullConrol(mainContainerWrapper, UserType.F_ADDITIONAL_NAME, false);
    // empty
    assertItemWrapperFullConrol(mainContainerWrapper, UserType.F_LOCALITY, false);
    // WHEN
    objectWrapper.setShowEmpty(true);
    // THEN
    assertItemWrapperFullConrol(mainContainerWrapper, UserType.F_NAME, true);
    // emphasized
    assertItemWrapperFullConrol(mainContainerWrapper, UserType.F_GIVEN_NAME, true);
    // emphasized
    assertItemWrapperFullConrol(mainContainerWrapper, UserType.F_FULL_NAME, true);
    // empty
    assertItemWrapperFullConrol(mainContainerWrapper, UserType.F_ADDITIONAL_NAME, true);
    // empty		
    assertItemWrapperFullConrol(mainContainerWrapper, UserType.F_LOCALITY, true);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ObjectWrapperFactory(com.evolveum.midpoint.web.component.prism.ObjectWrapperFactory) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test)

Aggregations

ActivationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType)76 Test (org.testng.annotations.Test)48 ActivationStatusType (com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType)40 AbstractUnitTest (com.evolveum.midpoint.tools.testng.AbstractUnitTest)13 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)11 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)10 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)9 Task (com.evolveum.midpoint.task.api.Task)9 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)8 PrismObject (com.evolveum.midpoint.prism.PrismObject)7 MetadataType (com.evolveum.midpoint.xml.ns._public.common.common_3.MetadataType)7 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)7 LockoutStatusType (com.evolveum.midpoint.xml.ns._public.common.common_3.LockoutStatusType)6 ActivationCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType)6 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)6 ActivationStatusCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationStatusCapabilityType)5 SchemaConstants (com.evolveum.midpoint.schema.constants.SchemaConstants)4 TimeIntervalStatusType (com.evolveum.midpoint.xml.ns._public.common.common_3.TimeIntervalStatusType)4 ActivationLockoutStatusCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationLockoutStatusCapabilityType)4 QName (javax.xml.namespace.QName)4