@Override public OperationResponse preprocess(OperationResponse response) { return this.responseFactory.createFrom(response, removeHeaders(response.getHeaders())); }
@Override public OperationResponse preprocess(OperationResponse response) { byte[] modifiedContent = this.contentModifier.modifyContent(response.getContent(), response.getHeaders().getContentType()); return this.responseFactory.createFrom(response, modifiedContent); }
@Test public void defaultOperationResponsePreprocessorsAreCalled() throws IOException { given(this.requestConverter.convert(this.request)) .willReturn(this.operationRequest); given(this.responseConverter.convert(this.response)) .willReturn(this.operationResponse); HashMap<String, Object> configuration = new HashMap<>(); OperationPreprocessor defaultPreprocessor1 = mock(OperationPreprocessor.class); OperationPreprocessor defaultPreprocessor2 = mock(OperationPreprocessor.class); configuration.put( RestDocumentationGenerator.ATTRIBUTE_NAME_DEFAULT_OPERATION_RESPONSE_PREPROCESSOR, Preprocessors.preprocessResponse(defaultPreprocessor1, defaultPreprocessor2)); OperationResponse first = createResponse(); OperationResponse second = createResponse(); OperationResponse third = new OperationResponseFactory() .createFrom(this.operationResponse, new HttpHeaders()); given(this.responsePreprocessor.preprocess(this.operationResponse)) .willReturn(first); given(defaultPreprocessor1.preprocess(first)).willReturn(second); given(defaultPreprocessor2.preprocess(second)).willReturn(third); new RestDocumentationGenerator<>("id", this.requestConverter, this.responseConverter, Preprocessors.preprocessResponse(this.responsePreprocessor), this.snippet) .handle(this.request, this.response, configuration); verifySnippetInvocation(this.snippet, this.operationRequest, third, configuration, 1); }