### Question:
InstanceSelector { void forAll( Consumer<T> consumer ) { RuntimeException exception = null; for ( IndexSlot slot : IndexSlot.values() ) { exception = consumeAndChainException( select( slot ), consumer, exception ); } if ( exception != null ) { throw exception; } } InstanceSelector();   InstanceSelector( EnumMap<IndexSlot,T> map ); @Override String toString();  }### Answer:
@SuppressWarnings( "ResultOfMethodCallIgnored" ) @Test public void shouldThrowOnNonInstantiatedForAll() { InstanceSelector<String> selector = selector( NUMBER, "0" ); try { selector.forAll( Integer::parseInt ); fail( "Should have failed" ); } catch ( IllegalStateException e ) { } }
@Test public void shouldForAll() { InstanceSelector<String> selector = selectorFilledWithOrdinal(); MutableInt count = new MutableInt(); selector.forAll( s -> count.increment() ); assertEquals( IndexSlot.values().length, count.intValue() ); }