NodeItemTest: check that child is added to parent

This commit is contained in:
Paul Campbell 2016-09-20 22:39:30 +01:00
parent 77a7946e9c
commit d73a46b905

View file

@ -10,6 +10,7 @@ import org.junit.rules.ExpectedException;
import java.util.Arrays;
import java.util.Collections;
import java.util.Optional;
import java.util.Set;
import static org.assertj.core.api.Assertions.assertThat;
@ -84,6 +85,17 @@ public class NodeItemTest {
.contains(parent);
}
@Test
public void shouldAddAsChildWhenCreatedWithParent() {
//given
final Node<String> root = Nodes.namedRoot("root data", "root name");
//when
final Node<String> child = Nodes.namedChild("child data", "child name", root);
//then
final Set<Node<String>> children = root.getChildren();
assertThat(children).containsExactly(child);
}
/**
* Test that setting the parent on a node where the proposed parent is a
* child of the node throws an exception.