Package de.danielbechler.diff.node

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


    working.put("foo", "bar");

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

    final DiffNode node = ObjectDifferBuilder.buildDefault().compare(working, base);
    NodeAssertions.assertThat(node).self().hasChildren(1);
    NodeAssertions.assertThat(node).child(new MapKeyElementSelector("foo")).hasState(DiffNode.State.CHANGED);
  }
View Full Code Here


  public void testCompareWithDifferentMapImplementationsSucceeds() throws Exception
  {
    final Map<String, String> base = new LinkedHashMap<String, String>(Collections.singletonMap("test", "foo"));
    final Map<String, String> working = new TreeMap<String, String>(Collections.singletonMap("test", "bar"));

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

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

  }

  @Test(groups = INTEGRATION)
  public void testCompareWithDifferentStrings() throws Exception
  {
    final DiffNode node = ObjectDifferBuilder.buildDefault().compare("foo", "bar");

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

        .filtering().returnNodesWithState(DiffNode.State.IGNORED).and()
        .build();

    final ObjectWithIdentityAndValue working = new ObjectWithIdentityAndValue("1", "foo");
    final ObjectWithIdentityAndValue base = new ObjectWithIdentityAndValue("1", "bar");
    final DiffNode node = objectDiffer.compare(working, base);

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

//    when(delegate.delegate(any(Node.class), any(Instances.class))).thenReturn(node);
//    when(configuration.isIntrospectible(any(Node.class))).thenReturn(true);
//    when(configuration.isReturnable(any(Node.class))).thenReturn(true);
//    when(node.hasChanges()).thenReturn(true);

    final DiffNode node = ObjectDifferBuilder.buildDefault().compare(
        new ObjectWithIdentityAndValue("a", "1"),
        new ObjectWithIdentityAndValue("a", "2"));

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

  @Test(enabled = false, description = "Currently this is simply not possible because of the way, the CollectionItemAccessor works. Would be great, to support this.")
  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

  @Test(enabled = false, description = "Currently this is simply not possible because of the way, the CollectionItemAccessor works. Would be great, to support this.")
  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 List<String> forBase = new ArrayList<String>();
    forBase.add("uno");
    final ObjectWithMethodEqualsOnlyValueProviderMethodOnGetCollection working = new ObjectWithMethodEqualsOnlyValueProviderMethodOnGetCollection(forWorking);
    final ObjectWithMethodEqualsOnlyValueProviderMethodOnGetCollection base = new ObjectWithMethodEqualsOnlyValueProviderMethodOnGetCollection(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 List<String> forBase = new ArrayList<String>();
    forBase.add("uno");
    final ObjectWithMethodEqualsOnlyValueProviderMethodOnGetCollection working = new ObjectWithMethodEqualsOnlyValueProviderMethodOnGetCollection(forWorking);
    final ObjectWithMethodEqualsOnlyValueProviderMethodOnGetCollection base = new ObjectWithMethodEqualsOnlyValueProviderMethodOnGetCollection(forBase);

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

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

    final ObjectWithNestedObject forBase = new ObjectWithNestedObject("childid");
    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.UNTOUCHED);
    NodeAssertions.assertThat(node).self().hasNoChildren();
  }
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.