Package de.danielbechler.diff.node

Examples of de.danielbechler.diff.node.DiffNode$Visitor


    final ObjectWithNestedObject forBase = new ObjectWithNestedObject("differentchildid");
    forBase.setObject(new ObjectWithNestedObject("differentgrandchildid"));
    final ObjectWithMethodEqualsOnlyValueProviderMethodOnGetNestedObject working = new ObjectWithMethodEqualsOnlyValueProviderMethodOnGetNestedObject("id", forWorking);
    final ObjectWithMethodEqualsOnlyValueProviderMethodOnGetNestedObject base = new ObjectWithMethodEqualsOnlyValueProviderMethodOnGetNestedObject("id", forBase);

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

    NodeAssertions.assertThat(node).self().hasState(DiffNode.State.CHANGED);
    assertThat(node)
        .child(NodePath.with("object"))
        .hasState(DiffNode.State.CHANGED);
View Full Code Here


    final Map<String, String> forBase = new HashMap<String, String>();
    forBase.put("keyone", "valone");
    final ObjectWithMethodEqualsOnlyValueProviderMethodOnGetMap working = new ObjectWithMethodEqualsOnlyValueProviderMethodOnGetMap(forWorking);
    final ObjectWithMethodEqualsOnlyValueProviderMethodOnGetMap base = new ObjectWithMethodEqualsOnlyValueProviderMethodOnGetMap(forBase);

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

    NodeAssertions.assertThat(node).self().hasState(DiffNode.State.UNTOUCHED);
    NodeAssertions.assertThat(node).self().hasNoChildren();
  }
View Full Code Here

    final Map<String, String> forBase = new HashMap<String, String>();
    forBase.put("keyone", "valone");
    final ObjectWithMethodEqualsOnlyValueProviderMethodOnGetMap working = new ObjectWithMethodEqualsOnlyValueProviderMethodOnGetMap(forWorking);
    final ObjectWithMethodEqualsOnlyValueProviderMethodOnGetMap base = new ObjectWithMethodEqualsOnlyValueProviderMethodOnGetMap(forBase);

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

    NodeAssertions.assertThat(node).self().hasState(DiffNode.State.CHANGED);
    assertThat(node)
        .child(NodePath.with("map"))
        .hasState(DiffNode.State.CHANGED);
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);
    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);

    assertThat(node).child(NodePath.startBuilding()
View Full Code Here

  public void detects_change_from_null_to_object_referenct_as_addition() throws Exception
  {
    final ObjectWithString base = new ObjectWithString();
    final ObjectWithString working = new ObjectWithString("foo");

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

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

    final ObjectWithCircularReference baseA = new ObjectWithCircularReference("a");
    final ObjectWithCircularReference baseB = new ObjectWithCircularReference("c");
    baseA.setReference(baseB);
    baseB.setReference(baseA);

    final DiffNode root = ObjectDifferBuilder.buildDefault().compare(workingA, baseA);
    assertThat(root).child("reference", "reference").isCircular();
    assertThat(root).child("reference", "reference")
        .hasCircularStartPathEqualTo(NodePath.withRoot());

    Assertions.assertThat(root.canonicalGet(workingA))
        .isSameAs(root.getChild("reference").getChild("reference").canonicalGet(workingA));
    Assertions.assertThat(root.getChild("reference").getChild("reference").getCircleStartNode())
        .isSameAs(root);
  }
View Full Code Here

    baseB.setReference(baseC);
    baseC.setReference(baseA);

    final ObjectDiffer objectDiffer = ObjectDifferBuilder.buildDefault();
//    objectDiffer.getConfiguration().withoutCircularNodes();
    final DiffNode root = objectDiffer.compare(workingA, baseA);
    root.visit(new PrintingVisitor(workingA, baseA));
    assertThat(root).child("reference", "reference", "reference").isCircular();
  }
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));
  }
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

TOP

Related Classes of de.danielbechler.diff.node.DiffNode$Visitor

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.