Package de.danielbechler.diff.node

Examples of de.danielbechler.diff.node.DiffNode


  @Test
  public void do_not_add_property_nodes_to_bean_node_if_they_are_not_returnable()
  {
    given_root_node_is_introspectable();
    final PropertyAwareAccessor propertyAccessor = given_introspector_returns_PropertyAccessor("foo");
    final DiffNode propertyNode = given_DifferDispatcher_returns_Node_for_PropertyAccessor(propertyAccessor);
    given_Node_is_not_returnable(propertyNode);

    final DiffNode node = beanDiffer.compare(DiffNode.ROOT, instances);

    Assertions.assertThat(node.hasChildren()).isFalse();
  }
View Full Code Here


  {
    given_primitiveDiffer_with_defaultValueMode(UNASSIGNED);
    given_instances(type, base, working, fresh);
    when(instances.hasBeenRemoved()).thenReturn(true);

    final DiffNode node = primitiveDiffer.compare(DiffNode.ROOT, instances);

    assertThat(node).self().hasState(DiffNode.State.REMOVED);

  }
View Full Code Here

                                final Object fresh) throws Exception
  {
    given_primitiveDiffer_with_defaultValueMode(UNASSIGNED);
    given_instances(type, base, working, fresh);

    final DiffNode node = primitiveDiffer.compare(DiffNode.ROOT, instances);

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

  {
    given_primitiveDiffer_with_defaultValueMode(UNASSIGNED);
    given_instances(type, base, working, fresh);
    when(instances.hasBeenAdded()).thenReturn(true);

    final DiffNode node = primitiveDiffer.compare(DiffNode.ROOT, instances);

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

                                final Object fresh) throws Exception
  {
    given_primitiveDiffer_with_defaultValueMode(ASSIGNED);
    given_instances(type, base, working, fresh);

    final DiffNode node = primitiveDiffer.compare(DiffNode.ROOT, instances);

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

  private static DiffNode newNode(final DiffNode parentNode, final Instances collectionInstances)
  {
    final Accessor accessor = collectionInstances.getSourceAccessor();
    final Class<?> type = collectionInstances.getType();
    return new DiffNode(parentNode, accessor, type);
  }
View Full Code Here

    return Collection.class.isAssignableFrom(type);
  }

  public final DiffNode compare(final DiffNode parentNode, final Instances collectionInstances)
  {
    final DiffNode collectionNode = newNode(parentNode, collectionInstances);
    if (collectionInstances.hasBeenAdded())
    {
      final Collection addedItems = collectionInstances.getWorking(Collection.class);
      compareItems(collectionNode, collectionInstances, addedItems);
      collectionNode.setState(DiffNode.State.ADDED);
    }
    else if (collectionInstances.hasBeenRemoved())
    {
      final Collection<?> removedItems = collectionInstances.getBase(Collection.class);
      compareItems(collectionNode, collectionInstances, removedItems);
      collectionNode.setState(DiffNode.State.REMOVED);
    }
    else if (collectionInstances.areSame())
    {
      collectionNode.setState(DiffNode.State.UNTOUCHED);
    }
    else
    {
      final ComparisonStrategy comparisonStrategy = comparisonStrategyResolver.resolveComparisonStrategy(collectionNode);
      if (comparisonStrategy == null)
View Full Code Here

  public void assign_the_circular_start_path_if_the_delegated_node_is_circular() throws Exception
  {
    final NodePath circularStartPath = NodePath.withRoot();
    given_the_delegated_node_is_circular(circularStartPath);

    final DiffNode node = differDispatcher.dispatch(DiffNode.ROOT, instances, accessor);

    assertThat(node.getCircleStartPath()).isEqualTo(circularStartPath);
  }
View Full Code Here

  @Test
  public void mark_node_as_circular_if_the_delegated_node_is_circular() throws Exception
  {
    given_the_delegated_node_is_circular(NodePath.withRoot());

    final DiffNode node = differDispatcher.dispatch(DiffNode.ROOT, instances, accessor);

    assertThat(node.getState()).isEqualTo(DiffNode.State.CIRCULAR);
  }
View Full Code Here

  @Test
  public void pass_node_to_onCircularReferenceException_method_of_the_exceptionListener_if_the_delegated_node_is_circular() throws Exception
  {
    given_the_delegated_node_is_circular(NodePath.withRoot());

    final DiffNode node = differDispatcher.dispatch(DiffNode.ROOT, instances, accessor);

    verify(circularReferenceExceptionHandler).onCircularReferenceException(node);
  }
View Full Code Here

TOP

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

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.