RequestResponseEnvelopeValidator { public void validateResponse(final JsonEnvelope jsonEnvelope) { final String actionName = envelopeInspector.getActionNameFor(jsonEnvelope); final Optional<MediaType> mediaType = mediaTypeProvider.getResponseMediaType(actionName); envelopeValidator.validate(jsonEnvelope, actionName, 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 shouldValidateAResponsetEnvelope() throws Exception { final String actionName = "example.action-name"; final JsonEnvelope jsonEnvelope = mock(JsonEnvelope.class); final Optional<MediaType> mediaType = of(mock(MediaType.class)); when(envelopeInspector.getActionNameFor(jsonEnvelope)).thenReturn(actionName); when(mediaTypeProvider.getResponseMediaType(actionName)).thenReturn(mediaType); requestResponseEnvelopeValidator.validateResponse(jsonEnvelope); verify(envelopeValidator).validate(jsonEnvelope, actionName, mediaType); }