Skip to content

Commit

Permalink
MID-8842 ninja - subtype processor + test
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Jul 25, 2023
1 parent 51c4387 commit d538181
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* 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.ObjectType;

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

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

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

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

@Override
public String upgradeDescription(PrismObject<ObjectType> object, ItemPath path) {
return "Subtype should be replaced by archetypes. See documentation for more information.";
}

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

@Override
public boolean process(PrismObject<ObjectType> object, ItemPath path) throws Exception {
return false;
}
}
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(4);
Assertions.assertThat(result.getItems()).hasSize(5);

UpgradeValidationItem item = assertGetItem(result, getProcessorIdentifier(PersonaTargetSubtypeProcessor.class));
UpgradeValidationItemAsserter asserter = new UpgradeValidationItemAsserter(item);
Expand Down
2 changes: 2 additions & 0 deletions infra/schema/src/test/resources/validator/expected/role.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

<name>role</name>

<subtype>some deprecated type</subtype>

<assignment id="1">
<personaConstruction>
<targetType>some-type</targetType>
Expand Down
2 changes: 2 additions & 0 deletions infra/schema/src/test/resources/validator/processor/role.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

<name>role</name>

<subtype>some deprecated type</subtype>

<assignment id="1">
<personaConstruction>
<targetType>some-type</targetType>
Expand Down

0 comments on commit d538181

Please sign in to comment.