Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
jdereg committed Oct 5, 2024
2 parents 48b9636 + c71567e commit 0a92d0f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
java.sql,
java.xml</Import-Package>
<Export-Package>
com.cedarsoftware.util
com.cedarsoftware.util,
com.cedarsoftware.util.convert
</Export-Package>
<DynamicImport-Package>*</DynamicImport-Package>
Expand Down
38 changes: 23 additions & 15 deletions src/test/java/com/cedarsoftware/util/TestGraphComparator.java
Original file line number Diff line number Diff line change
Expand Up @@ -629,23 +629,31 @@ public void testNewArrayElement() throws Exception

List<GraphComparator.Delta> deltas = GraphComparator.compare(persons[0], persons[1], getIdFetcher());
assertTrue(deltas.size() == 3);
GraphComparator.Delta delta = deltas.get(0);
assertTrue(ARRAY_SET_ELEMENT == delta.getCmd());
assertTrue("pets".equals(delta.getFieldName()));
assertTrue(0 == (Integer) delta.getOptionalKey());
assertTrue(persons[1].pets[0].equals(delta.getTargetValue()));
assertTrue((Long) delta.getId() == id);

delta = deltas.get(1);
assertTrue(OBJECT_ASSIGN_FIELD == delta.getCmd());
assertTrue("favoritePet".equals(delta.getFieldName()));
assertTrue(null == delta.getOptionalKey());
assertTrue(persons[1].pets[0].equals(delta.getTargetValue()));
assertTrue((Long) delta.getId() == id);
boolean arraySetElementFound = false;
boolean objectAssignFieldFound = false;
boolean objectOrphanFound = false;


for (GraphComparator.Delta delta : deltas) {
if (ARRAY_SET_ELEMENT == delta.getCmd()) {
assertTrue("pets".equals(delta.getFieldName()));
assertTrue(0 == (Integer)delta.getOptionalKey());
assertTrue(persons[1].pets[0].equals(delta.getTargetValue()));
assertTrue(id == (Long) delta.getId());
arraySetElementFound = true;
} else if (OBJECT_ASSIGN_FIELD == delta.getCmd()) {
assertTrue("favoritePet".equals(delta.getFieldName()));
assertTrue(delta.getOptionalKey() == null);
assertTrue(persons[1].pets[0].equals(delta.getTargetValue()));
assertTrue(id == (Long) delta.getId());
objectAssignFieldFound = true;
} else if (OBJECT_ORPHAN == delta.getCmd()) {
assertTrue(edId == (Long) delta.getId());
objectOrphanFound = true;
}
}

delta = deltas.get(2);
assertTrue(OBJECT_ORPHAN == delta.getCmd());
assertTrue(edId == (Long) delta.getId());

GraphComparator.applyDelta(persons[0], deltas, getIdFetcher(), GraphComparator.getJavaDeltaProcessor());
assertTrue(DeepEquals.deepEquals(persons[0], persons[1]));
Expand Down

0 comments on commit 0a92d0f

Please sign in to comment.