MapRouter implements IRouter { @Override public List<Object> enumerate() { return new ArrayList<>(map.keySet()); } MapRouter(final Map<Object, IMessageReceiver> map); @Override IMessageReceiver route(final Object targetId); @Override void register(final Object targetId, final IMessageReceiver receiver); @Override List<Object> enumerate();  }
@Test public void Should_enumerate_returnListOfIdentifiersOfAllReceivers() throws Exception { Set<Object> keys = new HashSet<>(Arrays.asList(new Object(), new Object())); Map<Object, IMessageReceiver> mapMock = mock(Map.class); when(mapMock.keySet()).thenReturn(keys); IRouter router = new MapRouter(mapMock); assertEquals(new ArrayList<Object>(keys), router.enumerate()); }