use of com.github.tomakehurst.wiremock.admin.model.ListStubMappingsResult in project wiremock by wiremock.
the class StubbingAcceptanceTest method listingAllStubMappings.
@Test
public void listingAllStubMappings() {
stubFor(get(urlEqualTo("/stub/one")).willReturn(aResponse().withBody("One")));
stubFor(post(urlEqualTo("/stub/two")).willReturn(aResponse().withBody("Two").withStatus(201)));
ListStubMappingsResult listingResult = listAllStubMappings();
StubMapping mapping1 = listingResult.getMappings().get(0);
assertThat(mapping1.getRequest().getMethod(), is(POST));
assertThat(mapping1.getRequest().getUrl(), is("/stub/two"));
assertThat(mapping1.getResponse().getBody(), is("Two"));
assertThat(mapping1.getResponse().getStatus(), is(201));
StubMapping mapping2 = listingResult.getMappings().get(1);
assertThat(mapping2.getRequest().getMethod(), is(GET));
assertThat(mapping2.getRequest().getUrl(), is("/stub/one"));
assertThat(mapping2.getResponse().getBody(), is("One"));
}
use of com.github.tomakehurst.wiremock.admin.model.ListStubMappingsResult in project wiremock by wiremock.
the class FindStubMappingsByMetadataTask method execute.
@Override
public ResponseDefinition execute(Admin admin, Request request, PathParams pathParams) {
StringValuePattern pattern = Json.read(request.getBodyAsString(), StringValuePattern.class);
ListStubMappingsResult stubMappings = admin.findAllStubsByMetadata(pattern);
return ResponseDefinition.okForJson(stubMappings);
}
Aggregations