LevelNode { void add(List<String> levels, T leafValue, int depth) { String[] levelsArray = levels.toArray(new String[levels.size()]); add(levelsArray, leafValue, depth); } LevelNode(LevelIndex<T> index);  LevelNode(String level, LevelNode<T> parent, LevelIndex<T> index); boolean hasChildren(); boolean isLeaf(); Map<String, LevelNode<T>> getChildren(); LevelNode<T> getDefaultNode(); List<T> getLeafList(); T getLeafValue(); void printNode(StringBuilder sb, int level); @Override String toString();  }
@Test public void shouldAddNewNodeValueToLeavesWhenAddingToLastNodeInIndexTree() { LevelIndex<Integer> levelIndex = levelIndex().withLevelCount(0).build(); LevelNode<Integer> node = new LevelNode<Integer>(levelIndex); int currentLevelNumber = 0; node.add(new String[]{}, 10, currentLevelNumber); assertThat(node).hasLeaves(1).leavesEqualTo(10); }
@Test public void shouldAddNewNodeToChildrenListWhenCurrentNodeIsNotLastInIndexTree() { LevelIndex<Integer> levelindex = levelIndex().withLevelCount(1).build(); LevelNode<Integer> root = new LevelNode<Integer>(levelindex); int currentLevelNumber = 0; root.add(new String[]{"A"}, 10, currentLevelNumber); assertThat(root).hasNoLeaves().hasDirectChild("A"); }