MapRouter implements IRouter { @Override public IMessageReceiver route(final Object targetId) throws RouteNotFoundException { IMessageReceiver receiver = map.get(targetId); if (null == receiver) { throw new RouteNotFoundException(MessageFormat.format("Route to {0} not found.", targetId)); } return receiver; } 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(expected = RouteNotFoundException.class) public void Should_throwWhenNoRouteFound() throws Exception { new MapRouter(mock(Map.class)).route(mock(Object.class)); }