Search in sources :

Example 1 with ListStubMappingsResult

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"));
}
Also used : ListStubMappingsResult(com.github.tomakehurst.wiremock.admin.model.ListStubMappingsResult) StubMapping(com.github.tomakehurst.wiremock.stubbing.StubMapping) Test(org.junit.jupiter.api.Test)

Example 2 with ListStubMappingsResult

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);
}
Also used : ListStubMappingsResult(com.github.tomakehurst.wiremock.admin.model.ListStubMappingsResult) StringValuePattern(com.github.tomakehurst.wiremock.matching.StringValuePattern)

Aggregations

ListStubMappingsResult (com.github.tomakehurst.wiremock.admin.model.ListStubMappingsResult)2 StringValuePattern (com.github.tomakehurst.wiremock.matching.StringValuePattern)1 StubMapping (com.github.tomakehurst.wiremock.stubbing.StubMapping)1 Test (org.junit.jupiter.api.Test)1