private PrismValue clone(PrismValue value) { if (value == null) { return null; } PrismValue cloned = value.clone(); cloned.setOriginType(OriginType.USER_ACTION); if (value instanceof PrismPropertyValue) { PrismPropertyValue ppValue = (PrismPropertyValue) value; if (ppValue.getValue() instanceof ProtectedStringType) { ((PrismPropertyValue) cloned).setValue(((ProtectedStringType) ppValue.getValue()).clone()); } if (ppValue.getValue() instanceof PolyString) { PolyString poly = (PolyString) ppValue.getValue(); if (StringUtils.isEmpty(poly.getOrig())) { return null; } ((PrismPropertyValue) cloned).setValue(new PolyString(poly.getOrig(), poly.getNorm())); } } else if (value instanceof PrismReferenceValue) { if (cloned == null) { return null; } if (cloned.isEmpty()) { return null; } } return cloned; }
private void assertMultivaluePolyString( String message, String expectedOrigs[], Collection<PolyString> actualPolyStrings, OperationResult result) { if (expectedOrigs.length != actualPolyStrings.size()) { fail( message + ": expected " + expectedOrigs.length + " values but has " + actualPolyStrings.size() + " values: " + actualPolyStrings, result); return; } for (String expectedOrig : expectedOrigs) { boolean found = false; for (PolyString actualPolyString : actualPolyStrings) { if (expectedOrig.equals(actualPolyString.getOrig())) { found = true; assertEquals( message + ", norm", polyStringNorm(expectedOrig), actualPolyString.getNorm(), result); break; } } if (!found) { fail( message + ": expected value '" + expectedOrig + "' not found in actual values " + actualPolyStrings, result); return; } } }
private PolyString toPolyString(String orig) { PolyString polyString = new PolyString(orig); polyString.recompute(prismContext.getDefaultPolyStringNormalizer()); return polyString; }
private void assertPolyString( String message, String expectedOrig, PolyString actualPolyString, OperationResult result) { assertEquals(message + ", orig", expectedOrig, actualPolyString.getOrig(), result); assertEquals( message + ", norm", polyStringNorm(expectedOrig), actualPolyString.getNorm(), result); }
public PolyStringType(PolyString polyString) { this.orig = polyString.getOrig(); this.norm = polyString.getNorm(); }