Package com.github.tomakehurst.wiremock.stubbing

Examples of com.github.tomakehurst.wiremock.stubbing.StubMapping


        wireMock.register(mapping);
    }
 
  public void expectExactlyOneAddResponseCallWithJson(final String json) {
        final StubMapping stubMapping = Json.read(json, StubMapping.class);

    context.checking(new Expectations() {{
      one(admin).addStubMapping(stubMapping);
    }});
  }
View Full Code Here


    public static void resetToDefault() {
        defaultInstance.resetToDefaultMappings();
    }

  public void register(MappingBuilder mappingBuilder) {
    StubMapping mapping = mappingBuilder.build();
    register(mapping);
  }
View Full Code Here

 
  public StubMapping build() {
    RequestPattern requestPattern = new RequestPattern(method, url);
    ResponseDefinition response = new ResponseDefinition(responseStatus, responseBody);
    response.setHeaders(new HttpHeaders(headers));
    StubMapping mapping = new StubMapping(requestPattern, response);
    return mapping;
  }
View Full Code Here

    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"));
    }
View Full Code Here

TOP

Related Classes of com.github.tomakehurst.wiremock.stubbing.StubMapping

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.