RequestResponseEnvelopeValidator { public void validateRequest(final JsonEnvelope jsonEnvelope) { final String actionName = envelopeInspector.getActionNameFor(jsonEnvelope); final MediaType mediaType = nameToMediaTypeConverter.convert(actionName); envelopeValidator.validate(jsonEnvelope, actionName, of(mediaType)); } RequestResponseEnvelopeValidator(
            final EnvelopeValidator envelopeValidator,
            final NameToMediaTypeConverter nameToMediaTypeConverter,
            final MediaTypeProvider mediaTypeProvider,
            final EnvelopeInspector envelopeInspector); void validateRequest(final JsonEnvelope jsonEnvelope); void validateResponse(final JsonEnvelope jsonEnvelope);  }
@Test public void shouldValidateARequestEnvelope() throws Exception { final String actionName = "example.action-name"; final JsonEnvelope jsonEnvelope = mock(JsonEnvelope.class); final MediaType mediaType = mock(MediaType.class); when(envelopeInspector.getActionNameFor(jsonEnvelope)).thenReturn(actionName); when(nameToMediaTypeConverter.convert(actionName)).thenReturn(mediaType); requestResponseEnvelopeValidator.validateRequest(jsonEnvelope); verify(envelopeValidator).validate(jsonEnvelope, actionName, of(mediaType)); }