use of com.github.tomakehurst.wiremock.matching.MatchResult in project spring-cloud-netflix by spring-cloud.
the class WireMockRestAssuredRequestAdapter method filter.
@Override
public Response filter(FilterableRequestSpecification requestSpec, FilterableResponseSpecification responseSpec, FilterContext context) {
Map<String, Object> configuration = getConfiguration(requestSpec, context);
configuration.put("contract.jsonPaths", this.jsonPaths.keySet());
Response response = context.next(requestSpec, responseSpec);
if (requestSpec.getBody() != null && !this.jsonPaths.isEmpty()) {
String actual = new String((byte[]) requestSpec.getBody());
for (JsonPath jsonPath : this.jsonPaths.values()) {
new JsonPathValue(jsonPath, actual).assertHasValue(Object.class, "an object");
}
}
if (this.builder != null) {
this.builder.willReturn(getResponseDefinition(response));
StubMapping stubMapping = this.builder.build();
MatchResult match = stubMapping.getRequest().match(new WireMockRestAssuredRequestAdapter(requestSpec));
assertThat(match.isExactMatch()).as("wiremock did not match request").isTrue();
configuration.put("contract.stubMapping", stubMapping);
}
return response;
}
Aggregations