Package de.danielbechler.diff.node

Examples of de.danielbechler.diff.node.DiffNode


  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void testAssertThat_node_has_children_with_negative_count_throws_IllegalArgumentException()
  {
    final DiffNode node = new DiffNode(String.class);
    assertThat(node).root().hasChildren(-1);
  }
View Full Code Here


  }

  @Test
  public void testAssertThat_node_has_changed_state_succeeds_when_node_has_changed()
  {
    final DiffNode node = new DiffNode(String.class);
    node.setState(DiffNode.State.CHANGED);
    assertThat(node).root().hasState(DiffNode.State.CHANGED);
  }
View Full Code Here

  }

  @Test(expectedExceptions = AssertionError.class)
  public void testAssertThat_node_has_changed_state_fails_when_node_has_different_state()
  {
    final DiffNode node = new DiffNode(String.class);
    node.setState(DiffNode.State.UNTOUCHED);
    assertThat(node).root().hasState(DiffNode.State.CHANGED);
  }
View Full Code Here

  @SuppressWarnings({"unchecked"})
  public <T> T merge(final T modified, final T base, final T head)
  {
    final DiffNode.Visitor visitor = new MergingDifferenceVisitor<T>(head, modified);
    final DiffNode difference = objectDiffer.compare(modified, base);
    difference.visit(visitor);
    return head;
  }
View Full Code Here

  @Test
  public void return_untouched_node_if_working_and_base_are_null()
  {
    when(instances.areNull()).thenReturn(true);

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

    assertThat(node).self().isUntouched();
  }
View Full Code Here

  @Test
  public void return_added_node_if_working_is_not_null_and_base_is()
  {
    when(instances.hasBeenAdded()).thenReturn(true);

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

    assertThat(node.getState(), is(DiffNode.State.ADDED));
  }
View Full Code Here

  @Test
  public void return_removed_node_if_working_is_null_and_base_is_not()
  {
    when(instances.hasBeenRemoved()).thenReturn(true);

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

    assertThat(node.getState(), is(DiffNode.State.REMOVED));
  }
View Full Code Here

  @Test
  public void return_untouched_node_if_working_and_base_are_the_same_instance()
  {
    when(instances.areNull()).thenReturn(true);

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

    assertThat(node).self().isUntouched();
  }
View Full Code Here

  @Test
  public void delegate_comparison_of_properties_when_comparing_via_introspector()
  {
    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_returnable(propertyNode);

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

    Assertions.assertThat(node.getChild("foo")).isSameAs(propertyNode);
  }
View Full Code Here

    return propertyAccessor;
  }

  private DiffNode given_DifferDispatcher_returns_Node_for_PropertyAccessor(final PropertyAwareAccessor propertyAccessor)
  {
    final DiffNode propertyNode = new DiffNode(propertyAccessor, String.class);
    doReturn(propertyNode).when(differDispatcher)
        .dispatch(any(DiffNode.class), any(Instances.class), same(propertyAccessor));
    return propertyNode;
  }
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.