示例#1
0
  public void test_iteration_childWithListOfChildren() {
    ImmTreeNode node1a = ImmTreeNode.builder().name("1a").build();
    ImmTreeNode node1b = ImmTreeNode.builder().name("1b").build();
    ImmTreeNode node1 = ImmTreeNode.builder().name("1").child1(node1a).child2(node1b).build();
    ImmTreeNode node2a = ImmTreeNode.builder().name("2a").build();
    ImmTreeNode node2b = ImmTreeNode.builder().name("2b").build();
    ImmTreeNode node2 = ImmTreeNode.builder().name("2").child1(node2a).child2(node2b).build();
    ImmTreeNode node3 = ImmTreeNode.builder().name("3").build();
    ImmTreeNode root =
        ImmTreeNode.builder()
            .name("root")
            .child1(node3)
            .childList(ImmutableList.of(node1, node2))
            .build();

    Iterator<Bean> it = JodaBeanUtils.beanIterator(root);
    assertEquals(it.hasNext(), true);
    assertSame(it.next(), root);
    assertEquals(it.hasNext(), true);
    assertSame(it.next(), node3);
    assertEquals(it.hasNext(), true);
    assertSame(it.next(), node1);
    assertEquals(it.hasNext(), true);
    assertSame(it.next(), node1a);
    assertEquals(it.hasNext(), true);
    assertSame(it.next(), node1b);
    assertEquals(it.hasNext(), true);
    assertSame(it.next(), node2);
    assertEquals(it.hasNext(), true);
    assertSame(it.next(), node2a);
    assertEquals(it.hasNext(), true);
    assertSame(it.next(), node2b);
    assertEquals(it.hasNext(), false);
  }
示例#2
0
  public void test_iteration_childWithChildren() {
    ImmTreeNode node1 = ImmTreeNode.builder().name("1").build();
    ImmTreeNode node2 = ImmTreeNode.builder().name("2").build();
    ImmTreeNode root = ImmTreeNode.builder().name("root").child1(node1).child2(node2).build();

    Iterator<Bean> it = JodaBeanUtils.beanIterator(root);
    assertEquals(it.hasNext(), true);
    assertSame(it.next(), root);
    assertEquals(it.hasNext(), true);
    assertSame(it.next(), node1);
    assertEquals(it.hasNext(), true);
    assertSame(it.next(), node2);
    assertEquals(it.hasNext(), false);
  }