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);
}
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);
}
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}"));
}
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;
}
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));
}
Aggregations