@Test public void compareObjectsReplaced() { TestPerson newPerson = SerializationUtils.clone(oldPerson); TestAttribute defaultAttribute = new TestAttribute(); defaultAttribute.setId(2L); defaultAttribute.setValue("changed value"); newPerson.setDefaultAttribute(defaultAttribute); AcmDiff diff = diffService.compareObjects(oldPerson, newPerson); assertEquals(1, diff.getChangesAsList().size()); AcmChange change = diff.getChangesAsList().get(0); assertTrue(change instanceof AcmObjectReplaced); AcmObjectReplaced acmObjectReplaced = (AcmObjectReplaced) change; assertEquals(acmObjectReplaced.getOldObject(), oldPerson.getDefaultAttribute()); assertEquals(acmObjectReplaced.getNewObject(), defaultAttribute); assertEquals("Value 4", acmObjectReplaced.getOldValue()); assertEquals("changed value", acmObjectReplaced.getNewValue()); }
public AcmDiff compareObjects(Object oldObj, Object newObj) { Map<Object, List<AcmChange>> alreadyProcessed = new HashMap<>(); AcmObjectChange acmObjectChange = compareObjects(null, null, oldObj, newObj, alreadyProcessed); AcmDiff diff = new AcmObjectDiff(acmObjectChange, getObjectConverter()); return diff; }
AcmDiffService { public AcmDiff compareObjects(Object oldObj, Object newObj) { Map<Object, List<AcmChange>> alreadyProcessed = new HashMap<>(); AcmObjectChange acmObjectChange = compareObjects(null, null, oldObj, newObj, alreadyProcessed); AcmDiff diff = new AcmObjectDiff(acmObjectChange, getObjectConverter()); return diff; } }
AcmDiffService { public AcmDiff compareObjects(Object oldObj, Object newObj) { Map<Object, List<AcmChange>> alreadyProcessed = new HashMap<>(); AcmObjectChange acmObjectChange = compareObjects(null, null, oldObj, newObj, alreadyProcessed); AcmDiff diff = new AcmObjectDiff(acmObjectChange, getObjectConverter()); return diff; }  }
AcmDiffService { public AcmDiff compareObjects(Object oldObj, Object newObj) { Map<Object, List<AcmChange>> alreadyProcessed = new HashMap<>(); AcmObjectChange acmObjectChange = compareObjects(null, null, oldObj, newObj, alreadyProcessed); AcmDiff diff = new AcmObjectDiff(acmObjectChange, getObjectConverter()); return diff; }  void initConfigurationMap(); AcmDiff compareObjects(Object oldObj, Object newObj); AcmCollectionChange compareCollections(Collection oldCollection, Collection newCollection); ObjectConverter getObjectConverter(); void setObjectConverter(ObjectConverter objectConverter); String getJsonConfiguration(); void setJsonConfiguration(String jsonConfiguration); }
AcmDiffService { public AcmDiff compareObjects(Object oldObj, Object newObj) { Map<Object, List<AcmChange>> alreadyProcessed = new HashMap<>(); AcmObjectChange acmObjectChange = compareObjects(null, null, oldObj, newObj, alreadyProcessed); AcmDiff diff = new AcmObjectDiff(acmObjectChange, getObjectConverter()); return diff; }  void initConfigurationMap(); AcmDiff compareObjects(Object oldObj, Object newObj); AcmCollectionChange compareCollections(Collection oldCollection, Collection newCollection); ObjectConverter getObjectConverter(); void setObjectConverter(ObjectConverter objectConverter); String getJsonConfiguration(); void setJsonConfiguration(String jsonConfiguration);  }