use of com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext in project midpoint by Evolveum.
the class TestWrapperDelta method test100modifyUserFullname.
@Test
public void test100modifyUserFullname() throws Exception {
Task task = getTestTask();
OperationResult result = task.getResult();
PrismObject<UserType> userElaineBefore = getUser(USER_ELAINE_OID);
WrapperContext ctx = new WrapperContext(task, result);
PrismObjectWrapper<UserType> objectWrapper = createObjectWrapper(userElaineBefore, ItemStatus.NOT_CHANGED, ctx);
PrismPropertyWrapper<PolyString> fullName = objectWrapper.findProperty(UserType.F_FULL_NAME);
fullName.getValue().setRealValue(PrismTestUtil.createPolyString("Sparrow-Marley"));
// GIVEN
ObjectDelta<UserType> elaineDelta = objectWrapper.getObjectDelta();
assertModificationsSize(elaineDelta, 1);
assertModification(elaineDelta, UserType.F_FULL_NAME, ModificationTypeType.REPLACE, PrismTestUtil.createPolyString("Sparrow-Marley"));
// WHEN
executeChanges(elaineDelta, null, task, result);
// THEN
PrismObject<UserType> userElaineAfter = getUser(USER_ELAINE_OID);
UserAsserter.forUser(userElaineAfter).assertFullName("Sparrow-Marley");
}
use of com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext in project midpoint by Evolveum.
the class TestWrapperDelta method test301ModifyProfilingClassLoggerOfSystemConfig.
@Test
public void test301ModifyProfilingClassLoggerOfSystemConfig() throws Exception {
Task task = getTestTask();
OperationResult result = task.getResult();
SystemConfigurationType systemConfigBefore = getSystemConfiguration();
WrapperContext ctx = new WrapperContext(task, result);
PrismObjectWrapper objectWrapper = createObjectWrapper(systemConfigBefore.asPrismContainer(), ItemStatus.NOT_CHANGED, ctx);
PrismContainerWrapper<LoggingConfigurationType> loggingConfig = objectWrapper.findContainer(SystemConfigurationType.F_LOGGING);
PrismContainerWrapper<Containerable> profilingClassLogger = loggingConfig.findContainer(ItemName.fromQName(ProfilingClassLoggerWrapperFactoryImpl.PROFILING_LOGGER_PATH));
PrismPropertyWrapper<LoggingLevelType> loggerLevel = profilingClassLogger.getValue().findProperty(ClassLoggerConfigurationType.F_LEVEL);
PrismPropertyWrapper<String> appenderLevel = profilingClassLogger.getValue().findProperty(ClassLoggerConfigurationType.F_APPENDER);
loggerLevel.getValue().setRealValue(LoggingLevelType.DEBUG);
appenderLevel.getValues().get(0).setRealValue("MIDPOINT_PROFILE_LOG");
// GIVEN
ObjectDelta<UserType> systemConfigDelta = objectWrapper.getObjectDelta();
assertModificationsSize(systemConfigDelta, 1);
assertModification(systemConfigDelta, ItemPath.create(SystemConfigurationType.F_LOGGING, LoggingConfigurationType.F_CLASS_LOGGER, ClassLoggerConfigurationType.F_LEVEL), ModificationTypeType.ADD, LoggingLevelType.DEBUG);
assertModification(systemConfigDelta, ItemPath.create(SystemConfigurationType.F_LOGGING, LoggingConfigurationType.F_CLASS_LOGGER, ClassLoggerConfigurationType.F_APPENDER), ModificationTypeType.ADD, "MIDPOINT_PROFILE_LOG");
// WHEN
executeChanges(systemConfigDelta, null, task, result);
// THEN
SystemConfigurationType systemConfigAfter = getSystemConfiguration();
loggingConfig = objectWrapper.findContainer(SystemConfigurationType.F_LOGGING);
profilingClassLogger = loggingConfig.findContainer(ItemName.fromQName(ProfilingClassLoggerWrapperFactoryImpl.PROFILING_LOGGER_PATH));
loggerLevel = profilingClassLogger.getValue().findProperty(ClassLoggerConfigurationType.F_LEVEL);
appenderLevel = profilingClassLogger.getValue().findProperty(ClassLoggerConfigurationType.F_APPENDER);
if (!loggerLevel.getValue().getRealValue().equals(LoggingLevelType.DEBUG)) {
AssertJUnit.fail("Expected value: " + LoggingLevelType.DEBUG + " after executing of changes. Values present: " + loggerLevel.getValue().getRealValue());
}
if (!appenderLevel.getValues().get(0).getRealValue().equals("MIDPOINT_PROFILE_LOG")) {
AssertJUnit.fail("Expected value: " + "MIDPOINT_PROFILE_LOG" + " after executing of changes. Values present: " + appenderLevel.getValues().get(0).getRealValue());
}
}
use of com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext in project midpoint by Evolveum.
the class TestWrapperDelta method test101modifyUserWeapon.
@Test
public void test101modifyUserWeapon() throws Exception {
Task task = getTestTask();
OperationResult result = task.getResult();
PrismObject<UserType> userElaineBefore = getUser(USER_ELAINE_OID);
WrapperContext ctx = new WrapperContext(task, result);
PrismObjectWrapper<UserType> objectWrapper = createObjectWrapper(userElaineBefore, ItemStatus.NOT_CHANGED, ctx);
PrismPropertyWrapper<String> weapon = objectWrapper.findProperty(ItemPath.create(UserType.F_EXTENSION, PIRACY_WEAPON));
for (PrismPropertyValueWrapper<String> valueWrapper : weapon.getValues()) {
valueWrapper.setRealValue(null);
}
ModelServiceLocator locator = getServiceLocator(task);
PrismPropertyValueWrapper<String> newValue = locator.createValueWrapper(weapon, new PrismPropertyValueImpl<>("revolver"), ValueStatus.ADDED, ctx);
weapon.getValues().add(newValue);
ObjectDelta<UserType> elaineDelta = objectWrapper.getObjectDelta();
assertModificationsSize(elaineDelta, 1);
assertModification(elaineDelta, ItemPath.create(UserType.F_EXTENSION, PIRACY_WEAPON), ModificationTypeType.ADD, "revolver");
assertModification(elaineDelta, ItemPath.create(UserType.F_EXTENSION, PIRACY_WEAPON), ModificationTypeType.DELETE, "pistol", "mouth");
executeChanges(elaineDelta, null, task, result);
PrismObject<UserType> userElaineAfter = getUser(USER_ELAINE_OID);
logger.info("ELAINE AFTER: {}", userElaineAfter.debugDump());
UserAsserter.forUser(userElaineAfter).extension().assertPropertyValuesEqual(PIRACY_WEAPON, "revolver");
}
use of com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext in project midpoint by Evolveum.
the class TestWrapperDelta method test310modifySystemConfigurationAddCollectionView.
@Test
public void test310modifySystemConfigurationAddCollectionView() throws Exception {
Task task = getTestTask();
OperationResult result = task.getResult();
ModelServiceLocator locator = getServiceLocator(task);
SystemConfigurationType systemConfigBefore = getSystemConfiguration();
WrapperContext ctx = new WrapperContext(task, result);
PrismObjectWrapper objectWrapper = createObjectWrapper(systemConfigBefore.asPrismContainer(), ItemStatus.NOT_CHANGED, ctx);
ItemPath guiObjectViewPath = ItemPath.create(SystemConfigurationType.F_ADMIN_GUI_CONFIGURATION, AdminGuiConfigurationType.F_OBJECT_COLLECTION_VIEWS, GuiObjectListViewsType.F_OBJECT_COLLECTION_VIEW);
PrismContainerWrapper<GuiObjectListViewType> collections = objectWrapper.findContainer(guiObjectViewPath);
// GIVEN
PrismContainerValue<GuiObjectListViewType> newCollection = collections.getItem().createNewValue();
ctx.setShowEmpty(true);
PrismContainerValueWrapper<GuiObjectListViewType> newCollectionValueWrapper = locator.createValueWrapper(collections, newCollection, ValueStatus.ADDED, ctx);
collections.getValues().add(newCollectionValueWrapper);
PrismPropertyWrapper<QName> type = newCollectionValueWrapper.findProperty(GuiObjectListViewType.F_TYPE);
type.getValue().setRealValue(new QName("RoleType"));
PrismPropertyWrapper<String> identifier = newCollectionValueWrapper.findProperty(GuiObjectListViewType.F_IDENTIFIER);
identifier.getValue().setRealValue("my-roles-collection");
// WHEN
ObjectDelta<SystemConfigurationType> delta = objectWrapper.getObjectDelta();
GuiObjectListViewType expectedValue = new GuiObjectListViewType(prismContext);
expectedValue.setIdentifier("my-roles-collection");
expectedValue.setType(new QName("RoleType"));
assertModification(delta, guiObjectViewPath, ModificationTypeType.ADD, expectedValue);
executeChanges(delta, null, task, result);
// THEN
SystemConfigurationType systemConfigAfter = getSystemConfiguration();
AdminGuiConfigurationType adminGuiConfig = systemConfigAfter.getAdminGuiConfiguration();
assertNotNull("Unexpected empty admin gui configuration.", adminGuiConfig);
GuiObjectListViewsType collectionViews = adminGuiConfig.getObjectCollectionViews();
assertNotNull("Unexpected empty gui object collection views", collectionViews);
GuiObjectListViewType myRolesCollection = null;
for (GuiObjectListViewType collectionView : collectionViews.getObjectCollectionView()) {
if ("my-roles-collection".equals(collectionView.getIdentifier())) {
myRolesCollection = collectionView;
}
}
assertNotNull("Newly added collection view not present in system configuration, something strange", myRolesCollection);
assertFalse("c:RoleType should not be equals to RoleType", RoleType.COMPLEX_TYPE.equals(myRolesCollection.getType()));
assertTrue("c:RoleType should match RoleType", QNameUtil.match(RoleType.COMPLEX_TYPE, myRolesCollection.getType()));
}
use of com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext in project midpoint by Evolveum.
the class TestWrapperDelta method test300SaveSystemConfigWithoutChanges.
@Test
public void test300SaveSystemConfigWithoutChanges() throws Exception {
Task task = getTestTask();
OperationResult result = task.getResult();
SystemConfigurationType systemConfig = getSystemConfiguration();
WrapperContext ctx = new WrapperContext(task, result);
PrismObjectWrapper<UserType> objectWrapper = createObjectWrapper(systemConfig.asPrismContainer(), ItemStatus.NOT_CHANGED, ctx);
// GIVEN
ObjectDelta<UserType> systemConfigDelta = objectWrapper.getObjectDelta();
assertModificationsSize(systemConfigDelta, 0);
}
Aggregations