NodeItemTest: add tests for parentStream()
This commit is contained in:
parent
081dfc7b37
commit
21c0fb8896
1 changed files with 20 additions and 0 deletions
|
@ -945,4 +945,24 @@ public class NodeItemTest {
|
||||||
assertThat(Nodes.unnamedChild(null, root)
|
assertThat(Nodes.unnamedChild(null, root)
|
||||||
.isRoot()).isFalse();
|
.isRoot()).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void parentStream() {
|
||||||
|
//given
|
||||||
|
val root = Nodes.namedRoot("root data", "root");
|
||||||
|
val child1 = Nodes.namedChild("child 1 data", "child 1", root);
|
||||||
|
val child2 = Nodes.namedChild("child 2 data", "child 2", root);
|
||||||
|
val child3 = Nodes.namedChild("child 3 data", "child 3", child2);
|
||||||
|
//when
|
||||||
|
val resultRoot = root.parentStream()
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
val resultChild1 = child1.parentStream()
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
val resultChild3 = child3.parentStream()
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
//then
|
||||||
|
assertThat(resultRoot).isEmpty();
|
||||||
|
assertThat(resultChild1).containsExactlyInAnyOrder(root);
|
||||||
|
assertThat(resultChild3).containsExactlyInAnyOrder(child2, root);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue