Package de.danielbechler.diff.node

Examples of de.danielbechler.diff.node.NodeHierarchyVisitor


  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


        .compare(workingAddressBook, baseAddressBook);
    final DiffNode contactsNode = rootNode.getChild("contacts");
    final DiffNode contactNode = contactsNode.getChild(new CollectionItemElementSelector(baseContact));
    final DiffNode nicknameNode = contactNode.getChild("nickname");

    rootNode.visit(new NodeHierarchyVisitor());

    /*

    Output:

 
View Full Code Here

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

    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);
    assertThat(node).child("directReference", "directReference").isCircular();
View Full Code Here

    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)
        .child(startBuilding()
            .propertyName("map")
            .mapKey("foo")
View Full Code Here

TOP

Related Classes of de.danielbechler.diff.node.NodeHierarchyVisitor

Copyright © 2018 www.massapicom. 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.