### Question:
InstanceSelector { T select( IndexSlot slot ) { if ( !instances.containsKey( slot ) ) { throw new IllegalStateException( "Instance is not instantiated" ); } return instances.get( slot ); } InstanceSelector();   InstanceSelector( EnumMap<IndexSlot,T> map ); @Override String toString();  }### Answer:
@Test public void shouldSelect() { InstanceSelector<String> selector = selector( NUMBER, "0", STRING, "1" ); String select0 = selector.select( NUMBER ); assertEquals( "0", select0 ); String select1 = selector.select( STRING ); assertEquals( "1", select1 ); }
@Test public void shouldThrowOnNonInstantiatedSelect() { InstanceSelector<String> selector = selector( NUMBER, "0" ); try { selector.select( STRING ); fail( "Should have failed" ); } catch ( IllegalStateException e ) { } }