Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Mar 19, 2020
2 parents 4a0f512 + 1e19652 commit 8c1b0b5
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 10 deletions.
Expand Up @@ -35,32 +35,32 @@ public PrismPropertyValueWrapper(ItemWrapper<?, ?, ?, ?> parent, PrismPropertyVa
private static final long serialVersionUID = 1L;

@Override
public void setRealValue(T realValue) {
public void setRealValue(T newRealValue) {

realValue = trimValueIfNeeded(realValue);
newRealValue = trimValueIfNeeded(newRealValue);

if (realValue == null) {
if (newRealValue == null) {
getNewValue().setValue(null);
setStatus(ValueStatus.DELETED);
return;
}

if (realValue instanceof QName) {
if (QNameUtil.match((QName) realValue, (QName) getNewValue())) {
if (newRealValue instanceof QName) {
if (QNameUtil.match((QName) newRealValue, (QName) getRealValue())) {
return;
}
} else if (realValue instanceof ItemPath) {
if (((ItemPath) realValue).equivalent((ItemPath) getNewValue())) {
} else if (newRealValue instanceof ItemPath) {
if (((ItemPath) newRealValue).equivalent((ItemPath) getRealValue())) {
return;
}
} else {
if (realValue.equals(getNewValue())) {
if (newRealValue.equals(getRealValue())) {
return;
}
}


getNewValue().setValue(realValue);
getNewValue().setValue(newRealValue);
setStatus(ValueStatus.MODIFIED);
}

Expand Down
Expand Up @@ -10,6 +10,7 @@
import com.evolveum.midpoint.gui.api.prism.PrismContainerWrapper;
import com.evolveum.midpoint.gui.api.prism.PrismObjectWrapper;
import com.evolveum.midpoint.gui.api.util.ModelServiceLocator;
import com.evolveum.midpoint.gui.api.util.WebPrismUtil;
import com.evolveum.midpoint.gui.impl.factory.PrismObjectWrapperFactory;
import com.evolveum.midpoint.gui.impl.factory.ProfilingClassLoggerWrapperFactoryImpl;
import com.evolveum.midpoint.gui.impl.factory.WrapperContext;
Expand All @@ -33,8 +34,10 @@
import com.evolveum.midpoint.schema.util.ObjectTypeUtil;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.test.asserter.UserAsserter;
import com.evolveum.midpoint.util.QNameUtil;
import com.evolveum.midpoint.web.AbstractInitializedGuiIntegrationTest;
import com.evolveum.midpoint.web.component.prism.ValueStatus;
import com.evolveum.midpoint.web.page.admin.reports.dto.ReportDeleteDialogDto;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import com.evolveum.prism.xml.ns._public.types_3.ItemPathType;
import com.evolveum.prism.xml.ns._public.types_3.ModificationTypeType;
Expand Down Expand Up @@ -323,7 +326,7 @@ public void test301ModifyProfilingClassLoggerOfSystemConfig() throws Exception {
SystemConfigurationType systemConfigBefore = getSystemConfiguration();

WrapperContext ctx = new WrapperContext(task, result);
PrismObjectWrapper objectWrapper =createObjectWrapper(systemConfigBefore.asPrismContainer(), ItemStatus.NOT_CHANGED, ctx);
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));
Expand Down Expand Up @@ -359,6 +362,94 @@ public void test301ModifyProfilingClassLoggerOfSystemConfig() throws Exception {

}

@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("Unexpecteed empty admin gui configuration.", adminGuiConfig);

GuiObjectListViewsType collectionViews = adminGuiConfig.getObjectCollectionViews();
assertNotNull("Unexpected empty gui obejct 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 eqals to RoleType", RoleType.COMPLEX_TYPE.equals(myRolesCollection.getType()));
assertTrue("c:RoleType should match RoleType", QNameUtil.match(RoleType.COMPLEX_TYPE, myRolesCollection.getType()));

}

@Test
public void test311modifySystemConfigurationModifyCollectionType() 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);

PrismContainerValueWrapper<GuiObjectListViewType> foundCollection = null;
for (PrismContainerValueWrapper<GuiObjectListViewType> collection : collections.getValues()) {
GuiObjectListViewType collectionRealValue = collection.getRealValue();
if ("my-roles-collection".equals(collectionRealValue.getIdentifier())) {
foundCollection = collection;
break;
}
}
// GIVEN
PrismPropertyWrapper<QName> collectionType = foundCollection.findProperty(GuiObjectListViewType.F_TYPE);
collectionType.getValue().setRealValue(RoleType.COMPLEX_TYPE);

// WHEN
ObjectDelta<SystemConfigurationType> systemConfigDelta = objectWrapper.getObjectDelta();
assertTrue("Delta should be empty!", systemConfigDelta.isEmpty());

}

private PrismContainerValue<AssignmentType> createDummyResourceAssignment(PrismObjectWrapper<UserType> objectWrapper, int existingAssignments, Task task, OperationResult result) throws Exception {
PrismContainerWrapper<AssignmentType> assignment = objectWrapper.findContainer(UserType.F_ASSIGNMENT);
assertNotNull("unexpected null assignment wrapper", assignment);
Expand Down

0 comments on commit 8c1b0b5

Please sign in to comment.