Search in sources :

Example 6 with RequestPattern

use of com.github.tomakehurst.wiremock.matching.RequestPattern in project wiremock by wiremock.

the class FindNearMissesForRequestPatternTask method execute.

@Override
public ResponseDefinition execute(Admin admin, Request request, PathParams pathParams) {
    RequestPattern requestPattern = Json.read(request.getBodyAsString(), RequestPattern.class);
    FindNearMissesResult nearMissesResult = admin.findTopNearMissesFor(requestPattern);
    return ResponseDefinition.okForJson(nearMissesResult);
}
Also used : FindNearMissesResult(com.github.tomakehurst.wiremock.verification.FindNearMissesResult) RequestPattern(com.github.tomakehurst.wiremock.matching.RequestPattern)

Example 7 with RequestPattern

use of com.github.tomakehurst.wiremock.matching.RequestPattern in project wiremock by wiremock.

the class RemoveServeEventsByRequestPatternTask method execute.

@Override
public ResponseDefinition execute(Admin admin, Request request, PathParams pathParams) {
    RequestPattern requestPattern = Json.read(request.getBodyAsString(), RequestPattern.class);
    FindServeEventsResult findServeEventsResult = admin.removeServeEventsMatching(requestPattern);
    return ResponseDefinition.okForJson(findServeEventsResult);
}
Also used : FindServeEventsResult(com.github.tomakehurst.wiremock.verification.FindServeEventsResult) RequestPattern(com.github.tomakehurst.wiremock.matching.RequestPattern)

Example 8 with RequestPattern

use of com.github.tomakehurst.wiremock.matching.RequestPattern in project wiremock by wiremock.

the class AdminRequestHandlerTest method shouldReturnCountOfMatchingRequests.

@Test
public void shouldReturnCountOfMatchingRequests() {
    RequestPattern requestPattern = newRequestPattern(DELETE, urlEqualTo("/some/resource")).build();
    Mockito.when(admin.countRequestsMatching(requestPattern)).thenReturn(VerificationResult.withCount(5));
    handler.handle(aRequest().withUrl("/requests/count").withMethod(POST).withBody(REQUEST_PATTERN_SAMPLE).build(), httpResponder);
    Response response = httpResponder.response;
    assertThat(response.getStatus(), is(HTTP_OK));
    assertThat(response.getBodyAsString(), equalToJson("{ \"count\": 5, \"requestJournalDisabled\" : false}"));
}
Also used : Response(com.github.tomakehurst.wiremock.http.Response) RequestPattern(com.github.tomakehurst.wiremock.matching.RequestPattern) RequestPatternBuilder.newRequestPattern(com.github.tomakehurst.wiremock.matching.RequestPatternBuilder.newRequestPattern) Test(org.junit.jupiter.api.Test)

Example 9 with RequestPattern

use of com.github.tomakehurst.wiremock.matching.RequestPattern in project wiremock by wiremock.

the class InMemoryStubMappingsTest method aMapping.

private StubMapping aMapping(Integer priority, String url) {
    RequestPattern requestPattern = newRequestPattern(ANY, urlEqualTo(url)).build();
    StubMapping mapping = new StubMapping(requestPattern, new ResponseDefinition());
    mapping.setPriority(priority);
    return mapping;
}
Also used : ResponseDefinition(com.github.tomakehurst.wiremock.http.ResponseDefinition) RequestPatternBuilder.newRequestPattern(com.github.tomakehurst.wiremock.matching.RequestPatternBuilder.newRequestPattern) RequestPattern(com.github.tomakehurst.wiremock.matching.RequestPattern)

Example 10 with RequestPattern

use of com.github.tomakehurst.wiremock.matching.RequestPattern 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)

Aggregations

RequestPattern (com.github.tomakehurst.wiremock.matching.RequestPattern)20 StubMapping (com.github.tomakehurst.wiremock.stubbing.StubMapping)8 RequestPatternBuilder (com.github.tomakehurst.wiremock.matching.RequestPatternBuilder)6 UrlPattern (com.github.tomakehurst.wiremock.matching.UrlPattern)6 VerificationResult (com.github.tomakehurst.wiremock.verification.VerificationResult)6 ResponseDefinition (com.github.tomakehurst.wiremock.http.ResponseDefinition)5 Test (org.junit.jupiter.api.Test)5 EqualToPattern (com.github.tomakehurst.wiremock.matching.EqualToPattern)4 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)4 RequestPatternBuilder.newRequestPattern (com.github.tomakehurst.wiremock.matching.RequestPatternBuilder.newRequestPattern)3 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 WireMock (com.github.tomakehurst.wiremock.client.WireMock)2 Parameters (com.github.tomakehurst.wiremock.extension.Parameters)2 RequestMethod (com.github.tomakehurst.wiremock.http.RequestMethod)2 ContentPattern (com.github.tomakehurst.wiremock.matching.ContentPattern)2 StringValuePattern (com.github.tomakehurst.wiremock.matching.StringValuePattern)2 GString (groovy.lang.GString)2 Arrays (java.util.Arrays)2 Collection (java.util.Collection)2