Search in sources :

Example 1 with VerificationResult

use of com.github.tomakehurst.wiremock.verification.VerificationResult 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);
}
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 2 with VerificationResult

use of com.github.tomakehurst.wiremock.verification.VerificationResult 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&param2=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");
}
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 3 with VerificationResult

use of com.github.tomakehurst.wiremock.verification.VerificationResult in project ccd-data-store-api by hmcts.

the class ReferenceDataCacheRefreshIT method verifyWiremockInvocation.

private void verifyWiremockInvocation(final String path, final int count) {
    final RequestPattern requestPattern = getRequestedFor(urlPathEqualTo(path)).build();
    final VerificationResult verificationResult = wireMockServer.countRequestsMatching(requestPattern);
    assertThat(verificationResult).isNotNull().satisfies(result -> assertThat(result.getCount()).isGreaterThanOrEqualTo(count));
}
Also used : VerificationResult(com.github.tomakehurst.wiremock.verification.VerificationResult) RequestPattern(com.github.tomakehurst.wiremock.matching.RequestPattern)

Example 4 with VerificationResult

use of com.github.tomakehurst.wiremock.verification.VerificationResult in project wiremock by wiremock.

the class GetRequestCountTask method execute.

@Override
public ResponseDefinition execute(Admin admin, Request request, PathParams pathParams) {
    RequestPattern requestPattern = Json.read(request.getBodyAsString(), RequestPattern.class);
    VerificationResult result = admin.countRequestsMatching(requestPattern);
    return responseDefinition().withStatus(HTTP_OK).withBody(write(result)).withHeader("Content-Type", "application/json").build();
}
Also used : VerificationResult(com.github.tomakehurst.wiremock.verification.VerificationResult) RequestPattern(com.github.tomakehurst.wiremock.matching.RequestPattern)

Example 5 with VerificationResult

use of com.github.tomakehurst.wiremock.verification.VerificationResult in project wiremock by wiremock.

the class StubMappingJsonRecorder method requestNotAlreadyReceived.

private boolean requestNotAlreadyReceived(RequestPattern requestPattern) {
    VerificationResult verificationResult = admin.countRequestsMatching(requestPattern);
    verificationResult.assertRequestJournalEnabled();
    return (verificationResult.getCount() < 1);
}
Also used : VerificationResult(com.github.tomakehurst.wiremock.verification.VerificationResult)

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