Search in sources :

Example 11 with ModelServiceLocator

use of com.evolveum.midpoint.gui.api.util.ModelServiceLocator in project midpoint by Evolveum.

the class TestIntegrationObjectWrapperFactory method test102CreateWrapperUserEmpty.

@Test
public void test102CreateWrapperUserEmpty() throws Exception {
    PrismObject<UserType> user = getUser(USER_EMPTY_OID);
    PrismObject<UserType> userOld = user.clone();
    when();
    Task task = createTask();
    OperationResult result = task.getResult();
    ModelServiceLocator modelServiceLocator = getServiceLocator(task);
    PrismObjectWrapperFactory<UserType> factory = modelServiceLocator.findObjectWrapperFactory(user.getDefinition());
    WrapperContext context = new WrapperContext(task, result);
    PrismObjectWrapper<UserType> objectWrapper = factory.createObjectWrapper(user, ItemStatus.NOT_CHANGED, context);
    then();
    displayDumpable("Wrapper after", objectWrapper);
    WrapperTestUtil.assertWrapper(objectWrapper, getString("prismContainer.mainPanelDisplayName"), "user description", user, userOld, ItemStatus.NOT_CHANGED);
    assertContainersPaths(objectWrapper, BASIC_USER_CONTAINERS_PATHS);
    WrapperTestUtil.assertWrapper(objectWrapper, getString("prismContainer.mainPanelDisplayName"), null, user, ItemStatus.NOT_CHANGED);
    assertEquals("wrong number of containers in " + objectWrapper, 1, objectWrapper.getValues().size());
    PrismContainerValueWrapper<UserType> mainContainerValueWrapper = objectWrapper.getValue();
    WrapperTestUtil.assertPropertyWrapperByName(mainContainerValueWrapper, UserType.F_NAME, PrismTestUtil.createPolyString(USER_EMPTY_USERNAME));
    WrapperTestUtil.assertPropertyWrapperByName(mainContainerValueWrapper, UserType.F_TIMEZONE, null);
    // Not sure about this
    // ContainerWrapper<ActivationType> activationContainerWrapper = objectWrapper.findContainer(ItemPath.create(UserType.F_ACTIVATION));
    // assertNull("Unexpected activation "+activationContainerWrapper, activationContainerWrapper);
    assertEquals("Wrong main container wrapper readOnly", Boolean.FALSE, (Boolean) objectWrapper.isReadOnly());
    ItemStatus objectStatus = objectWrapper.getStatus();
    assertItemWrapperFullControl(mainContainerValueWrapper, UserType.F_NAME, true);
    // emphasized
    assertItemWrapperFullControl(mainContainerValueWrapper, UserType.F_GIVEN_NAME, true);
    // emphasized
    assertItemWrapperFullControl(mainContainerValueWrapper, UserType.F_FULL_NAME, true);
    // empty
    assertItemWrapperFullControl(mainContainerValueWrapper, UserType.F_ADDITIONAL_NAME, false);
    // empty
    assertItemWrapperFullControl(mainContainerValueWrapper, UserType.F_LOCALITY, false);
    when();
    mainContainerValueWrapper.setShowEmpty(true);
    then();
    assertItemWrapperFullControl(mainContainerValueWrapper, UserType.F_NAME, true);
    // emphasized
    assertItemWrapperFullControl(mainContainerValueWrapper, UserType.F_GIVEN_NAME, true);
    // emphasized
    assertItemWrapperFullControl(mainContainerValueWrapper, UserType.F_FULL_NAME, true);
    // empty
    assertItemWrapperFullControl(mainContainerValueWrapper, UserType.F_ADDITIONAL_NAME, true);
    // empty
    assertItemWrapperFullControl(mainContainerValueWrapper, UserType.F_LOCALITY, true);
    ObjectDelta<UserType> objectDelta = objectWrapper.getObjectDelta();
    displayDumpable("Delta", objectDelta);
    assertTrue("non-empty delta produced from wrapper: " + objectDelta, objectDelta.isEmpty());
}
Also used : WrapperContext(com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext) ItemStatus(com.evolveum.midpoint.gui.api.prism.ItemStatus) Task(com.evolveum.midpoint.task.api.Task) ModelServiceLocator(com.evolveum.midpoint.gui.api.util.ModelServiceLocator) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) AbstractInitializedGuiIntegrationTest(com.evolveum.midpoint.web.AbstractInitializedGuiIntegrationTest) Test(org.testng.annotations.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 12 with ModelServiceLocator

use of com.evolveum.midpoint.gui.api.util.ModelServiceLocator in project midpoint by Evolveum.

the class TestIntegrationObjectWrapperFactory method createObjectWrapper.

private <O extends ObjectType> PrismObjectWrapper<O> createObjectWrapper(Task task, PrismObject<O> object, ItemStatus status) throws SchemaException {
    OperationResult result = task.getResult();
    ModelServiceLocator modelServiceLocator = getServiceLocator(task);
    PrismObjectWrapperFactory<O> factory = modelServiceLocator.findObjectWrapperFactory(object.getDefinition());
    WrapperContext context = new WrapperContext(task, result);
    if (ItemStatus.NOT_CHANGED == status) {
        context.setCreateIfEmpty(true);
        context.setShowEmpty(true);
    }
    PrismObjectWrapper<O> objectWrapper = factory.createObjectWrapper(object, status, context);
    return objectWrapper;
}
Also used : WrapperContext(com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext) ModelServiceLocator(com.evolveum.midpoint.gui.api.util.ModelServiceLocator) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Aggregations

ModelServiceLocator (com.evolveum.midpoint.gui.api.util.ModelServiceLocator)12 WrapperContext (com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext)11 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)9 Task (com.evolveum.midpoint.task.api.Task)9 AbstractInitializedGuiIntegrationTest (com.evolveum.midpoint.web.AbstractInitializedGuiIntegrationTest)8 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)8 Test (org.testng.annotations.Test)8 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)4 ItemStatus (com.evolveum.midpoint.gui.api.prism.ItemStatus)3 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)3 QName (javax.xml.namespace.QName)3 PrismObjectWrapper (com.evolveum.midpoint.gui.api.prism.wrapper.PrismObjectWrapper)2 ItemWrapper (com.evolveum.midpoint.gui.api.prism.wrapper.ItemWrapper)1 PrismContainerValueWrapper (com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper)1 PrismValueWrapper (com.evolveum.midpoint.gui.api.prism.wrapper.PrismValueWrapper)1 ShadowWrapperFactoryImpl (com.evolveum.midpoint.gui.impl.factory.wrapper.ShadowWrapperFactoryImpl)1 ContainerDelta (com.evolveum.midpoint.prism.delta.ContainerDelta)1 UniformItemPath (com.evolveum.midpoint.prism.path.UniformItemPath)1 MidPointPrincipal (com.evolveum.midpoint.security.api.MidPointPrincipal)1 ValueStatus (com.evolveum.midpoint.web.component.prism.ValueStatus)1