Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/support-4.0' into s…
Browse files Browse the repository at this point in the history
…upport-4.0
  • Loading branch information
skublik committed Sep 9, 2020
2 parents 4386481 + 1e87d19 commit 385739b
Show file tree
Hide file tree
Showing 9 changed files with 2,326 additions and 7 deletions.
Expand Up @@ -1139,7 +1139,10 @@ private String buildRelation(ObjectReferenceType roleMembershipRef, String relat
if (!StringUtils.isBlank(relation)) {
relation += ",";
}
relation += assignmentRelation.getLocalPart();
String relationDisplayName = WebComponentUtil.getRelationHeaderLabelKeyIfKnown(assignmentRelation);
relation += StringUtils.isNotEmpty(relationDisplayName) ?
getPageBase().createStringResource(relationDisplayName).getString() :
getPageBase().createStringResource(assignmentRelation.getLocalPart()).getString();
}
}
return relation;
Expand Down
Expand Up @@ -872,7 +872,9 @@ public ItemDelta<V,D> narrow(PrismObject<? extends Objectable> object, Comparato
}
}
if (clone.getValuesToAdd() != null) {
clone.getValuesToAdd().removeIf(valueToAdd -> currentItem.containsEquivalentValue(valueToAdd, comparator));
clone.getValuesToAdd().removeIf(
valueToAdd -> currentItem.containsEquivalentValue(valueToAdd, comparator)
&& !containsEquivalentValue(clone.getValuesToDelete(), valueToAdd));
if (clone.getValuesToAdd().isEmpty()) {
clone.resetValuesToAdd();
}
Expand Down
Expand Up @@ -65,6 +65,8 @@ public class TestParseDiffPatch {
private static final File RESOURCE_AFTER_CONST_FILE = new File(TEST_DIR, "resource-after-const.xml");
private static final File RESOURCE_AFTER_NS_CHANGE_FILE = new File(TEST_DIR, "resource-after-ns-change.xml");
private static final String RESOURCE_OID = "ef2bc95b-76e0-59e2-86d6-3d4f02d3ffff";
private static final File SYSTEM_CONFIGURATION_BEFORE_FILE = new File(TEST_DIR, "system-configuration-before.xml");
private static final File SYSTEM_CONFIGURATION_AFTER_FILE = new File(TEST_DIR, "system-configuration-after.xml");

@BeforeSuite
public void setup() throws SchemaException, SAXException, IOException {
Expand Down Expand Up @@ -902,4 +904,59 @@ public void testDiffSingleContainerValues() {
//noinspection SimplifiedTestNGAssertion
assertEquals("Wrong values to replace", null, diff.getValuesToReplace());
}
/**
* MID-6063
*/
@Test
public void testSystemConfigurationDiff() throws Exception {
System.out.println("===[ testSystemConfigurationDiff ]===");

PrismObject<SystemConfigurationType> before = PrismTestUtil.parseObject(SYSTEM_CONFIGURATION_BEFORE_FILE);
before.checkConsistence();
PrismObject<SystemConfigurationType> after = PrismTestUtil.parseObject(SYSTEM_CONFIGURATION_AFTER_FILE);
after.checkConsistence();

ObjectDelta<SystemConfigurationType> delta = before.diff(after, EquivalenceStrategy.LITERAL);
System.out.println("DELTA:");
System.out.println(delta.debugDump());

before.checkConsistence();
after.checkConsistence();
delta.checkConsistence();
delta.assertDefinitions();

PrismObject<SystemConfigurationType> workingCopy = before.clone();
delta.applyTo(workingCopy);
PrismAsserts.assertEquals("before + delta is different from after", after, workingCopy);
}

/**
* MID-6063
*/
@Test
public void testSystemConfigurationDiffPlusNarrow() throws Exception {
System.out.println("===[ testSystemConfigurationDiffPlusNarrow ]===");

PrismObject<SystemConfigurationType> before = PrismTestUtil.parseObject(SYSTEM_CONFIGURATION_BEFORE_FILE);
before.checkConsistence();
PrismObject<SystemConfigurationType> after = PrismTestUtil.parseObject(SYSTEM_CONFIGURATION_AFTER_FILE);
after.checkConsistence();

ObjectDelta<SystemConfigurationType> delta = before.diff(after, EquivalenceStrategy.LITERAL);
System.out.println("DELTA:");
System.out.println(delta.debugDump());

ObjectDelta<SystemConfigurationType> deltaNarrowed = delta.narrow(before, true);
System.out.println("DELTA NARROWED:");
System.out.println(deltaNarrowed.debugDump());

before.checkConsistence();
after.checkConsistence();
deltaNarrowed.checkConsistence();
deltaNarrowed.assertDefinitions();

PrismObject<SystemConfigurationType> workingCopy = before.clone();
deltaNarrowed.applyTo(workingCopy);
PrismAsserts.assertEquals("before + delta (narrowed) is different from after", after, workingCopy);
}
}

0 comments on commit 385739b

Please sign in to comment.