use of com.evolveum.midpoint.gui.api.prism.ItemStatus in project midpoint by Evolveum.
the class TestIntegrationObjectWrapperFactory method test802EditSchemaJackPropReadSomeModifySomeUser.
/**
* MID-3126
*/
@Test
public void test802EditSchemaJackPropReadSomeModifySomeUser() throws Exception {
given();
cleanupAutzTest(USER_JACK_OID);
assignRole(USER_JACK_OID, ROLE_PROP_READ_SOME_MODIFY_SOME_USER_OID);
login(USER_JACK_USERNAME);
Task task = getTestTask();
PrismObject<UserType> user = getUser(USER_JACK_OID);
display("user before", user);
when();
PrismObjectWrapper<UserType> objectWrapper = createObjectWrapper(task, user, ItemStatus.NOT_CHANGED);
then();
displayDumpable("Wrapper after", objectWrapper);
assertEquals("Wrong object wrapper readOnly", Boolean.FALSE, (Boolean) objectWrapper.isReadOnly());
ItemStatus objectStatus = objectWrapper.getStatus();
PrismContainerValueWrapper<UserType> mainContainerValueWrapper = objectWrapper.getValue();
PrismPropertyWrapper nameWrapper = mainContainerValueWrapper.findProperty(UserType.F_NAME);
assertEquals("Wrong name readOnly", Boolean.TRUE, (Boolean) nameWrapper.isReadOnly());
assertEquals("Wrong name visible", Boolean.TRUE, (Boolean) nameWrapper.isVisible(mainContainerValueWrapper, null));
assertEquals("Wrong name definition.canRead", Boolean.TRUE, (Boolean) nameWrapper.canRead());
assertEquals("Wrong name definition.canAdd", Boolean.FALSE, (Boolean) nameWrapper.canAdd());
assertEquals("Wrong name definition.canModify", Boolean.FALSE, (Boolean) nameWrapper.canModify());
// no access to given name, wrapper should not be even generated
PrismPropertyWrapper givenNameWrapper = mainContainerValueWrapper.findProperty(UserType.F_GIVEN_NAME);
assertNull("Unexpected givenName wrapper ", givenNameWrapper);
// assertEquals("Wrong givenName readOnly", Boolean.TRUE, (Boolean)givenNameWrapper.isReadOnly());
// // Emphasized property. But the role given no access to this. Therefore is should not be visible.
// // MID-3206
// assertEquals("Wrong givenName visible", Boolean.FALSE, (Boolean)givenNameWrapper.isVisible(mainContainerValueWrapper, null));
// assertEquals("Wrong givenName definition.canRead", Boolean.FALSE, (Boolean)givenNameWrapper.canRead());
// assertEquals("Wrong givenName definition.canAdd", Boolean.FALSE, (Boolean)givenNameWrapper.canAdd());
// assertEquals("Wrong givenName definition.canModify", Boolean.FALSE, (Boolean)givenNameWrapper.canModify());
PrismPropertyWrapper fullNameWrapper = mainContainerValueWrapper.findProperty(UserType.F_FULL_NAME);
assertEquals("Wrong fullName readOnly", Boolean.FALSE, (Boolean) fullNameWrapper.isReadOnly());
assertEquals("Wrong fullName visible", Boolean.TRUE, (Boolean) fullNameWrapper.isVisible(mainContainerValueWrapper, null));
assertEquals("Wrong fullName definition.canRead", Boolean.TRUE, (Boolean) fullNameWrapper.canRead());
assertEquals("Wrong fullName definition.canAdd", Boolean.FALSE, (Boolean) fullNameWrapper.canAdd());
assertEquals("Wrong fullName definition.canModify", Boolean.TRUE, (Boolean) fullNameWrapper.canModify());
// not created because of insufficient authZ
PrismPropertyWrapper additionalNameWrapper = mainContainerValueWrapper.findProperty(UserType.F_ADDITIONAL_NAME);
assertNull("Unexpected additional name wrapper", additionalNameWrapper);
// assertEquals("Wrong additionalName readOnly", Boolean.FALSE, (Boolean)additionalNameWrapper.isReadOnly());
// assertEquals("Wrong additionalName visible", Boolean.FALSE, (Boolean)additionalNameWrapper.isVisible(mainContainerValueWrapper, null));
// assertEquals("Wrong additionalName definition.canRead", Boolean.FALSE, (Boolean)additionalNameWrapper.canRead());
// assertEquals("Wrong additionalName definition.canAdd", Boolean.FALSE, (Boolean)additionalNameWrapper.canAdd());
// assertEquals("Wrong additionalName definition.canModify", Boolean.TRUE, (Boolean)additionalNameWrapper.canModify());
// no access to property, should not be generated
PrismPropertyWrapper localityNameWrapper = mainContainerValueWrapper.findProperty(UserType.F_LOCALITY);
assertNull("Unexpected locality wrapper", localityNameWrapper);
// assertEquals("Wrong locality readOnly", Boolean.TRUE, (Boolean)localityNameWrapper.isReadOnly()); // Is this OK?
// assertEquals("Wrong locality visible", Boolean.FALSE, (Boolean)localityNameWrapper.isVisible(mainContainerValueWrapper, null));
// assertEquals("Wrong locality definition.canRead", Boolean.FALSE, (Boolean)localityNameWrapper.canRead());
// assertEquals("Wrong locality definition.canAdd", Boolean.FALSE, (Boolean)localityNameWrapper.canAdd());
// assertEquals("Wrong locality definition.canModify", Boolean.FALSE, (Boolean)localityNameWrapper.canModify());
}
use of com.evolveum.midpoint.gui.api.prism.ItemStatus in project midpoint by Evolveum.
the class TestIntegrationObjectWrapperFactory method test160CreateWrapperOrgScummBar.
@Test
public void test160CreateWrapperOrgScummBar() throws Exception {
PrismObject<OrgType> org = getObject(OrgType.class, ORG_SCUMM_BAR_OID);
PrismObject<OrgType> orgOld = org.clone();
when();
Task task = getTestTask();
PrismObjectWrapper<OrgType> objectWrapper = createObjectWrapper(task, org, ItemStatus.NOT_CHANGED);
then();
displayDumpable("Wrapper after", objectWrapper);
WrapperTestUtil.assertWrapper(objectWrapper, getString("prismContainer.mainPanelDisplayName"), "org description", org, orgOld, ItemStatus.NOT_CHANGED);
assertContainersPaths(objectWrapper, BASIC_ORG_CONTAINERS_PATHS);
WrapperTestUtil.assertWrapper(objectWrapper, getString("prismContainer.mainPanelDisplayName"), (ItemPath) null, org, ItemStatus.NOT_CHANGED);
assertEquals("wrong number of containers in " + objectWrapper, 1, objectWrapper.getValues().size());
PrismContainerValueWrapper<OrgType> mainContainerValueWrapper = objectWrapper.getValue();
WrapperTestUtil.assertPropertyWrapperByName(mainContainerValueWrapper, OrgType.F_NAME, PrismTestUtil.createPolyString(ORG_SCUMM_BAR_NAME));
WrapperTestUtil.assertPropertyWrapperByName(mainContainerValueWrapper, OrgType.F_TIMEZONE, null);
PrismContainerWrapper<ActivationType> activationContainerWrapper = mainContainerValueWrapper.findContainer(OrgType.F_ACTIVATION);
WrapperTestUtil.assertWrapper(activationContainerWrapper, getString("ActivationType.activation"), OrgType.F_ACTIVATION, org, ItemStatus.NOT_CHANGED);
assertEquals("wrong number of containers in " + activationContainerWrapper, 1, activationContainerWrapper.getValues().size());
PrismContainerValueWrapper<ActivationType> activationContainerValueWrapper = activationContainerWrapper.getValues().iterator().next();
WrapperTestUtil.assertPropertyWrapperByName(activationContainerValueWrapper, ActivationType.F_ADMINISTRATIVE_STATUS, ActivationStatusType.ENABLED);
WrapperTestUtil.assertPropertyWrapperByName(activationContainerValueWrapper, ActivationType.F_LOCKOUT_STATUS, null);
assertEquals("Wrong main container wrapper readOnly", Boolean.FALSE, (Boolean) mainContainerValueWrapper.isReadOnly());
ItemStatus objectStatus = objectWrapper.getStatus();
assertItemWrapperFullControl(mainContainerValueWrapper, OrgType.F_NAME, true);
assertItemWrapperFullControl(mainContainerValueWrapper, OrgType.F_IDENTIFIER, true);
// not visible, because it is empty
assertItemWrapperFullControl(mainContainerValueWrapper, OrgType.F_RISK_LEVEL, false);
assertItemWrapperFullControl(mainContainerValueWrapper, OrgType.F_LOCALITY, true);
assertItemWrapperProcessing(mainContainerValueWrapper, extensionPath(PIRACY_TRANSFORM_DESCRIPTION), null);
PrismContainerWrapper<Containerable> transformContainerWrapper = mainContainerValueWrapper.findContainer(extensionPath(PIRACY_TRANSFORM));
assertEquals("Wrong processing in item wrapper for " + PIRACY_TRANSFORM, ItemProcessing.MINIMAL, transformContainerWrapper.getProcessing());
// ContainerWrapper<Containerable> transformContainerWrapper = objectWrapper.findContainer(ItemPath.create(PIRACY_TRANSFORM));
// assertEquals("Wrong processing in item wrapper for "+PIRACY_TRANSFORM, ItemProcessing.MINIMAL, transformContainerWrapper.getProcessing());
when();
mainContainerValueWrapper.setShowEmpty(true);
then();
assertItemWrapperFullControl(mainContainerValueWrapper, OrgType.F_NAME, true);
assertItemWrapperFullControl(mainContainerValueWrapper, OrgType.F_IDENTIFIER, true);
// empty
assertItemWrapperFullControl(mainContainerValueWrapper, OrgType.F_RISK_LEVEL, true);
assertItemWrapperFullControl(mainContainerValueWrapper, OrgType.F_LOCALITY, true);
ObjectDelta<OrgType> objectDelta = objectWrapper.getObjectDelta();
displayDumpable("Delta", objectDelta);
assertTrue("non-empty delta produced from wrapper: " + objectDelta, objectDelta.isEmpty());
}
use of com.evolveum.midpoint.gui.api.prism.ItemStatus in project midpoint by Evolveum.
the class TestIntegrationObjectWrapperFactory method test112CreateWrapperUserNewman.
/**
* Create wrapper for brand new user, but "fill in" some data.
*/
@Test
public void test112CreateWrapperUserNewman() throws Exception {
PrismObject<UserType> user = getUserDefinition().instantiate();
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.ADDED, context);
PrismObjectValueWrapper<UserType> mainContainerValueWrapper = objectWrapper.getValue();
WrapperTestUtil.fillInPropertyWrapper(modelServiceLocator, mainContainerValueWrapper, UserType.F_NAME, PrismTestUtil.createPolyString(USER_NEWMAN_USERNAME));
WrapperTestUtil.fillInPropertyWrapper(modelServiceLocator, mainContainerValueWrapper, UserType.F_GIVEN_NAME, PrismTestUtil.createPolyString(USER_NEWMAN_GIVEN_NAME));
WrapperTestUtil.fillInPropertyWrapper(modelServiceLocator, mainContainerValueWrapper, UserType.F_FAMILY_NAME, PrismTestUtil.createPolyString(USER_NEWMAN_FAMILY_NAME));
WrapperTestUtil.fillInPropertyWrapper(modelServiceLocator, mainContainerValueWrapper, UserType.F_EMPLOYEE_NUMBER, USER_NEWMAN_EMPLOYEE_NUMBER);
WrapperTestUtil.fillInPropertyWrapper(modelServiceLocator, mainContainerValueWrapper, extensionPath(PIRACY_SHIP), USER_NEWMAN_SHIP);
then();
displayDumpable("Wrapper after", objectWrapper);
WrapperTestUtil.assertWrapper(objectWrapper, getString("prismContainer.mainPanelDisplayName"), "user description", user, getUserDefinition().instantiate(), ItemStatus.ADDED);
assertContainersPaths(objectWrapper, BASIC_USER_CONTAINERS_PATHS);
WrapperTestUtil.assertWrapper(objectWrapper, getString("prismContainer.mainPanelDisplayName"), null, user, ItemStatus.ADDED);
assertEquals("wrong number of containers in " + objectWrapper, 1, objectWrapper.getValues().size());
WrapperTestUtil.assertPropertyWrapperByName(mainContainerValueWrapper, UserType.F_NAME, PrismTestUtil.createPolyString(USER_NEWMAN_USERNAME));
WrapperTestUtil.assertPropertyWrapperByName(mainContainerValueWrapper, UserType.F_TIMEZONE, null);
WrapperTestUtil.assertPropertyWrapper(mainContainerValueWrapper, extensionPath(PIRACY_SHIP), USER_NEWMAN_SHIP);
PrismContainerWrapper<ActivationType> activationContainerWrapper = objectWrapper.findContainer(UserType.F_ACTIVATION);
WrapperTestUtil.assertWrapper(activationContainerWrapper, getString("ActivationType.activation"), UserType.F_ACTIVATION, user, ItemStatus.ADDED);
assertEquals("wrong number of containers in " + activationContainerWrapper, 1, activationContainerWrapper.getValues().size());
assertEquals("Wrong main container wrapper readOnly", Boolean.FALSE, (Boolean) objectWrapper.isReadOnly());
assertItemWrapperProcessing(mainContainerValueWrapper, extensionPath(PIRACY_WEAPON), null);
assertItemWrapperProcessing(mainContainerValueWrapper, extensionPath(PIRACY_COLORS), ItemProcessing.AUTO);
assertItemWrapperProcessing(mainContainerValueWrapper, extensionPath(PIRACY_SECRET), ItemProcessing.IGNORE);
assertItemWrapperProcessing(mainContainerValueWrapper, extensionPath(PIRACY_RANT), ItemProcessing.MINIMAL);
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, true);
// empty
assertItemWrapperFullControl(mainContainerValueWrapper, UserType.F_LOCALITY, true);
when();
mainContainerValueWrapper.setShowEmpty(false);
then();
assertItemWrapperFullControl(mainContainerValueWrapper, UserType.F_NAME, true);
assertItemWrapperFullControl(mainContainerValueWrapper, UserType.F_GIVEN_NAME, true);
assertItemWrapperFullControl(mainContainerValueWrapper, UserType.F_FULL_NAME, true);
// not visible, because it is empty
assertItemWrapperFullControl(mainContainerValueWrapper, UserType.F_ADDITIONAL_NAME, false);
ObjectDelta<UserType> objectDelta = objectWrapper.getObjectDelta();
displayDumpable("Delta", objectDelta);
assertTrue("non-add delta produced from wrapper: " + objectDelta, objectDelta.isAdd());
PrismObject<UserType> objectToAdd = objectDelta.getObjectToAdd();
PrismAsserts.assertPropertyValue(objectToAdd, UserType.F_NAME, PrismTestUtil.createPolyString(USER_NEWMAN_USERNAME));
PrismAsserts.assertPropertyValue(objectToAdd, UserType.F_GIVEN_NAME, PrismTestUtil.createPolyString(USER_NEWMAN_GIVEN_NAME));
PrismAsserts.assertPropertyValue(objectToAdd, UserType.F_FAMILY_NAME, PrismTestUtil.createPolyString(USER_NEWMAN_FAMILY_NAME));
PrismAsserts.assertPropertyValue(objectToAdd, UserType.F_EMPLOYEE_NUMBER, USER_NEWMAN_EMPLOYEE_NUMBER);
PrismAsserts.assertPropertyValue(objectToAdd, extensionPath(PIRACY_SHIP), USER_NEWMAN_SHIP);
PrismAsserts.assertItems(objectToAdd, 5);
}
use of com.evolveum.midpoint.gui.api.prism.ItemStatus in project midpoint by Evolveum.
the class AbstractGuiIntegrationTest method getServiceLocator.
protected ModelServiceLocator getServiceLocator(final Task pageTask) {
return new ModelServiceLocator() {
@Override
public ModelService getModelService() {
return modelService;
}
@Override
public ModelInteractionService getModelInteractionService() {
return modelInteractionService;
}
@Override
public DashboardService getDashboardService() {
return dashboardService;
}
@Override
public Task createSimpleTask(String operationName) {
MidPointPrincipal user = AuthUtil.getPrincipalUser();
if (user == null) {
throw new IllegalStateException("No authenticated user");
}
return WebModelServiceUtils.createSimpleTask(operationName, SchemaConstants.CHANNEL_USER_URI, user.getFocus().asPrismObject(), taskManager);
}
@Override
public PrismContext getPrismContext() {
return prismContext;
}
@Override
public SecurityEnforcer getSecurityEnforcer() {
return securityEnforcer;
}
@Override
public SecurityContextManager getSecurityContextManager() {
return securityContextManager;
}
@NotNull
@Override
public CompiledGuiProfile getCompiledGuiProfile() {
Task task = createSimpleTask("getCompiledGuiProfile");
try {
return getModelInteractionService().getCompiledGuiProfile(task, task.getResult());
} catch (ObjectNotFoundException | SchemaException | CommunicationException | ConfigurationException | SecurityViolationException | ExpressionEvaluationException e) {
throw new SystemException(e.getMessage(), e);
}
}
@Override
public Task getPageTask() {
return pageTask;
}
@Override
public ExpressionFactory getExpressionFactory() {
return expressionFactory;
}
@Override
public LocalizationService getLocalizationService() {
return localizationService;
}
@Override
public Locale getLocale() {
return Locale.US;
}
@Override
public GuiComponentRegistry getRegistry() {
return registry;
}
@Override
public <O extends ObjectType> PrismObjectWrapperFactory<O> findObjectWrapperFactory(PrismObjectDefinition<O> objectDef) {
return registry.getObjectWrapperFactory(objectDef);
}
@Override
public <I extends Item, IW extends ItemWrapper> IW createItemWrapper(I item, ItemStatus status, WrapperContext ctx) throws SchemaException {
ItemWrapperFactory<IW, ?, ?> factory = registry.findWrapperFactory(item.getDefinition(), null);
ctx.setCreateIfEmpty(true);
return factory.createWrapper(null, item, status, ctx);
}
@Override
public <IW extends ItemWrapper, VW extends PrismValueWrapper, PV extends PrismValue> VW createValueWrapper(IW parentWrapper, PV newValue, ValueStatus status, WrapperContext context) throws SchemaException {
ItemWrapperFactory<IW, VW, PV> factory = registry.findWrapperFactory(parentWrapper, null);
return factory.createValueWrapper(parentWrapper, newValue, status, context);
}
@Override
public MidpointFormValidatorRegistry getFormValidatorRegistry() {
return null;
}
@Override
public AdminGuiConfigurationMergeManager getAdminGuiConfigurationMergeManager() {
return null;
}
@Override
public CorrelationService getCorrelationService() {
return null;
}
};
}
use of com.evolveum.midpoint.gui.api.prism.ItemStatus in project midpoint by Evolveum.
the class TestIntegrationObjectWrapperFactory method test100CreateWrapperUserJack.
@Test
public void test100CreateWrapperUserJack() throws Exception {
Task task = getTestTask();
OperationResult result = task.getResult();
when();
assertLoggedInUserOid(USER_ADMINISTRATOR_OID);
PrismObject<UserType> user = getUser(USER_JACK_OID);
PrismObject<UserType> userOld = user.clone();
PrismObjectWrapperFactory<UserType> factory = getServiceLocator(task).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);
assertEquals("wrong number of containers in " + objectWrapper, 1, objectWrapper.getValues().size());
PrismObjectValueWrapper<UserType> mainContainerValueWrapper = objectWrapper.getValue();
WrapperTestUtil.assertPropertyWrapperByName(mainContainerValueWrapper, UserType.F_NAME, PrismTestUtil.createPolyString(USER_JACK_USERNAME));
WrapperTestUtil.assertPropertyWrapperByName(mainContainerValueWrapper, UserType.F_TIMEZONE, null);
Item ship = userOld.findItem(ItemPath.create(UserType.F_EXTENSION, PIRACY_SHIP));
assertNotNull("Ship is null", ship);
WrapperTestUtil.assertPropertyWrapper(mainContainerValueWrapper, extensionPath(PIRACY_SHIP), AdminGuiTestConstants.USER_JACK_SHIP);
PrismContainerWrapper<ActivationType> activationContainerWrapper = objectWrapper.findContainer(UserType.F_ACTIVATION);
WrapperTestUtil.assertWrapper(activationContainerWrapper, getString("ActivationType.activation"), UserType.F_ACTIVATION, user, ItemStatus.NOT_CHANGED);
assertEquals("wrong number of containers in " + activationContainerWrapper, 1, activationContainerWrapper.getValues().size());
PrismContainerValueWrapper<ActivationType> activationContainerValueWrapper = activationContainerWrapper.getValues().iterator().next();
WrapperTestUtil.assertPropertyWrapperByName(activationContainerValueWrapper, ActivationType.F_ADMINISTRATIVE_STATUS, ActivationStatusType.ENABLED);
WrapperTestUtil.assertPropertyWrapperByName(activationContainerValueWrapper, ActivationType.F_LOCKOUT_STATUS, null);
assertEquals("Wrong main container wrapper readOnly", Boolean.FALSE, (Boolean) objectWrapper.isReadOnly());
ItemStatus objectStatus = objectWrapper.getStatus();
assertItemWrapperFullControl(mainContainerValueWrapper, UserType.F_NAME, true);
assertItemWrapperFullControl(mainContainerValueWrapper, UserType.F_GIVEN_NAME, true);
assertItemWrapperFullControl(mainContainerValueWrapper, UserType.F_FULL_NAME, true);
// not visible, because it is empty
assertItemWrapperFullControl(mainContainerValueWrapper, UserType.F_ADDITIONAL_NAME, false);
assertItemWrapperFullControl(mainContainerValueWrapper, UserType.F_LOCALITY, true);
assertItemWrapperProcessing(mainContainerValueWrapper, extensionPath(PIRACY_WEAPON), null);
assertItemWrapperProcessing(mainContainerValueWrapper, extensionPath(PIRACY_COLORS), ItemProcessing.AUTO);
assertItemWrapperProcessing(mainContainerValueWrapper, extensionPath(PIRACY_SECRET), ItemProcessing.IGNORE);
assertItemWrapperProcessing(mainContainerValueWrapper, extensionPath(PIRACY_RANT), ItemProcessing.MINIMAL);
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());
}
Aggregations