Search in sources :

Example 11 with WrapperContext

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");
}
Also used : WrapperContext(com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext) Task(com.evolveum.midpoint.task.api.Task) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) 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 WrapperContext

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());
    }
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) PrismObjectWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismObjectWrapper) WrapperContext(com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext) AbstractInitializedGuiIntegrationTest(com.evolveum.midpoint.web.AbstractInitializedGuiIntegrationTest) Test(org.testng.annotations.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 13 with WrapperContext

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");
}
Also used : WrapperContext(com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext) Task(com.evolveum.midpoint.task.api.Task) ModelServiceLocator(com.evolveum.midpoint.gui.api.util.ModelServiceLocator) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) AbstractInitializedGuiIntegrationTest(com.evolveum.midpoint.web.AbstractInitializedGuiIntegrationTest) Test(org.testng.annotations.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 14 with WrapperContext

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()));
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ModelServiceLocator(com.evolveum.midpoint.gui.api.util.ModelServiceLocator) QName(javax.xml.namespace.QName) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) PrismObjectWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismObjectWrapper) WrapperContext(com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) AbstractInitializedGuiIntegrationTest(com.evolveum.midpoint.web.AbstractInitializedGuiIntegrationTest) Test(org.testng.annotations.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 15 with WrapperContext

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);
}
Also used : WrapperContext(com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext) Task(com.evolveum.midpoint.task.api.Task) 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)

Aggregations

WrapperContext (com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext)46 Task (com.evolveum.midpoint.task.api.Task)32 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)28 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)15 AbstractInitializedGuiIntegrationTest (com.evolveum.midpoint.web.AbstractInitializedGuiIntegrationTest)15 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)15 Test (org.testng.annotations.Test)15 ModelServiceLocator (com.evolveum.midpoint.gui.api.util.ModelServiceLocator)11 ItemStatus (com.evolveum.midpoint.gui.api.prism.ItemStatus)9 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)7 RestartResponseException (org.apache.wicket.RestartResponseException)5 PrismObjectWrapper (com.evolveum.midpoint.gui.api.prism.wrapper.PrismObjectWrapper)4 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)4 QName (javax.xml.namespace.QName)4 SystemException (com.evolveum.midpoint.util.exception.SystemException)3 NotNull (org.jetbrains.annotations.NotNull)3 PrismObjectWrapperFactory (com.evolveum.midpoint.gui.api.factory.wrapper.PrismObjectWrapperFactory)2 ItemWrapper (com.evolveum.midpoint.gui.api.prism.wrapper.ItemWrapper)2 ShadowWrapper (com.evolveum.midpoint.gui.api.prism.wrapper.ShadowWrapper)2 PrismPropertyValueWrapper (com.evolveum.midpoint.gui.impl.prism.wrapper.PrismPropertyValueWrapper)2