Package de.danielbechler.diff.node

Examples of de.danielbechler.diff.node.DiffNode.visit()


    final ObjectDifferBuilder objectDifferBuilder = ObjectDifferBuilder.startBuilding();
    // final Configuration2 objectDifferBuilder = new Configuration2().withChildrenOfAddedNodes();

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

    node.visit(new NodeHierarchyVisitor());
    NodeAssertions.assertThat(node).root().hasState(DiffNode.State.CHANGED);
    NodeAssertions.assertThat(node).child("object").hasState(DiffNode.State.ADDED);
    NodeAssertions.assertThat(node).child("object", "object").hasState(DiffNode.State.ADDED);
  }
View Full Code Here


  public static void main(final String[] args)
  {
    final Person bruceWayne = new Person("Bruce", "Wayne");
    final Person batman = new Person("Batman", null);
    final DiffNode rootNode = ObjectDifferBuilder.buildDefault().compare(batman, bruceWayne);
    rootNode.visit(new NodeHierarchyVisitor(10));
    rootNode.visit(new PrintingVisitor(batman, bruceWayne)
    {
      @Override
      protected boolean filter(final DiffNode node)
      {
View Full Code Here

  {
    final Person bruceWayne = new Person("Bruce", "Wayne");
    final Person batman = new Person("Batman", null);
    final DiffNode rootNode = ObjectDifferBuilder.buildDefault().compare(batman, bruceWayne);
    rootNode.visit(new NodeHierarchyVisitor(10));
    rootNode.visit(new PrintingVisitor(batman, bruceWayne)
    {
      @Override
      protected boolean filter(final DiffNode node)
      {
        return true;
View Full Code Here

    // (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

        .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
    // Output without ignore:
    // Property at path '/prop/prop2' has changed from [ 2 ] to [ 3 ]
View Full Code Here

  public void testCompareWithListContainingObjectTwiceDetectsIfOneGetsRemoved() throws Exception
  {
    final List<ObjectWithHashCodeAndEquals> base = asList(new ObjectWithHashCodeAndEquals("foo"), new ObjectWithHashCodeAndEquals("foo"));
    final List<ObjectWithHashCodeAndEquals> working = asList(new ObjectWithHashCodeAndEquals("foo"));
    final DiffNode node = ObjectDifferBuilder.buildDefault().compare(working, base);
    node.visit(new NodeHierarchyVisitor());
    assertThat(node)
        .child(NodePath.startBuilding()
            .collectionItem(new ObjectWithHashCodeAndEquals("foo"))
            .build())
        .hasState(DiffNode.State.REMOVED);
View Full Code Here

  public void testCompareWithListContainingObjectOnceDetectsIfAnotherInstanceOfItGetsAdded() throws Exception
  {
    final List<ObjectWithHashCodeAndEquals> base = asList(new ObjectWithHashCodeAndEquals("foo"));
    final List<ObjectWithHashCodeAndEquals> working = asList(new ObjectWithHashCodeAndEquals("foo"), new ObjectWithHashCodeAndEquals("foo"));
    final DiffNode node = ObjectDifferBuilder.buildDefault().compare(working, base);
    node.visit(new NodeHierarchyVisitor());
    assertThat(node).child(NodePath.startBuilding()
        .collectionItem(new ObjectWithHashCodeAndEquals("foo"))
        .build()).hasState(DiffNode.State.ADDED);
  }
View Full Code Here

    final NodePath nodePath = NodePath.with("reference", "reference");

    // verify that the node can be found when it's not excluded
    ObjectDiffer objectDiffer = ObjectDifferBuilder.startBuilding().build();
    final DiffNode verification = objectDiffer.compare(obj1, modifiedObj1);
    verification.visit(new PrintingVisitor(obj1, modifiedObj1));
    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);
View Full Code Here

    // 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 ObjectDifferBuilder objectDifferBuilder = ObjectDifferBuilder.startBuilding();
    final ObjectDiffer differ = objectDifferBuilder.build();

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

    node.visit(new NodeHierarchyVisitor());

    assertThat(node).child(NodePath.startBuilding()
        .mapKey("foo")).hasState(DiffNode.State.ADDED);

    assertThat(node).child(NodePath.startBuilding()
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.