use of org.springframework.cloud.contract.spec.internal.Response in project spring-cloud-contract by spring-cloud.
the class CustomModeHeadersThen method apply.
@Override
public MethodVisitor<Then> apply(SingleContractMetadata metadata) {
Response response = metadata.getContract().getResponse();
Headers headers = response.getHeaders();
Iterator<Header> iterator = headers.getEntries().iterator();
while (iterator.hasNext()) {
Header header = iterator.next();
String text = processHeaderElement(header.getName(), header.getServerValue() instanceof NotToEscapePattern ? header.getServerValue() : MapConverter.getTestSideValues(header.getServerValue()));
if (iterator.hasNext()) {
this.blockBuilder.addLineWithEnding(text);
} else {
this.blockBuilder.addIndented(text);
}
}
this.blockBuilder.addEndingIfNotPresent();
return this;
}
use of org.springframework.cloud.contract.spec.internal.Response in project spring-cloud-contract by spring-cloud.
the class CustomModeStatusCodeThen method apply.
@Override
public MethodVisitor<Then> apply(SingleContractMetadata metadata) {
Response response = metadata.getContract().getResponse();
this.blockBuilder.addIndented(this.comparisonBuilder.assertThat("response.statusCode()", response.getStatus().getServerValue())).addEndingIfNotPresent();
return this;
}
use of org.springframework.cloud.contract.spec.internal.Response in project spring-cloud-contract by spring-cloud.
the class CookieElementProcessor method processCookies.
default void processCookies(SingleContractMetadata metadata) {
Response response = metadata.getContract().getResponse();
Cookies cookies = response.getCookies();
Iterator<Cookie> iterator = cookies.getEntries().iterator();
while (iterator.hasNext()) {
Cookie cookie = iterator.next();
String text = processCookieElement(cookie.getKey(), cookie.getServerValue() instanceof NotToEscapePattern ? cookie.getServerValue() : MapConverter.getTestSideValues(cookie.getServerValue()));
if (iterator.hasNext()) {
blockBuilder().addLine(text).addEndingIfNotPresent();
} else {
blockBuilder().addIndented(text).addEndingIfNotPresent();
}
}
}
use of org.springframework.cloud.contract.spec.internal.Response in project spring-cloud-contract by spring-cloud.
the class JaxRsResponseHeadersThen method validateResponseHeadersBlock.
private void validateResponseHeadersBlock(SingleContractMetadata metadata) {
Response response = metadata.getContract().getResponse();
Headers headers = response.getHeaders();
Iterator<Header> iterator = headers.getEntries().iterator();
while (iterator.hasNext()) {
Header header = iterator.next();
String text = processHeaderElement(header.getName(), header.getServerValue() instanceof NotToEscapePattern ? header.getServerValue() : MapConverter.getTestSideValues(header.getServerValue()));
if (iterator.hasNext()) {
this.blockBuilder.addLineWithEnding(text);
} else {
this.blockBuilder.addIndented(text);
}
}
}
use of org.springframework.cloud.contract.spec.internal.Response in project spring-cloud-contract by spring-cloud.
the class ContractsToYaml method response.
protected void response(YamlContract yamlContract, Contract contract) {
if (contract.getResponse() != null) {
Response contractResponse = contract.getResponse();
ContentType contentType = evaluateClientSideContentType(contractResponse.getHeaders(), contractResponse.getBody());
YamlContract.Response response = new YamlContract.Response();
yamlContract.response = response;
mapResponseAsync(contractResponse, response);
mapResponseFixedDelayMilliseconds(contractResponse, response);
mapResponseStatus(contractResponse, response);
mapResponseHeaders(contractResponse, response);
mapResponseCookies(contractResponse, response);
mapResponseBody(contractResponse, response);
mapResponseBodyMatchers(contractResponse, response);
if (XML != contentType) {
setOutputBodyMatchers(contractResponse.getBody(), yamlContract.response.matchers.body);
}
setOutputHeadersMatchers(contractResponse.getHeaders(), yamlContract.response.matchers.headers);
}
}
Aggregations