From 21c0fb889683023ec3ee0278e16bfe5bbd060541 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 18 Feb 2017 19:29:01 +0000 Subject: [PATCH] NodeItemTest: add tests for parentStream() --- .../java/net/kemitix/node/NodeItemTest.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) 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); + } }