@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));
 }
 @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));
 }
  @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));
  }
Example #4
0
 /**
  * On node selection changes description text.
  *
  * @param node node.
  */
 private void onNodeSelected(CollectionNode node) {
   if (node == null) {
     taDescription.setText(null);
   } else {
     taDescription.setText(node.getDescription());
     UifUtilities.installTextStyle(taDescription, TEXT_STYLE);
   }
 }
  @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));
  }
Example #6
0
  @Override
  public Object visit(CollectionNode node) {
    StringBuilder sb = new StringBuilder();

    ArrayList<Node> children = node.GetChildren();

    for (int i = 0; i < children.size(); i++) {
      /*if(i > 0)
      sb.append(", ");*/
      sb.append(visit(children.get(i)));
    }

    return sb.toString();
  }
 @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));
 }