Allow responses with non-standard status codes to be documented
Fixes gh-639
This commit is contained in:
@@ -69,7 +69,7 @@ public class RestDocumentationGeneratorTests {
|
||||
private final OperationRequest operationRequest = new OperationRequestFactory()
|
||||
.create(URI.create("http://localhost:8080"), null, null, new HttpHeaders(), null, null);
|
||||
|
||||
private final OperationResponse operationResponse = new OperationResponseFactory().create(null, null, null);
|
||||
private final OperationResponse operationResponse = new OperationResponseFactory().create(0, null, null);
|
||||
|
||||
private final Snippet snippet = mock(Snippet.class);
|
||||
|
||||
@@ -197,7 +197,7 @@ public class RestDocumentationGeneratorTests {
|
||||
}
|
||||
|
||||
private static OperationResponse createResponse() {
|
||||
return new OperationResponseFactory().create(null, null, null);
|
||||
return new OperationResponseFactory().create(0, null, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ public class RestDocumentationConfigurerTests {
|
||||
.get(RestDocumentationGenerator.ATTRIBUTE_NAME_DEFAULT_OPERATION_RESPONSE_PREPROCESSOR);
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.add("Foo", "value");
|
||||
OperationResponse response = new OperationResponseFactory().create(HttpStatus.OK, headers, null);
|
||||
OperationResponse response = new OperationResponseFactory().create(HttpStatus.OK.value(), headers, null);
|
||||
assertThat(preprocessor.preprocess(response).getHeaders()).doesNotContainKey("Foo");
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ public class ContentTypeLinkExtractorTests {
|
||||
public void extractionFailsWithNullContentType() throws IOException {
|
||||
this.thrown.expect(IllegalStateException.class);
|
||||
new ContentTypeLinkExtractor()
|
||||
.extractLinks(this.responseFactory.create(HttpStatus.OK, new HttpHeaders(), null));
|
||||
.extractLinks(this.responseFactory.create(HttpStatus.OK.value(), new HttpHeaders(), null));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -59,7 +59,7 @@ public class ContentTypeLinkExtractorTests {
|
||||
extractors.put(MediaType.APPLICATION_JSON, extractor);
|
||||
HttpHeaders httpHeaders = new HttpHeaders();
|
||||
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
|
||||
OperationResponse response = this.responseFactory.create(HttpStatus.OK, httpHeaders, null);
|
||||
OperationResponse response = this.responseFactory.create(HttpStatus.OK.value(), httpHeaders, null);
|
||||
new ContentTypeLinkExtractor(extractors).extractLinks(response);
|
||||
verify(extractor).extractLinks(response);
|
||||
}
|
||||
@@ -71,7 +71,7 @@ public class ContentTypeLinkExtractorTests {
|
||||
extractors.put(MediaType.APPLICATION_JSON, extractor);
|
||||
HttpHeaders httpHeaders = new HttpHeaders();
|
||||
httpHeaders.setContentType(MediaType.parseMediaType("application/json;foo=bar"));
|
||||
OperationResponse response = this.responseFactory.create(HttpStatus.OK, httpHeaders, null);
|
||||
OperationResponse response = this.responseFactory.create(HttpStatus.OK.value(), httpHeaders, null);
|
||||
new ContentTypeLinkExtractor(extractors).extractLinks(response);
|
||||
verify(extractor).extractLinks(response);
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ public class LinkExtractorsPayloadTests {
|
||||
}
|
||||
|
||||
private OperationResponse createResponse(String contentName) throws IOException {
|
||||
return this.responseFactory.create(HttpStatus.OK, null,
|
||||
return this.responseFactory.create(HttpStatus.OK.value(), null,
|
||||
FileCopyUtils.copyToByteArray(getPayloadFile(contentName)));
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ public class ContentModifyingOperationPreprocessorTests {
|
||||
|
||||
@Test
|
||||
public void modifyResponseContent() {
|
||||
OperationResponse response = this.responseFactory.create(HttpStatus.OK, new HttpHeaders(),
|
||||
OperationResponse response = this.responseFactory.create(HttpStatus.OK.value(), new HttpHeaders(),
|
||||
"content".getBytes());
|
||||
OperationResponse preprocessed = this.preprocessor.preprocess(response);
|
||||
assertThat(preprocessed.getContent()).isEqualTo("modified".getBytes());
|
||||
|
||||
@@ -87,7 +87,7 @@ public class HeaderRemovingOperationPreprocessorTests {
|
||||
}
|
||||
|
||||
private OperationResponse createResponse(String... extraHeaders) {
|
||||
return this.responseFactory.create(HttpStatus.OK, getHttpHeaders(extraHeaders), new byte[0]);
|
||||
return this.responseFactory.create(HttpStatus.OK.value(), getHttpHeaders(extraHeaders), new byte[0]);
|
||||
}
|
||||
|
||||
private HttpHeaders getHttpHeaders(String... extraHeaders) {
|
||||
|
||||
@@ -321,13 +321,13 @@ public class UriModifyingOperationPreprocessorTests {
|
||||
}
|
||||
|
||||
private OperationResponse createResponseWithContent(String content) {
|
||||
return this.responseFactory.create(HttpStatus.OK, new HttpHeaders(), content.getBytes());
|
||||
return this.responseFactory.create(HttpStatus.OK.value(), new HttpHeaders(), content.getBytes());
|
||||
}
|
||||
|
||||
private OperationResponse createResponseWithHeader(String name, String value) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.add(name, value);
|
||||
return this.responseFactory.create(HttpStatus.OK, headers, new byte[0]);
|
||||
return this.responseFactory.create(HttpStatus.OK.value(), headers, new byte[0]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -261,7 +261,7 @@ public class OperationBuilder extends OperationTestRule {
|
||||
*/
|
||||
public final class OperationResponseBuilder {
|
||||
|
||||
private HttpStatus status = HttpStatus.OK;
|
||||
private int status = HttpStatus.OK.value();
|
||||
|
||||
private HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
@@ -272,7 +272,7 @@ public class OperationBuilder extends OperationTestRule {
|
||||
}
|
||||
|
||||
public OperationResponseBuilder status(int status) {
|
||||
this.status = HttpStatus.valueOf(status);
|
||||
this.status = status;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user