public boolean isRealValueToAdd(PrismPropertyValue<?> value) { if (valuesToAdd == null) { return false; } for (PrismPropertyValue valueToAdd : valuesToAdd) { if (valueToAdd.equals(value, EquivalenceStrategy.REAL_VALUE)) { return true; } } return false; }
public static boolean containsRealValue(Collection<PrismPropertyValue<?>> collection, PrismPropertyValue<?> value) { for (PrismPropertyValue<?> colVal: collection) { if (value.equals(colVal, EquivalenceStrategy.REAL_VALUE)) { return true; } } return false; }
public boolean isRealValueToDelete(PrismPropertyValue<?> value) { if (valuesToDelete == null) { return false; } for (PrismPropertyValue valueToAdd : valuesToDelete) { if (valueToAdd.equals(value, EquivalenceStrategy.REAL_VALUE)) { return true; } } return false; }
public PropertyDelta<T> narrow(PrismObject<? extends Objectable> object, final MatchingRule<T> matchingRule) { Comparator<PrismPropertyValue<T>> comparator = (o1, o2) -> { if (o1.equals(o2, EquivalenceStrategy.IGNORE_METADATA, matchingRule)) { return 0; } else { return 1; } }; return (PropertyDelta<T>) super.narrow(object, comparator); }
public boolean hasRealValue(PrismPropertyValue<T> value) { for (PrismPropertyValue<T> propVal : getValues()) { if (propVal.equals(value, EquivalenceStrategy.REAL_VALUE)) { return true; } } return false; }
public boolean isRedundant(PrismObject<? extends Objectable> object, final MatchingRule<T> matchingRule) { Comparator<PrismPropertyValue<T>> comparator = (o1, o2) -> { if (o1.equals(o2, EquivalenceStrategy.IGNORE_METADATA, matchingRule)) { return 0; } else { return 1; } }; return super.isRedundant(object, comparator); }
public boolean deleteValue(PrismPropertyValue<T> pValueToDelete) { checkMutability(); Iterator<PrismPropertyValue<T>> iterator = getValues().iterator(); boolean found = false; while (iterator.hasNext()) { PrismPropertyValue<T> pValue = iterator.next(); if (pValue.equals(pValueToDelete, EquivalenceStrategy.REAL_VALUE)) { iterator.remove(); pValue.setParent(null); found = true; } } if (!found) { LOGGER.warn("Deleting value of property "+ getElementName()+" that does not exist (skipping), value: "+pValueToDelete); } return found; }
public void addValue(PrismPropertyValue<T> pValueToAdd) { checkMutability(); ((PrismPropertyValueImpl<T>) pValueToAdd).checkValue(); Iterator<PrismPropertyValue<T>> iterator = getValues().iterator(); while (iterator.hasNext()) { PrismPropertyValue<T> pValue = iterator.next(); if (pValue.equals(pValueToAdd, EquivalenceStrategy.REAL_VALUE)) { LOGGER.warn("Adding value to property "+ getElementName()+" that already exists (overwriting), value: "+pValueToAdd); iterator.remove(); } } pValueToAdd.setParent(this); pValueToAdd.recompute(); getValues().add(pValueToAdd); }
if (o1.equals(o2, EquivalenceStrategy.IGNORE_METADATA, matchingRule)) { return 0; } else {
@Test public void testPasswordChange() throws Exception { System.out.println("===[ testPasswordChange ]===="); ObjectModificationType objectChange = PrismTestUtil.parseAtomicValue(new File(TEST_DIR, "user-modify-password.xml"), ObjectModificationType.COMPLEX_TYPE); // WHEN ObjectDelta<UserType> objectDelta = DeltaConvertor.createObjectDelta(objectChange, UserType.class, getPrismContext()); // THEN assertNotNull("No object delta", objectDelta); objectDelta.checkConsistence(); assertEquals("Wrong OID", "c0c010c0-d34d-b33f-f00d-111111111111", objectDelta.getOid()); PropertyDelta<ProtectedStringType> protectedStringDelta = objectDelta.findPropertyDelta(CREDENTIALS_PASSWORD_VALUE_PATH); assertNotNull("No protectedString delta", protectedStringDelta); Collection<PrismPropertyValue<ProtectedStringType>> valuesToReplace = protectedStringDelta.getValuesToReplace(); assertEquals("Wrong number of values to replace", 1, valuesToReplace.size()); PrismPropertyValue<ProtectedStringType> protectedStringVal = valuesToReplace.iterator().next(); assertNotNull("Null value in protectedStringDelta", protectedStringVal); PrismObject<UserType> user = PrismTestUtil.parseObject(USER_JACK_FILE); // apply to user objectDelta.applyTo(user); PrismProperty<ProtectedStringType> protectedStringProperty = user.findProperty(CREDENTIALS_PASSWORD_VALUE_PATH); PrismPropertyValue<ProtectedStringType> protectedStringPropertyValue = protectedStringProperty.getValue(); assertTrue("protectedString not equivalent", protectedStringPropertyValue.equals(protectedStringVal, EquivalenceStrategy.REAL_VALUE)); objectDelta.assertDefinitions(); }
@Test public void testUnmarshallAndEqualsResource() throws JAXBException, SchemaException, FileNotFoundException { System.out.println("\n\n ===[testUnmarshallAndEqualsResource]===\n"); // GIVEN ResourceType resource1Type = JaxbTestUtil.getInstance().unmarshalObject(new File(RESOURCE_OPENDJ_FILENAME), ResourceType.class); assertNotNull(resource1Type); System.out.println("Resource1 " + resource1Type.asPrismObject().debugDump()); PrismObject resource1 = resource1Type.asPrismObject(); ResourceType resource2Type = JaxbTestUtil.getInstance().unmarshalObject(new File(RESOURCE_OPENDJ_FILENAME), ResourceType.class); assertNotNull(resource2Type); System.out.println("Resource2 " + resource2Type.asPrismObject().debugDump()); PrismObject resource2 = resource2Type.asPrismObject(); // WHEN, THEN ObjectDelta<ResourceType> objectDelta = resource1.diff(resource2); System.out.println("Resource delta:"); System.out.println(objectDelta.debugDump()); assertTrue("Resource delta is not empty", objectDelta.isEmpty()); assertTrue("Resource not equal", resource1Type.equals(resource2Type)); System.out.println("HASH"); System.out.println(resource1Type.hashCode()); System.out.println(resource2Type.hashCode()); assertTrue("Resource hashcode does not match", resource1Type.hashCode() == resource2Type.hashCode()); PrismPropertyValue<Object> pv1 = getPrismContext().itemFactory().createPropertyValue(resource1Type.getConnectorConfiguration()); PrismPropertyValue<Object> pv2 = getPrismContext().itemFactory().createPropertyValue(resource2Type.getConnectorConfiguration()); assertTrue("Real property values not equal",pv1.equals(pv2, EquivalenceStrategy.REAL_VALUE)); }