Skip to content

Commit

Permalink
MID-8842 ninja - approval work items processor + test
Browse files Browse the repository at this point in the history
(cherry picked from commit e7e59cc)
  • Loading branch information
1azyman committed Jul 25, 2023
1 parent e2fc3c2 commit 27ae970
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@
import com.evolveum.midpoint.schema.validator.UpgradePriority;
import com.evolveum.midpoint.schema.validator.UpgradeType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentHolderType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.OtherPrivilegesLimitationType;

@SuppressWarnings("unused")
public class ApprovalWorkItemsProcessor implements UpgradeObjectProcessor<AssignmentHolderType> {

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

@Override
Expand All @@ -35,13 +36,18 @@ public UpgradeType getType() {

@Override
public boolean isApplicable(PrismObject<?> object, ItemPath path) {
// todo implement
return false;
return matchParentTypeAndItemName(
object, path, OtherPrivilegesLimitationType.class, OtherPrivilegesLimitationType.F_APPROVAL_WORK_ITEMS);
}

@Override
public boolean process(PrismObject<AssignmentHolderType> object, ItemPath path) {
// todo implement
return false;
OtherPrivilegesLimitationType limitation = getItemParent(object, path);
if (limitation.getCaseManagementWorkItems() == null) {
limitation.setCaseManagementWorkItems(limitation.getApprovalWorkItems());
}
limitation.setApprovalWorkItems(null);

return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public void test30TestSystemConfig() throws Exception {
@Test
public void test40TestRole() throws Exception {
testUpgradeValidator("role.xml", result -> {
Assertions.assertThat(result.getItems()).hasSize(1);
Assertions.assertThat(result.getItems()).hasSize(4);

UpgradeValidationItem item = assertGetItem(result, getProcessorIdentifier(PersonaTargetSubtypeProcessor.class));
UpgradeValidationItemAsserter asserter = new UpgradeValidationItemAsserter(item);
Expand Down
23 changes: 23 additions & 0 deletions infra/schema/src/test/resources/validator/expected/role.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,27 @@
</personaConstruction>
</assignment>

<assignment id="2">
<limitOtherPrivileges>
<caseManagementWorkItems>
<all>true</all>
</caseManagementWorkItems>
</limitOtherPrivileges>
</assignment>

<inducement id="3">
<limitOtherPrivileges>
<caseManagementWorkItems>
<all>true</all>
</caseManagementWorkItems>
</limitOtherPrivileges>
</inducement>

<inducement id="4">
<limitOtherPrivileges>
<caseManagementWorkItems>
<all>false</all>
</caseManagementWorkItems>
</limitOtherPrivileges>
</inducement>
</role>
26 changes: 26 additions & 0 deletions infra/schema/src/test/resources/validator/processor/role.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,30 @@
</personaConstruction>
</assignment>

<assignment id="2">
<limitOtherPrivileges>
<approvalWorkItems>
<all>true</all>
</approvalWorkItems>
</limitOtherPrivileges>
</assignment>

<inducement id="3">
<limitOtherPrivileges>
<approvalWorkItems>
<all>true</all>
</approvalWorkItems>
</limitOtherPrivileges>
</inducement>

<inducement id="4">
<limitOtherPrivileges>
<approvalWorkItems>
<all>true</all>
</approvalWorkItems>
<caseManagementWorkItems>
<all>false</all>
</caseManagementWorkItems>
</limitOtherPrivileges>
</inducement>
</role>

0 comments on commit 27ae970

Please sign in to comment.