@Test public void testUserSimplePropertyDiffReplace() throws Exception { System.out.println("\n\n===[ testUserSimplePropertyDiffReplace ]===\n"); // GIVEN PrismObjectDefinition<UserType> userDef = getUserTypeDefinition(); PrismObject<UserType> user1 = userDef.instantiate(); user1.setOid(USER_JACK_OID); user1.setPropertyRealValue(UserType.F_NAME, PrismTestUtil.createPolyString("test name")); PrismObject<UserType> user2 = userDef.instantiate(); user2.setOid(USER_JACK_OID); user2.setPropertyRealValue(UserType.F_NAME, PrismTestUtil.createPolyString("other name")); // WHEN ObjectDelta<UserType> delta = user1.diff(user2); // THEN assertNotNull(delta); System.out.println(delta.debugDump()); assertEquals("Unexpected number of midifications", 1, delta.getModifications().size()); PrismAsserts.assertPropertyReplace( delta, UserType.F_NAME, PrismTestUtil.createPolyString("other name")); assertEquals("Wrong OID", USER_JACK_OID, delta.getOid()); delta.checkConsistence(); }
@Test public void testUserSimpleDiffMultiAdd() throws Exception { System.out.println("\n\n===[ testUserSimpleDiffMulti ]===\n"); // GIVEN PrismObjectDefinition<UserType> userDef = getUserTypeDefinition(); PrismObject<UserType> user1 = userDef.instantiate(); user1.setOid(USER_JACK_OID); PrismProperty<String> anamesProp1 = user1.findOrCreateProperty(UserType.F_ADDITIONAL_NAMES); anamesProp1.addRealValue("foo"); anamesProp1.addRealValue("bar"); PrismObject<UserType> user2 = userDef.instantiate(); user2.setOid(USER_JACK_OID); PrismProperty<String> anamesProp2 = user2.findOrCreateProperty(UserType.F_ADDITIONAL_NAMES); anamesProp2.addRealValue("foo"); anamesProp2.addRealValue("bar"); anamesProp2.addRealValue("baz"); // WHEN ObjectDelta<UserType> delta = user1.diff(user2); // THEN assertNotNull(delta); System.out.println(delta.debugDump()); assertEquals("Unexpected number of midifications", 1, delta.getModifications().size()); PrismAsserts.assertPropertyAdd(delta, UserType.F_ADDITIONAL_NAMES, "baz"); assertEquals("Wrong OID", USER_JACK_OID, delta.getOid()); delta.checkConsistence(); }