Package de.danielbechler.diff.node

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


    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


  @Test
  public void detectsCircularReference_whenEncounteringSameObjectTwice() throws Exception
  {
    final ObjectWithNestedObject object = new ObjectWithNestedObject("foo");
    object.setObject(object);
    final DiffNode node = objectDiffer.compare(object, null);
    NodeAssertions.assertThat(node).child("object").isCircular();
  }
View Full Code Here

  @Test
  public void detectsCircularReference_whenEncounteringDifferentButEqualObjectsTwice() throws Exception
  {
    final ObjectWithNestedObject object = new ObjectWithNestedObject("foo", new ObjectWithNestedObject("foo"));
    final DiffNode node = objectDiffer.compare(object, null);
    NodeAssertions.assertThat(node).child("object").isCircular();
  }
View Full Code Here

               final Accessor accessor)
  {
    Assert.notNull(parentInstances, "parentInstances");
    Assert.notNull(accessor, "accessor");

    final DiffNode node = compare(parentNode, parentInstances, accessor);
    if (parentNode != null && isReturnableResolver.isReturnable(node))
    {
      parentNode.addChild(node);
    }
    return node;
View Full Code Here

  private DiffNode compare(final DiffNode parentNode,
               final Instances parentInstances,
               final Accessor accessor)
  {
    final DiffNode node = new DiffNode(parentNode, accessor, null);
    if (isIgnoredResolver.isIgnored(node))
    {
      node.setState(DiffNode.State.IGNORED);
      return node;
    }

    final Instances accessedInstances;
    if (accessor instanceof PropertyAwareAccessor)
    {
      final PropertyAwareAccessor propertyAwareAccessor = (PropertyAwareAccessor) accessor;
      try
      {
        accessedInstances = parentInstances.access(accessor);
      }
      catch (final PropertyReadException e)
      {
        node.setState(DiffNode.State.INACCESSIBLE);
        final Class<?> parentType = parentInstances.getType();
        final String propertyName = propertyAwareAccessor.getPropertyName();
        final PropertyAccessExceptionHandler exceptionHandler = propertyAccessExceptionHandlerResolver
            .resolvePropertyAccessExceptionHandler(parentType, propertyName);
        if (exceptionHandler != null)
        {
          exceptionHandler.onPropertyReadException(e, node);
        }
        return node;
      }
    }
    else
    {
      accessedInstances = parentInstances.access(accessor);
    }

    if (accessedInstances.areNull())
    {
      return new DiffNode(parentNode, accessedInstances.getSourceAccessor(), accessedInstances.getType());
    }
    else
    {
      return compareWithCircularReferenceTracking(parentNode, accessedInstances);
    }
View Full Code Here

  @Test
  public void detectsCircularReference_whenEncounteringSameObjectTwice() throws Exception
  {
    final ObjectWithNestedObject object = new ObjectWithNestedObject("foo");
    object.setObject(object);
    final DiffNode node = objectDiffer.compare(object, null);
    NodeAssertions.assertThat(node).child("object").isCircular();
  }
View Full Code Here

  @Test
  public void detectsNoCircularReference_whenEncounteringDifferentButEqualObjectsTwice() throws Exception
  {
    final ObjectWithNestedObject object = new ObjectWithNestedObject("foo", new ObjectWithNestedObject("foo"));
    final DiffNode node = objectDiffer.compare(object, null);
    NodeAssertions.assertThat(node).child("object").hasState(DiffNode.State.ADDED);
  }
View Full Code Here

  }

  private DiffNode compareWithCircularReferenceTracking(final DiffNode parentNode,
                              final Instances instances)
  {
    DiffNode node = null;
    try
    {
      rememberInstances(parentNode, instances);
      try
      {
View Full Code Here

  private static DiffNode newCircularNode(final DiffNode parentNode,
                      final Instances instances,
                      final NodePath circleStartPath)
  {
    final DiffNode node = new DiffNode(parentNode, instances.getSourceAccessor(), instances.getType());
    node.setState(DiffNode.State.CIRCULAR);
    node.setCircleStartPath(circleStartPath);
    node.setCircleStartNode(findNodeMatchingPropertyPath(parentNode, circleStartPath));
    return node;
  }
View Full Code Here

    final GraphNode modified = new GraphNode(1);
    final GraphNode modifiedA = new GraphNode(2, "ax");
    modified.setDirectReference(modifiedA);

    final DiffNode root = compareAndPrint(modified, base);

    assertThat(root).root().hasChildren(1);
    assertThat(root).child("directReference", "value").hasState(DiffNode.State.CHANGED).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.