Search in sources :

Example 6 with ObjectWrapperFactory

use of com.evolveum.midpoint.web.component.prism.ObjectWrapperFactory in project midpoint by Evolveum.

the class TestIntegrationObjectWrapperFactory method test800EditSchemaJackPropReadAllModifySomeUser.

/**
	 * MID-3126
	 */
@Test
public void test800EditSchemaJackPropReadAllModifySomeUser() throws Exception {
    final String TEST_NAME = "test800EditSchemaJackPropReadAllModifySomeUser";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    cleanupAutzTest(USER_JACK_OID);
    assignRole(USER_JACK_OID, ROLE_PROP_READ_ALL_MODIFY_SOME_USER_OID);
    login(USER_JACK_USERNAME);
    ObjectWrapperFactory factory = new ObjectWrapperFactory(getServiceLocator());
    PrismObject<UserType> user = getUser(USER_JACK_OID);
    display("user before", user);
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    Task task = taskManager.createTaskInstance(TEST_NAME);
    ObjectWrapper<UserType> objectWrapper = factory.createObjectWrapper("user display name", "user description", user, ContainerStatus.MODIFYING, task);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    IntegrationTestTools.display("Wrapper after", objectWrapper);
    assertEquals("Wrong object wrapper readOnly", Boolean.FALSE, (Boolean) objectWrapper.isReadonly());
    ContainerWrapper<UserType> mainContainerWrapper = objectWrapper.findMainContainerWrapper();
    assertEquals("Wrong main container wrapper readOnly", Boolean.FALSE, (Boolean) mainContainerWrapper.isReadonly());
    ItemWrapper nameWrapper = mainContainerWrapper.findPropertyWrapper(UserType.F_NAME);
    // Is this OK?
    assertEquals("Wrong name readOnly", Boolean.TRUE, (Boolean) nameWrapper.isReadonly());
    assertEquals("Wrong name visible", Boolean.TRUE, (Boolean) nameWrapper.isVisible());
    assertEquals("Wrong name definition.canRead", Boolean.TRUE, (Boolean) nameWrapper.getItemDefinition().canRead());
    assertEquals("Wrong name definition.canAdd", Boolean.FALSE, (Boolean) nameWrapper.getItemDefinition().canAdd());
    assertEquals("Wrong name definition.canModify", Boolean.FALSE, (Boolean) nameWrapper.getItemDefinition().canModify());
    ItemWrapper givenNameWrapper = mainContainerWrapper.findPropertyWrapper(UserType.F_GIVEN_NAME);
    // Is this OK?
    assertEquals("Wrong givenName readOnly", Boolean.TRUE, (Boolean) givenNameWrapper.isReadonly());
    assertEquals("Wrong givenName visible", Boolean.TRUE, (Boolean) givenNameWrapper.isVisible());
    assertEquals("Wrong givenName definition.canRead", Boolean.TRUE, (Boolean) givenNameWrapper.getItemDefinition().canRead());
    assertEquals("Wrong givenName definition.canAdd", Boolean.FALSE, (Boolean) givenNameWrapper.getItemDefinition().canAdd());
    assertEquals("Wrong givenName definition.canModify", Boolean.FALSE, (Boolean) givenNameWrapper.getItemDefinition().canModify());
    ItemWrapper fullNameWrapper = mainContainerWrapper.findPropertyWrapper(UserType.F_FULL_NAME);
    assertEquals("Wrong fullName readOnly", Boolean.FALSE, (Boolean) fullNameWrapper.isReadonly());
    assertEquals("Wrong fullName visible", Boolean.TRUE, (Boolean) fullNameWrapper.isVisible());
    assertEquals("Wrong fullName definition.canRead", Boolean.TRUE, (Boolean) fullNameWrapper.getItemDefinition().canRead());
    assertEquals("Wrong fullName definition.canAdd", Boolean.FALSE, (Boolean) fullNameWrapper.getItemDefinition().canAdd());
    assertEquals("Wrong fullName definition.canModify", Boolean.TRUE, (Boolean) fullNameWrapper.getItemDefinition().canModify());
    ItemWrapper additionalNameWrapper = mainContainerWrapper.findPropertyWrapper(UserType.F_ADDITIONAL_NAME);
    // Is this OK?
    assertEquals("Wrong additionalName readOnly", Boolean.TRUE, (Boolean) additionalNameWrapper.isReadonly());
    // not visible, because it is empty
    assertEquals("Wrong additionalName visible", Boolean.FALSE, (Boolean) additionalNameWrapper.isVisible());
    assertEquals("Wrong additionalName definition.canRead", Boolean.TRUE, (Boolean) additionalNameWrapper.getItemDefinition().canRead());
    assertEquals("Wrong additionalName definition.canAdd", Boolean.FALSE, (Boolean) additionalNameWrapper.getItemDefinition().canAdd());
    assertEquals("Wrong additionalName definition.canModify", Boolean.FALSE, (Boolean) additionalNameWrapper.getItemDefinition().canModify());
    ItemWrapper localityNameWrapper = mainContainerWrapper.findPropertyWrapper(UserType.F_LOCALITY);
    assertEquals("Wrong locality readOnly", Boolean.TRUE, (Boolean) localityNameWrapper.isReadonly());
    assertEquals("Wrong locality visible", Boolean.TRUE, (Boolean) localityNameWrapper.isVisible());
    assertEquals("Wrong locality definition.canRead", Boolean.TRUE, (Boolean) localityNameWrapper.getItemDefinition().canRead());
    assertEquals("Wrong locality definition.canAdd", Boolean.FALSE, (Boolean) localityNameWrapper.getItemDefinition().canAdd());
    assertEquals("Wrong locality definition.canModify", Boolean.FALSE, (Boolean) localityNameWrapper.getItemDefinition().canModify());
    // WHEN
    objectWrapper.setShowEmpty(true);
    // THEN
    additionalNameWrapper = mainContainerWrapper.findPropertyWrapper(UserType.F_ADDITIONAL_NAME);
    // not visible, because it is empty
    assertEquals("Wrong additionalName visible", Boolean.TRUE, (Boolean) additionalNameWrapper.isVisible());
}
Also used : ItemWrapper(com.evolveum.midpoint.web.component.prism.ItemWrapper) 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)

Example 7 with ObjectWrapperFactory

use of com.evolveum.midpoint.web.component.prism.ObjectWrapperFactory in project midpoint by Evolveum.

the class TestIntegrationObjectWrapperFactory method test150CreateWrapperShadow.

@Test
public void test150CreateWrapperShadow() throws Exception {
    final String TEST_NAME = "test150CreateWrapperShadow";
    TestUtil.displayTestTile(TEST_NAME);
    PrismObject<ShadowType> shadow = getShadowModel(accountJackOid);
    shadow.findReference(ShadowType.F_RESOURCE_REF).getValue().setObject(resourceDummy);
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    Task task = taskManager.createTaskInstance(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<ShadowAttributesType> attributesContainerWrapper = objectWrapper.findContainerWrapper(new ItemPath(ShadowType.F_ATTRIBUTES));
    PrismContainer<ShadowAttributesType> attributesContainer = shadow.findContainer(ShadowType.F_ATTRIBUTES);
    WrapperTestUtil.assertWrapper(attributesContainerWrapper, "prismContainer.shadow.mainPanelDisplayName", new ItemPath(ShadowType.F_ATTRIBUTES), attributesContainer, true, ContainerStatus.MODIFYING);
    WrapperTestUtil.assertPropertyWrapper(attributesContainerWrapper, dummyResourceCtl.getAttributeFullnameQName(), USER_JACK_FULL_NAME);
    WrapperTestUtil.assertPropertyWrapper(attributesContainerWrapper, SchemaConstants.ICFS_NAME, USER_JACK_USERNAME);
    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);
    assertEquals("Wrong attributes container wrapper readOnly", Boolean.FALSE, (Boolean) attributesContainerWrapper.isReadonly());
    ItemWrapper fullnameWrapper = attributesContainerWrapper.findPropertyWrapper(dummyResourceCtl.getAttributeFullnameQName());
    // Is this OK?
    assertEquals("Wrong attribute fullname readOnly", Boolean.FALSE, (Boolean) fullnameWrapper.isReadonly());
    assertEquals("Wrong attribute fullname visible", Boolean.TRUE, (Boolean) fullnameWrapper.isVisible());
    ItemDefinition fullNameDefinition = fullnameWrapper.getItemDefinition();
    display("fullname attribute definition", fullNameDefinition);
    assertEquals("Wrong attribute fullname definition.canRead", Boolean.TRUE, (Boolean) fullNameDefinition.canRead());
    assertEquals("Wrong attribute fullname definition.canAdd", Boolean.TRUE, (Boolean) fullNameDefinition.canAdd());
    assertEquals("Wrong attribute fullname definition.canModify", Boolean.TRUE, (Boolean) fullNameDefinition.canModify());
    // MID-3144
    if (fullNameDefinition.getDisplayOrder() == null || fullNameDefinition.getDisplayOrder() < 100 || fullNameDefinition.getDisplayOrder() > 400) {
        AssertJUnit.fail("Wrong fullname definition.displayOrder: " + fullNameDefinition.getDisplayOrder());
    }
    assertEquals("Wrong attribute fullname definition.displayName", "Full Name", fullNameDefinition.getDisplayName());
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ShadowAttributesType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAttributesType) ItemDefinition(com.evolveum.midpoint.prism.ItemDefinition) ItemWrapper(com.evolveum.midpoint.web.component.prism.ItemWrapper) ActivationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType) ObjectWrapperFactory(com.evolveum.midpoint.web.component.prism.ObjectWrapperFactory) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Example 8 with ObjectWrapperFactory

use of com.evolveum.midpoint.web.component.prism.ObjectWrapperFactory in project midpoint by Evolveum.

the class PageTaskEdit method loadObjectWrapper.

protected ObjectWrapper<TaskType> loadObjectWrapper(PrismObject<TaskType> object, Task task, OperationResult result) {
    ObjectWrapper<TaskType> wrapper;
    ObjectWrapperFactory owf = new ObjectWrapperFactory(this);
    try {
        // just to be sure (after deserialization the context is missing in this object)
        object.revive(getPrismContext());
        wrapper = owf.createObjectWrapper("pageAdminFocus.focusDetails", null, object, ContainerStatus.MODIFYING, task);
    } catch (Exception ex) {
        result.recordFatalError("Couldn't get user.", ex);
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load user", ex);
        wrapper = owf.createObjectWrapper("pageAdminFocus.focusDetails", null, object, null, null, ContainerStatus.MODIFYING, false);
    }
    showResult(wrapper.getResult(), false);
    return wrapper;
}
Also used : TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) ObjectWrapperFactory(com.evolveum.midpoint.web.component.prism.ObjectWrapperFactory) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) SystemException(com.evolveum.midpoint.util.exception.SystemException)

Example 9 with ObjectWrapperFactory

use of com.evolveum.midpoint.web.component.prism.ObjectWrapperFactory in project midpoint by Evolveum.

the class TestIntegrationObjectWrapperFactory method test100CreateWrapperUserJack.

@Test
public void test100CreateWrapperUserJack() throws Exception {
    final String TEST_NAME = "test100CreateWrapperUserJack";
    TestUtil.displayTestTile(TEST_NAME);
    PrismObject<UserType> user = getUser(USER_JACK_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_JACK_USERNAME));
    WrapperTestUtil.assertPropertyWrapper(mainContainerWrapper, UserType.F_TIMEZONE, null);
    ContainerWrapper<ActivationType> activationContainerWrapper = objectWrapper.findContainerWrapper(new ItemPath(UserType.F_ACTIVATION));
    WrapperTestUtil.assertWrapper(activationContainerWrapper, "ActivationType.activation", UserType.F_ACTIVATION, user, ContainerStatus.MODIFYING);
    WrapperTestUtil.assertPropertyWrapper(activationContainerWrapper, ActivationType.F_ADMINISTRATIVE_STATUS, ActivationStatusType.ENABLED);
    WrapperTestUtil.assertPropertyWrapper(activationContainerWrapper, ActivationType.F_LOCKOUT_STATUS, null);
    assertEquals("Wrong main container wrapper readOnly", Boolean.FALSE, (Boolean) mainContainerWrapper.isReadonly());
    assertItemWrapperFullConrol(mainContainerWrapper, UserType.F_NAME, true);
    assertItemWrapperFullConrol(mainContainerWrapper, UserType.F_GIVEN_NAME, true);
    assertItemWrapperFullConrol(mainContainerWrapper, UserType.F_FULL_NAME, true);
    // not visible, because it is empty
    assertItemWrapperFullConrol(mainContainerWrapper, UserType.F_ADDITIONAL_NAME, false);
    assertItemWrapperFullConrol(mainContainerWrapper, UserType.F_LOCALITY, true);
    // 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) 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 10 with ObjectWrapperFactory

use of com.evolveum.midpoint.web.component.prism.ObjectWrapperFactory in project midpoint by Evolveum.

the class TestUnitObjectWrapperFactory method testCreateWrapperUser.

@Test
public void testCreateWrapperUser() throws Exception {
    final String TEST_NAME = "testCreateWrapperUser";
    TestUtil.displayTestTile(TEST_NAME);
    PrismObject<UserType> user = PrismTestUtil.parseObject(USER_JACK_REPO_FILE);
    PrismObjectDefinition<UserType> objDef = user.getDefinition();
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    ObjectWrapperFactory factory = new ObjectWrapperFactory(getServiceLocator());
    ObjectWrapper<UserType> objectWrapper = factory.createObjectWrapper("user display name", "user description", user, objDef, null, ContainerStatus.MODIFYING, false);
    // 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 mainContainerWrapper = objectWrapper.findContainerWrapper(null);
    WrapperTestUtil.assertWrapper(mainContainerWrapper, "prismContainer.mainPanelDisplayName", (ItemPath) null, user, ContainerStatus.MODIFYING);
    WrapperTestUtil.assertPropertyWrapper(mainContainerWrapper, UserType.F_NAME, PrismTestUtil.createPolyString("jack"));
    WrapperTestUtil.assertPropertyWrapper(mainContainerWrapper, UserType.F_TIMEZONE, null);
    ContainerWrapper<ActivationType> activationContainerWrapper = objectWrapper.findContainerWrapper(new ItemPath(UserType.F_ACTIVATION));
    WrapperTestUtil.assertWrapper(activationContainerWrapper, "ActivationType.activation", UserType.F_ACTIVATION, user, ContainerStatus.MODIFYING);
    WrapperTestUtil.assertPropertyWrapper(activationContainerWrapper, ActivationType.F_ADMINISTRATIVE_STATUS, ActivationStatusType.ENABLED);
    WrapperTestUtil.assertPropertyWrapper(activationContainerWrapper, ActivationType.F_LOCKOUT_STATUS, null);
}
Also used : 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) ContainerWrapper(com.evolveum.midpoint.web.component.prism.ContainerWrapper) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Aggregations

ObjectWrapperFactory (com.evolveum.midpoint.web.component.prism.ObjectWrapperFactory)10 Task (com.evolveum.midpoint.task.api.Task)8 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)7 Test (org.testng.annotations.Test)7 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)4 ItemWrapper (com.evolveum.midpoint.web.component.prism.ItemWrapper)4 ActivationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType)4 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)3 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)2 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)2 SystemException (com.evolveum.midpoint.util.exception.SystemException)2 ContainerStatus (com.evolveum.midpoint.web.component.prism.ContainerStatus)2 ContainerWrapper (com.evolveum.midpoint.web.component.prism.ContainerWrapper)2 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)2 RestartResponseException (org.apache.wicket.RestartResponseException)2 DummyGroup (com.evolveum.icf.dummy.resource.DummyGroup)1 ItemDefinition (com.evolveum.midpoint.prism.ItemDefinition)1 PrismContainerValue (com.evolveum.midpoint.prism.PrismContainerValue)1 EncryptionException (com.evolveum.midpoint.prism.crypto.EncryptionException)1 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)1