Dispatcher { public JsonEnvelope dispatch(final JsonEnvelope envelope) { final HandlerMethod handlerMethod; try { handlerMethod = handlerRegistry.get(envelope.metadata().name()); } catch (NullPointerException e) { throw new NullEnvelopeException("Envelope cannot be null", e); } return MethodInvoker .createMethodInvoker(typeConverter, jsonEnvelopeRepacker) .invoke(handlerMethod, envelope); } Dispatcher(final HandlerRegistry handlerRegistry,
                      final EnvelopePayloadTypeConverter typeConverter,
                      final JsonEnvelopeRepacker jsonEnvelopeRepacker); JsonEnvelope dispatch(final JsonEnvelope envelope); void register(final Object handler);  }
@Test(expected = MissingHandlerException.class) public void shouldThrowExceptionIfNoHandlerExists() throws Exception { final String payloadId = "3f47ab7e-aecc-4cec-9246-c32066ef5ba1"; final String payloadName = "payload name"; final long payloadVersion = 200L; final JsonValue payload = withPayloadOfTestPojo(payloadId, payloadName, payloadVersion); final JsonEnvelope envelope = envelopeFrom(metadata, payload); dispatcher.dispatch(envelope); }