use of com.github.tomakehurst.wiremock.matching.EqualToJsonPattern in project wiremock by wiremock.
the class RequestBodyPatternFactoryJsonDeserializerTest method correctlyDeserializesWithEqualToJsonMatcher.
@Test
public void correctlyDeserializesWithEqualToJsonMatcher() {
RequestBodyPatternFactory bodyPatternFactory = deserializeJson("{ \n" + " \"matcher\": \"equalToJson\", \n" + " \"ignoreArrayOrder\": false, \n" + " \"ignoreExtraElements\": true \n" + "} ");
EqualToJsonPattern bodyPattern = (EqualToJsonPattern) bodyPatternFactory.forRequest(mockRequest().body("1"));
assertThat(bodyPattern.isIgnoreArrayOrder(), is(false));
assertThat(bodyPattern.isIgnoreExtraElements(), is(true));
}
use of com.github.tomakehurst.wiremock.matching.EqualToJsonPattern in project wiremock by wiremock.
the class RequestBodyEqualToJsonPatternFactoryTest method withIgnoreArrayOrder.
@Test
public void withIgnoreArrayOrder() {
RequestBodyEqualToJsonPatternFactory patternFactory = new RequestBodyEqualToJsonPatternFactory(true, false);
EqualToJsonPattern pattern = patternFactory.forRequest(mockRequest().body("{}"));
assertThat(pattern.getEqualToJson(), is("{}"));
assertThat(pattern.isIgnoreExtraElements(), is(false));
assertThat(pattern.isIgnoreArrayOrder(), is(true));
}
use of com.github.tomakehurst.wiremock.matching.EqualToJsonPattern in project wiremock by wiremock.
the class RequestBodyEqualToJsonPatternFactoryTest method withIgnoreExtraElements.
@Test
public void withIgnoreExtraElements() {
RequestBodyEqualToJsonPatternFactory patternFactory = new RequestBodyEqualToJsonPatternFactory(false, true);
EqualToJsonPattern pattern = patternFactory.forRequest(mockRequest().body("{}"));
assertThat(pattern.getEqualToJson(), is("{}"));
assertThat(pattern.isIgnoreExtraElements(), is(true));
assertThat(pattern.isIgnoreArrayOrder(), is(false));
}
use of com.github.tomakehurst.wiremock.matching.EqualToJsonPattern in project wiremock by wiremock.
the class RecordingDslAcceptanceTest method supportsInstanceClientWithSpec.
@Test
public void supportsInstanceClientWithSpec() {
targetService.stubFor(post("/record-this-with-body").willReturn(ok()));
adminClient.startStubRecording(recordSpec().forTarget(targetBaseUrl).matchRequestBodyWithEqualToJson(true, true));
client.postJson("/record-this-with-body", "{}");
List<StubMapping> returnedMappings = adminClient.stopStubRecording().getStubMappings();
EqualToJsonPattern bodyPattern = (EqualToJsonPattern) returnedMappings.get(0).getRequest().getBodyPatterns().get(0);
assertThat(bodyPattern.isIgnoreArrayOrder(), is(true));
assertThat(bodyPattern.isIgnoreExtraElements(), is(true));
}
use of com.github.tomakehurst.wiremock.matching.EqualToJsonPattern in project wiremock by wiremock.
the class RecordingDslAcceptanceTest method supportsDirectDslCallsWithSpec.
@Test
public void supportsDirectDslCallsWithSpec() {
targetService.stubFor(post("/record-this-with-body").willReturn(ok()));
proxyingService.startRecording(recordSpec().forTarget(targetBaseUrl).matchRequestBodyWithEqualToJson(true, true));
client.postJson("/record-this-with-body", "{}");
List<StubMapping> returnedMappings = proxyingService.stopRecording().getStubMappings();
EqualToJsonPattern bodyPattern = (EqualToJsonPattern) returnedMappings.get(0).getRequest().getBodyPatterns().get(0);
assertThat(bodyPattern.isIgnoreArrayOrder(), is(true));
assertThat(bodyPattern.isIgnoreExtraElements(), is(true));
}
Aggregations