Package de.danielbechler.diff

Examples of de.danielbechler.diff.ObjectDiffer


    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


    modifiedObj2.setReference(modifiedObj3);

    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);
    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());

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

    phoneBookExample();
  }

  private static void helloWorldExample()
  {
    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));
  }
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

  {
  }

  public static void main(final String[] args)
  {
    final ObjectDiffer objectDiffer = ObjectDifferBuilder.buildDefault();

    final TopHat hat1 = new TopHat(1, 10);
    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

    working.setValue(0);

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

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

    root.visit(new PrintingVisitor(working, base));
  }
View Full Code Here

    working.setValue(0);

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

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

    root.visit(new PrintingVisitor(working, base));
  }
View Full Code Here

    working.setValue(2);

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

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

    root.visit(new PrintingVisitor(working, base));
  }
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

TOP

Related Classes of de.danielbechler.diff.ObjectDiffer

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.