Package de.danielbechler.diff

Examples of de.danielbechler.diff.ObjectDifferBuilder.build()


    final ObjectDifferBuilder builder = ObjectDifferBuilder.startBuilding();

    // (Option 1) Causes the ObjectDiffer to ignore the 'password' property of the root object
    builder.inclusion().exclude().node(NodePath.with("password"));

    final DiffNode node = builder.build().compare(working, base);

    node.visit(new PrintingVisitor(working, base));

    // Output with ignore: Property at path '/' has not changed
    // Output without ignore: Property at path '/password' has changed from [ 1234 ] to [ 9876 ]
View Full Code Here


    // (Option 1) Causes the ObjectDiffer to compare using the method "getProp1" on the 'prop' property of the root object
    builder.comparison()
        .ofNode(NodePath.with("prop"))
        .toUseEqualsMethodOfValueProvidedByMethod("getProp1");

    final DiffNode node = builder.build().compare(working, base);

    node.visit(new PrintingVisitor(working, base));

    // Output with ignore:
    //  Property at path '/' has not changed
View Full Code Here

    assertThat(verification).child(nodePath).hasState(DiffNode.State.CHANGED).hasChildren(1);

    // verify that the node can't be found, when it's excluded
    final ObjectDifferBuilder objectDifferBuilder = ObjectDifferBuilder.startBuilding();
    objectDifferBuilder.inclusion().exclude().node(nodePath);
    objectDiffer = objectDifferBuilder.build();
    final DiffNode node = objectDiffer.compare(obj1, modifiedObj1);
    node.visit(new PrintingVisitor(obj1, modifiedObj1));
    assertThat(node).child(nodePath).doesNotExist();
  }
}
View Full Code Here

  {
    final Map<String, ObjectWithString> base = Collections.emptyMap();
    final Map<String, ObjectWithString> working = Collections.singletonMap("foo", new ObjectWithString("bar"));

    final ObjectDifferBuilder objectDifferBuilder = ObjectDifferBuilder.startBuilding();
    final ObjectDiffer differ = objectDifferBuilder.build();

    final DiffNode node = differ.compare(working, base);

    node.visit(new NodeHierarchyVisitor());
View Full Code Here

    final Thing thingOne = new Thing("a", "b");
    final Thing thingTwo = new Thing("aa", "bb");

    final ThingHolder first = new ThingHolder(singleton(thingOne), "ignore", "include");
    final ThingHolder second = new ThingHolder(singleton(thingTwo), "ignore this change", "include");
    final DiffNode compareResults = builder.build().compare(first, second);

    assertThat(compareResults.isChanged(), is(true));
  }

  private class Thing
View Full Code Here

    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();
View Full Code Here

  @BeforeMethod
  public void setUp() throws Exception
  {
    final ObjectDifferBuilder objectDifferBuilder = ObjectDifferBuilder.startBuilding();
    objectDifferBuilder.circularReferenceHandling().matchCircularReferencesUsing(EQUALITY_OPERATOR);
    objectDiffer = objectDifferBuilder.build();
  }

  @Test
  public void detectsCircularReference_whenEncounteringSameObjectTwice() throws Exception
  {
View Full Code Here

    final GraphNode base2 = new GraphNode(2);
    establishCircularDirectReference(base1, base2);

    final ObjectDifferBuilder objectDifferBuilder = ObjectDifferBuilder.startBuilding();
    objectDifferBuilder.filtering().returnNodesWithState(DiffNode.State.CIRCULAR);
    final DiffNode node = objectDifferBuilder.build().compare(working1, base1);
    node.visit(new NodeHierarchyVisitor());

    assertThat(node).child("value").hasState(DiffNode.State.ADDED);
    assertThat(node).child("directReference").hasState(DiffNode.State.CHANGED);
    assertThat(node).child("directReference", "value").hasState(DiffNode.State.ADDED);
View Full Code Here

    base1.getMap().put("foo", base2);
    base2.getMap().put("bar", base1);

    final ObjectDifferBuilder objectDifferBuilder = ObjectDifferBuilder.startBuilding();
    objectDifferBuilder.filtering().returnNodesWithState(DiffNode.State.CIRCULAR);
    final ObjectDiffer differ = objectDifferBuilder.build();

    final DiffNode node = differ.compare(working1, base1);
    node.visit(new NodeHierarchyVisitor());

    NodeAssertions.assertThat(node)
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.