### Question:
NodeSelectorFactoryImpl implements NodeSelectorFactory { @Override public <E> NodeSelector<E> newSelector(Predicate<OpenNode<? extends E, ?>> predicate) { return new RootMatcherSelector<>(predicate); } NodeSelectorFactoryImpl(); @Override NodeSelector<E> newSelector(Predicate<OpenNode<? extends E, ?>> predicate); @Override NodeSelector<E> newSelector(NodeSelector<E> selector, Predicate<OpenNode<? extends E, ?>> predicate); @Override NodeSelector<E> newSelector(final NodeSelector<E> baseSelector, final NodeSelector<E> extensionSelector);  }### Answer:
@Test public void selectorFromMatcher() { final NodeSelector<String> selector = factory.newSelector(new AlwaysMatcher<String>()); final Iterator<? extends MutableSettableStructuredNode<String>> iterator = selector.select(tree); final MutableSettableStructuredNode<String> selectedNode = iterator.next(); assertEquals("a", selectedNode.getElement()); assertFalse(iterator.hasNext()); }
@Test public void selectorFromSelectorAndMatcher() { final NodeSelector<String> selector0 = factory.newSelector(new AlwaysMatcher<>()); final NodeSelector<String> selector1 = factory.newSelector(selector0, new AlwaysMatcher<>()); final Iterator<? extends MutableSettableStructuredNode<String>> iterator = selector1.select(tree); final MutableSettableStructuredNode<String> selectedNode0 = iterator.next(); assertEquals("b", selectedNode0.getElement()); final MutableSettableStructuredNode<String> selectedNode1 = iterator.next(); assertEquals("c", selectedNode1.getElement()); assertFalse(iterator.hasNext()); }
@Test public void selectorFromSelectorAndSelector() { final NodeSelector<String> selector0 = factory.newSelector(new AlwaysMatcher<>()); final NodeSelector<String> selector1 = factory.newSelector(new EqualityMatcher<>("b")); final NodeSelector<String> selector2 = factory.newSelector(selector0, selector1); final Iterator<? extends MutableSettableStructuredNode<String>> iterator = selector2.select(tree); final MutableSettableStructuredNode<String> selectedNode0 = iterator.next(); assertEquals("b", selectedNode0.getElement()); assertFalse(iterator.hasNext()); }