### Question:
NodeStreamFactoryImpl implements NodeStreamFactory { @Override public <E, N extends OpenNode<E, N>, T extends SortingTree<E, N>> Stream<N> sortedStream(T tree) { final Spliterator<N> spliterator = spliterator(tree); return StreamSupport.stream(spliterator, false); } NodeStreamFactoryImpl(TreeIteratorFactory iterators); @Override Stream<N> preOrderStream(T tree); @Override Stream<N> inOrderStream(T tree); @Override Stream<N> postOrderStream(T tree); @Override Stream<N> breadthFirstStream(T tree); @Override Stream<N> sortedStream(T tree);  }### Answer:
@Test public void sortedStream() { final NodeStreamFactoryImpl factory = new NodeStreamFactoryImpl(iterators); final List<? extends Integer> list = factory .sortedStream(sortingTree) .map(OpenNode::getElement) .collect(Collectors.toList()); assertEquals(4, list.size()); assertEquals(Integer.valueOf(0), list.get(0)); assertEquals(Integer.valueOf(1), list.get(1)); assertEquals(Integer.valueOf(2), list.get(2)); assertEquals(Integer.valueOf(3), list.get(3)); }