Skip to content

Commit

Permalink
MID-8842 ninja - gui action name processor + test
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Aug 1, 2023
1 parent 6463da4 commit ddcf3ba
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright (C) 2010-2023 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/

package com.evolveum.midpoint.schema.validator.processor;

import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.schema.validator.UpgradeObjectProcessor;
import com.evolveum.midpoint.schema.validator.UpgradePhase;
import com.evolveum.midpoint.schema.validator.UpgradePriority;
import com.evolveum.midpoint.schema.validator.UpgradeType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.GuiActionType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;

@SuppressWarnings("unused")
public class GuiActionNameProcessor implements UpgradeObjectProcessor<ObjectType> {

@Override
public UpgradePhase getPhase() {
return UpgradePhase.BEFORE;
}

@Override
public UpgradePriority getPriority() {
return UpgradePriority.NECESSARY;
}

@Override
public UpgradeType getType() {
return UpgradeType.SEAMLESS;
}

@Override
public boolean isApplicable(PrismObject<?> object, ItemPath path) {
return matchParentTypeAndItemName(object, path, GuiActionType.class, GuiActionType.F_NAME);
}

@Override
public boolean process(PrismObject<ObjectType> object, ItemPath path) throws Exception {
GuiActionType action = getItemParent(object, path);
if (action.getIdentifier() == null) {
action.setIdentifier(action.getName());
}
action.setName(null);

return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ private String getProcessorIdentifier(Class<?> processorClass) {
@Test
public void test30TestSystemConfig() throws Exception {
testUpgradeValidator("system-configuration.xml", result -> {
Assertions.assertThat(result.getItems()).hasSize(13);
Assertions.assertThat(result.getItems()).hasSize(15);

UpgradeValidationItem item = assertGetItem(result, getProcessorIdentifier(RoleCatalogCollectionsProcessor.class));
Assertions.assertThat(item.getDelta().getModifiedItems()).hasSize(2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,16 @@
</formSpecification>
</objectForm>
</objectForms>
<objectCollectionViews>
<objectCollectionView id="3">
<action id="4">
<identifier>action1</identifier>
</action>
<action id="5">
<identifier>action2</identifier>
</action>
</objectCollectionView>
</objectCollectionViews>
<accessRequest>
<roleCatalog>
<roleCatalogRef oid="0e5b7304-ea5c-438e-84d1-2b0ce40517ce" type="OrgType"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,16 @@
</formSpecification>
</objectForm>
</objectForms>
<objectCollectionViews>
<objectCollectionView id="3">
<action id="4">
<name>action1</name>
</action>
<action id="5">
<name>action2</name>
</action>
</objectCollectionView>
</objectCollectionViews>
</adminGuiConfiguration>

<defaultObjectPolicyConfiguration id="2">
Expand Down

0 comments on commit ddcf3ba

Please sign in to comment.