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());
}
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;
}
Aggregations