Package de.danielbechler.diff

Examples of de.danielbechler.diff.ObjectDiffer.compare()


    final PhoneBook modifiedPhoneBook = PhoneBook.from(phoneBook);
    modifiedPhoneBook.getContact("Jesse", "Pinkman").setMiddleName("Bruce");
    modifiedPhoneBook.getContact("Walter", "White").setMiddleName("Hartwell");

    final ObjectDiffer objectDiffer = ObjectDifferBuilder.buildDefault();
    final DiffNode node = objectDiffer.compare(modifiedPhoneBook, phoneBook);

    assertThat(node.hasChanges(), is(true));
    assertThat(node.hasChildren(), is(true));
    assertThat(node.childCount(), is(1));
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();
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 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());

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

  {
    final ObjectDiffer objectDiffer = ObjectDifferBuilder.buildDefault();

    final String working = "Hello";
    final String base = "World";
    final DiffNode root = objectDiffer.compare(working, base);

    root.visit(new PrintingVisitor(working, base));
  }

  private static void phoneBookExample()
View Full Code Here

    final PhoneBook modifiedPhoneBook = PhoneBook.from(phoneBook);
    modifiedPhoneBook.getContact("Jesse", "Pinkman").setMiddleName("Bruce");
    modifiedPhoneBook.getContact("Walter", "White").setMiddleName("Hartwell");

    final ObjectDiffer objectDiffer = ObjectDifferBuilder.buildDefault();
    final DiffNode root = objectDiffer.compare(modifiedPhoneBook, phoneBook);
    final DiffNode.Visitor visitor = new PrintingVisitor(modifiedPhoneBook, phoneBook);
    root.visit(visitor);
  }
}
View Full Code Here

    final TopHat hat2 = new TopHat(2, 20);

    final Person p1 = new Person(hat1);
    final Person p2 = new Person(hat2);

    final DiffNode root = objectDiffer.compare(p1, p2);

    root.visit(new DiffNode.Visitor()
    {
      public void node(final DiffNode node, final Visit visit)
      {
View Full Code Here

    TestIntBeanPublic base = new TestIntBeanPublic();
    base.setValue(1);

    ObjectDiffer differ = ObjectDifferBuilder.buildDefault();
    final DiffNode root = differ.compare(working, base);

    root.visit(new PrintingVisitor(working, base));
  }

  public static void testIntegerWorksPrivate()
View Full Code Here

    TestIntBeanPrivate base = new TestIntBeanPrivate();
    base.setValue(1);

    ObjectDiffer differ = ObjectDifferBuilder.buildDefault();
    final DiffNode root = differ.compare(working, base);

    root.visit(new PrintingVisitor(working, base));
  }

  public static void testIntegerWorksPublic()
View Full Code Here

    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

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.