Package de.danielbechler.diff.node

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


    working.put(15, "Ford");
    working.put(16, "Jarrah");
    working.put(23, "Shephard");
    working.put(42, "Kwon");

    final DiffNode mapNode = ObjectDifferBuilder.buildDefault().compare(working, base);
    mapNode.visitChildren(new DiffNode.Visitor()
    {
      public void node(final DiffNode node, final Visit visit)
      {
        final Object key = ((MapKeyElementSelector) node.getElementSelector()).getKey();
        //                 ^^^ I do not encourage this, but currently it's the only way
View Full Code Here


    // (Option 1) Causes the ObjectDiffer to compare using the method "getProp1" on the 'prop' property of the root object
    builder.comparison()
        .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 testCompareCollectionWithDifferentCollectionImplementationsSucceeds() throws Exception
  {
    final Collection<String> base = new LinkedHashSet<String>(asList("one", "two"));
    final Collection<String> working = new TreeSet<String>(asList("one", "three"));

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

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

  public void testCompareCollectionWithChangedItem() throws Exception
  {
    final List<?> working = asList(new ObjectWithIdentityAndValue("foo", "1"));
    final List<?> base = asList(new ObjectWithIdentityAndValue("foo", "2"));

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

    assertThat(node).self().hasChanges();
    assertThat(node).child(new CollectionItemElementSelector(new ObjectWithIdentityAndValue("foo")))
        .hasState(DiffNode.State.CHANGED);
  }
View Full Code Here

  {
    final Map<String, String> base = null;
    final Map<String, String> working = new TreeMap<String, String>();
    working.put("foo", "bar");

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

    NodeAssertions.assertThat(node).self().hasState(DiffNode.State.ADDED);
    NodeAssertions.assertThat(node).child(new MapKeyElementSelector("foo")).hasState(DiffNode.State.ADDED);
  }
View Full Code Here

  {
    final Map<String, String> base = new TreeMap<String, String>();
    final Map<String, String> working = new TreeMap<String, String>();
    working.put("foo", "bar");

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

    NodeAssertions.assertThat(node).self().hasState(DiffNode.State.CHANGED);
    NodeAssertions.assertThat(node).child(new MapKeyElementSelector("foo")).hasState(DiffNode.State.ADDED);
  }
View Full Code Here

    final Map<String, String> base = new TreeMap<String, String>();
    base.put("foo", "bar");
    final Map<String, String> working = new TreeMap<String, String>();
    working.put("foo", "bar");

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

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

  {
    final Map<String, String> base = new TreeMap<String, String>();
    base.put("foo", "bar");
    final Map<String, String> working = null;

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

    NodeAssertions.assertThat(node).self().hasState(DiffNode.State.REMOVED);
    NodeAssertions.assertThat(node).child(new MapKeyElementSelector("foo")).hasState(DiffNode.State.REMOVED);
  }
View Full Code Here

    working.put("foo", null);

    final Map<String, String> base = new HashMap<String, String>(1);
    base.put("foo", null);

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

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

    final Map<String, String> modified = new LinkedHashMap<String, String>(1);
    modified.put("foo", "bar");
    final Map<String, String> base = new LinkedHashMap<String, String>(modified);
    modified.put("ping", "pong");

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

    NodeAssertions.assertThat(node).root().hasChildren(1);
    NodeAssertions.assertThat(node)
        .child(NodePath.startBuilding().mapKey("foo"))
        .doesNotExist();
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.