@Test public void testIncludeCollectionAttribute() { final Person a = new Person("Gulen Chongtham", Arrays.asList("Hola Espanyol", "Vicky Boss")); final Person b = new Person( "Gulen Chongthamm", Arrays.asList("Hola Espanyol", "Vicky Boss", "Roger Harper")); final ObjectDifferBuilder builder = ObjectDifferBuilder.startBuilding(); builder.inclusion().include().node(NodePath.with("aliases")); final ObjectDiffer differ = builder.build(); final DiffNode root = differ.compare(b, a); root.visit(new PrintingVisitor(b, a)); NodeAssertions.assertThat(root).root().hasChanges(); }
@Test public void testCircularReferenceShouldBeAddedWhenEnabledInConfiguration() { final ObjectWithCircularReference workingA = new ObjectWithCircularReference("a"); final ObjectWithCircularReference workingB = new ObjectWithCircularReference("b"); final ObjectWithCircularReference workingC = new ObjectWithCircularReference("c"); workingA.setReference(workingB); workingB.setReference(workingC); workingC.setReference(workingA); final ObjectWithCircularReference baseA = new ObjectWithCircularReference("a"); final ObjectWithCircularReference baseB = new ObjectWithCircularReference("b"); final ObjectWithCircularReference baseC = new ObjectWithCircularReference("d"); baseA.setReference(baseB); baseB.setReference(baseC); baseC.setReference(baseA); final ObjectDiffer objectDiffer = ObjectDifferBuilder.buildDefault(); // objectDiffer.getConfiguration().withoutCircularNodes(); final DiffNode root = objectDiffer.compare(workingA, baseA); root.visit(new PrintingVisitor(workingA, baseA)); assertThat(root).child("reference", "reference", "reference").isCircular(); }