コード例 #1
0
 @Test
 public void testCompareWithRemovedCollection() throws Exception {
   final List<Object> working = null;
   final List<Object> base = Collections.emptyList();
   final CollectionNode node = differ.compare(working, base);
   assertThat(node.getState(), is(Node.State.REMOVED));
 }
コード例 #2
0
 @Test
 public void testCompareWithEmptyLists() {
   final List<String> working = Collections.emptyList();
   final List<String> base = Collections.emptyList();
   final CollectionNode node = differ.compare(working, base);
   assertThat(node.hasChanges(), is(false));
   assertThat(node.hasChildren(), is(false));
 }
コード例 #3
0
  @Test
  public void testCompareWithRemovedItem() throws Exception {
    final Collection<String> working = new LinkedList<String>();
    final Collection<String> base = new LinkedList<String>(Arrays.asList("foo"));

    final CollectionNode node = differ.compare(working, base);

    assertThat(node.hasChanges(), is(true));

    final Node child =
        node.getChild(PropertyPath.createBuilder().withRoot().withCollectionItem("foo").build());
    assertThat(child.getState(), is(Node.State.REMOVED));
  }
コード例 #4
0
  @Test
  public void testCompareWithChangedItem() throws Exception {
    final List<ObjectWithHashCodeAndEquals> working =
        Arrays.asList(new ObjectWithHashCodeAndEquals("foo", "1"));
    final List<ObjectWithHashCodeAndEquals> base =
        Arrays.asList(new ObjectWithHashCodeAndEquals("foo", "2"));

    final CollectionNode node = differ.compare(working, base);

    assertThat(node.hasChanges(), is(true));

    final PropertyPath propertyPath =
        PropertyPath.createBuilder()
            .withRoot()
            .withCollectionItem(new ObjectWithHashCodeAndEquals("foo"))
            .build();
    final Node child = node.getChild(propertyPath);
    assertThat(child.getState(), is(Node.State.CHANGED));
  }
コード例 #5
0
 @Test
 public void testCompareWithAddedCollection() throws Exception {
   final List<Object> working = Collections.emptyList();
   final CollectionNode node = differ.compare(working, null);
   assertThat(node.getState(), is(Node.State.ADDED));
 }