diff --git a/src/test/java/net/kemitix/node/NodeItemTest.java b/src/test/java/net/kemitix/node/NodeItemTest.java index 1f25426..e9928b6 100644 --- a/src/test/java/net/kemitix/node/NodeItemTest.java +++ b/src/test/java/net/kemitix/node/NodeItemTest.java @@ -945,4 +945,24 @@ public class NodeItemTest { assertThat(Nodes.unnamedChild(null, root) .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); + } }