Search in sources :

Example 6 with VerificationResult

use of com.github.tomakehurst.wiremock.verification.VerificationResult in project furms by unity-idm.

the class UnityClientTest method shouldSend_POST_toUnityServer.

@Test
void shouldSend_POST_toUnityServer() {
    // given
    RequestPattern request = new RequestPatternBuilder(POST, new UrlPattern(new EqualToPattern("/path/to/unity/test"), false)).build();
    server.addStubMapping(new StubMapping(request, ResponseDefinitionBuilder.responseDefinition().withHeader(CONTENT_TYPE, APPLICATION_JSON_VALUE).withBody("{\"field\": \"string\"}").withStatus(SC_OK).build()));
    // when
    unityClient.post("/path/to/unity/test", new SampleDto("string"));
    // then
    VerificationResult verificationResult = server.countRequestsMatching(request);
    assertThat(verificationResult.getCount()).isEqualTo(1);
}
Also used : VerificationResult(com.github.tomakehurst.wiremock.verification.VerificationResult) EqualToPattern(com.github.tomakehurst.wiremock.matching.EqualToPattern) StubMapping(com.github.tomakehurst.wiremock.stubbing.StubMapping) RequestPattern(com.github.tomakehurst.wiremock.matching.RequestPattern) RequestPatternBuilder(com.github.tomakehurst.wiremock.matching.RequestPatternBuilder) UrlPattern(com.github.tomakehurst.wiremock.matching.UrlPattern) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 7 with VerificationResult

use of com.github.tomakehurst.wiremock.verification.VerificationResult in project furms by unity-idm.

the class UnityClientTest method shouldSend_PUT_toUnityServer.

@Test
void shouldSend_PUT_toUnityServer() {
    // given
    RequestPattern request = new RequestPatternBuilder(PUT, new UrlPattern(new EqualToPattern("/path/to/unity/test"), false)).build();
    server.addStubMapping(new StubMapping(request, ResponseDefinitionBuilder.responseDefinition().withHeader(CONTENT_TYPE, APPLICATION_JSON_VALUE).withBody("{\"field\": \"string\"}").withStatus(SC_OK).build()));
    // when
    unityClient.put("/path/to/unity/test", Map.of("param", "test"));
    // then
    VerificationResult verificationResult = server.countRequestsMatching(request);
    assertThat(verificationResult.getCount()).isEqualTo(1);
}
Also used : VerificationResult(com.github.tomakehurst.wiremock.verification.VerificationResult) EqualToPattern(com.github.tomakehurst.wiremock.matching.EqualToPattern) StubMapping(com.github.tomakehurst.wiremock.stubbing.StubMapping) RequestPattern(com.github.tomakehurst.wiremock.matching.RequestPattern) RequestPatternBuilder(com.github.tomakehurst.wiremock.matching.RequestPatternBuilder) UrlPattern(com.github.tomakehurst.wiremock.matching.UrlPattern) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

VerificationResult (com.github.tomakehurst.wiremock.verification.VerificationResult)7 RequestPattern (com.github.tomakehurst.wiremock.matching.RequestPattern)6 EqualToPattern (com.github.tomakehurst.wiremock.matching.EqualToPattern)4 RequestPatternBuilder (com.github.tomakehurst.wiremock.matching.RequestPatternBuilder)4 UrlPattern (com.github.tomakehurst.wiremock.matching.UrlPattern)4 StubMapping (com.github.tomakehurst.wiremock.stubbing.StubMapping)4 Test (org.junit.jupiter.api.Test)4 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)4