com.github.tomakehurst.wiremock.client.WireMock.findAll()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(4.8k)|赞(0)|评价(0)|浏览(98)

本文整理了Java中com.github.tomakehurst.wiremock.client.WireMock.findAll()方法的一些代码示例,展示了WireMock.findAll()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WireMock.findAll()方法的具体详情如下:
包路径:com.github.tomakehurst.wiremock.client.WireMock
类名称:WireMock
方法名:findAll

WireMock.findAll介绍

暂无

代码示例

代码示例来源:origin: aws/aws-sdk-java-v2

/**
 * @return All LoggedRequests that wire mock captured.
 */
public static List<LoggedRequest> findAllLoggedRequests() {
  List<LoggedRequest> requests = findAll(
      new RequestPatternBuilder(RequestMethod.ANY, urlMatching(".*")));
  return requests;
}

代码示例来源:origin: software.amazon.awssdk/protocol-tests-core

/**
   * @return All LoggedRequests that wire mock captured.
   */
  public static List<LoggedRequest> findAllLoggedRequests() {
    List<LoggedRequest> requests = findAll(
        new RequestPatternBuilder(RequestMethod.ANY, urlMatching(".*")));
    return requests;
  }
}

代码示例来源:origin: cyclestreets/android

List<LoggedRequest> requests = findAll(getRequestedFor(urlPathEqualTo("/v2/photomap.categories")));
assertThat(requests, hasSize(1));

代码示例来源:origin: cyclestreets/android

List<LoggedRequest> requests = findAll(getRequestedFor(urlPathEqualTo("/blog/feed/"))
    .withQueryParam("key", equalTo("myApiKey")));
assertThat(requests, hasSize(1));

代码示例来源:origin: cyclestreets/android

@Test
public void testGetPoiCategories() throws Exception {
 // given
 stubFor(get(urlPathEqualTo("/v2/pois.types"))
     .willReturn(aResponse()
         .withStatus(200)
         .withHeader("Content-Type", "application/json")
         .withHeader("Cache-Control", "public, max-age=604800")
         .withBodyFile("pois-types.json")));
 // when
 POICategories poiCategories = apiClient.getPOICategories(16);
 // call the endpoint 5 more times
 for (int ii = 0; ii < 5; ii++) {
  apiClient.getPOICategories(16);
 }
 // then
 verify(getRequestedFor(urlPathEqualTo("/v2/pois.types"))
     .withQueryParam("icons", equalTo("16"))
     .withQueryParam("key", equalTo("myApiKey")));
 assertThat(poiCategories.count(), is(52));
 POICategory category = poiCategories.get(37);
 assertThat(category.name(), is("Supermarkets"));
 assertThat(category.icon(), is(notNullValue()));
 // caching should mean the REST request is only made once
 List<LoggedRequest> requests = findAll(getRequestedFor(urlPathEqualTo("/v2/pois.types")));
 assertThat(requests, hasSize(1));
}

代码示例来源:origin: cyclestreets/android

@Test
public void testGeoCoder() throws Exception {
 // given
 stubFor(get(urlPathEqualTo("/v2/geocoder"))
     .willReturn(aResponse()
         .withStatus(200)
         .withHeader("Content-Type", "application/json")
         .withBodyFile("geocoder.json")));
 // when
 GeoPlaces geoPlaces = apiClient.geoCoder("High", 0.1, 52.2, 0.2, 52.3);
 // call the endpoint 5 more times
 for (int ii = 0; ii < 5; ii++) {
  apiClient.geoCoder("High", 0.1, 52.2, 0.2, 52.3);
 }
 // then
 verify(getRequestedFor(urlPathEqualTo("/v2/geocoder"))
     .withQueryParam("bbox", equalTo("0.1,52.2,0.2,52.3"))
     .withQueryParam("countrycodes", equalTo("gb,ie"))
     .withQueryParam("q", equalTo("High"))
     .withQueryParam("key", equalTo("myApiKey")));
 assertThat(geoPlaces.size(), is(5));
 GeoPlace place = geoPlaces.get(1);
 assertThat(place.name(), is("The High"));
 assertThat(place.near(), is("Essex, East of England"));
 assertThat(place.coord(), is(new GeoPoint(51.769678, 0.0939271)));
 // not cached - REST request will be made 6 times
 List<LoggedRequest> requests = findAll(getRequestedFor(urlPathEqualTo("/v2/geocoder")));
 assertThat(requests, hasSize(6));
}

代码示例来源:origin: cyclestreets/android

@Test
public void testGetPoisByRadius() throws Exception {
 // given
 stubFor(get(urlPathEqualTo("/v2/pois.locations"))
     .willReturn(aResponse()
         .withStatus(200)
         .withHeader("Content-Type", "application/json")
         .withBodyFile("pois.json")));
 // when
 List<POI> pois = apiClient.getPOIs("bikeshops", 0.15, 52.25, 100);
 // call the endpoint 5 more times
 for (int ii = 0; ii < 5; ii++) {
  apiClient.getPOIs("bikeshops", 0.15, 52.25, 100);
 }
 // then
 verify(getRequestedFor(urlPathEqualTo("/v2/pois.locations"))
     .withQueryParam("type", equalTo("bikeshops"))
     .withQueryParam("longitude", equalTo("0.15"))
     .withQueryParam("latitude", equalTo("52.25"))
     .withQueryParam("radius", equalTo("100"))
     .withQueryParam("limit", equalTo("150"))
     .withQueryParam("fields", equalTo("id,latitude,longitude,name,notes,osmTags,website"))
     .withQueryParam("key", equalTo("myApiKey")));
 validatePois(pois);
 // not cached - REST request will be made 6 times
 List<LoggedRequest> requests = findAll(getRequestedFor(urlPathEqualTo("/v2/pois.locations")));
 assertThat(requests, hasSize(6));
}

相关文章