use of com.github.tomakehurst.wiremock.matching.RequestPatternBuilder in project furms by unity-idm.
the class UnityClientTest method shouldSend_DELETE_toUnityServer.
@Test
void shouldSend_DELETE_toUnityServer() {
// given
RequestPattern request = new RequestPatternBuilder(DELETE, new UrlPattern(new EqualToPattern("/path/to/unity/test?recursive=true"), false)).build();
server.addStubMapping(new StubMapping(request, ResponseDefinitionBuilder.responseDefinition().withHeader(CONTENT_TYPE, APPLICATION_JSON_VALUE).withStatus(SC_OK).build()));
// when
unityClient.delete("/path/to/unity/test", Map.of("recursive", TRUE.toString()));
// then
VerificationResult verificationResult = server.countRequestsMatching(request);
assertThat(verificationResult.getCount()).isEqualTo(1);
}
use of com.github.tomakehurst.wiremock.matching.RequestPatternBuilder in project furms by unity-idm.
the class UnityClientTest method shouldSend_GET_toUnityServer.
@Test
void shouldSend_GET_toUnityServer() {
// given
RequestPattern request = new RequestPatternBuilder(GET, new UrlPattern(new EqualToPattern("/path/to/unity/test?param1=stringValue¶m2=1"), false)).build();
server.addStubMapping(new StubMapping(request, ResponseDefinitionBuilder.responseDefinition().withBody("{\"field\": \"string_value\"}").withHeader(CONTENT_TYPE, APPLICATION_JSON_VALUE).withStatus(SC_OK).build()));
// when
SampleDto response = unityClient.get("/path/to/unity/test", SampleDto.class, Map.of("param1", "stringValue", "param2", "1"));
// then
VerificationResult verificationResult = server.countRequestsMatching(request);
assertThat(verificationResult.getCount()).isEqualTo(1);
assertThat(response.getField()).isEqualTo("string_value");
}
use of com.github.tomakehurst.wiremock.matching.RequestPatternBuilder in project testnorge by navikt.
the class JsonWiremockHelper method verifyGet.
public void verifyGet() {
RequestPatternBuilder requestPatternBuilder = getRequestedFor(urlPathPattern);
verify(requestPatternBuilder);
}
use of com.github.tomakehurst.wiremock.matching.RequestPatternBuilder in project testnorge by navikt.
the class JsonWiremockHelper method verifyPost.
public void verifyPost() {
RequestPatternBuilder requestPatternBuilder = postRequestedFor(urlPathPattern);
if (requestBody != null) {
if (requestFieldsToIgnore.isEmpty()) {
requestPatternBuilder.withRequestBody(equalToJson(requestBody));
} else {
requestPatternBuilder.withRequestBody(matching(convertToRegexString(requestBody, requestFieldsToIgnore.toArray(String[]::new))));
}
}
verify(requestPatternBuilder);
}
use of com.github.tomakehurst.wiremock.matching.RequestPatternBuilder in project testnorge by navikt.
the class JsonWiremockHelper method verifyDelete.
public void verifyDelete() {
RequestPatternBuilder requestPatternBuilder = deleteRequestedFor(urlPathPattern);
if (requestBody != null) {
if (requestFieldsToIgnore.isEmpty()) {
requestPatternBuilder.withRequestBody(equalToJson(requestBody));
} else {
requestPatternBuilder.withRequestBody(matching(convertToRegexString(requestBody, requestFieldsToIgnore.toArray(String[]::new))));
}
}
verify(requestPatternBuilder);
}
Aggregations