@Test public void testGeoCoder() throws Exception { stubFor(get(urlPathEqualTo("/v2/geocoder")) .willReturn(aResponse() .withStatus(200) .withHeader("Content-Type", "application/json") .withBodyFile("geocoder.json"))); GeoPlaces geoPlaces = apiClient.geoCoder("High", 0.1, 52.2, 0.2, 52.3); for (int ii = 0; ii < 5; ii++) { apiClient.geoCoder("High", 0.1, 52.2, 0.2, 52.3); } 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()).isEqualTo(5); GeoPlace place = geoPlaces.get(1); assertThat(place.name()).isEqualTo("The High"); assertThat(place.near()).isEqualTo("Essex, East of England"); assertThat(place.coord()).isEqualTo(new GeoPoint(51.769678, 0.0939271)); List<LoggedRequest> requests = findAll(getRequestedFor(urlPathEqualTo("/v2/geocoder"))); assertThat(requests).hasSize(6); }
public GeoPlaces geoCoder(final String search, final double lonW, final double latS, final double lonE, final double latN) throws IOException { String bbox = toBboxString(lonW, latS, lonE, latN); Response<FeatureCollection> response = v2Api.geoCoder(search, bbox).execute(); return GeoPlacesFactory.toGeoPlaces(response.body()); }
RetrofitApiClient { public GeoPlaces geoCoder(final String search, final double lonW, final double latS, final double lonE, final double latN) throws IOException { String bbox = toBboxString(lonW, latS, lonE, latN); Response<FeatureCollection> response = v2Api.geoCoder(search, bbox).execute(); return GeoPlacesFactory.toGeoPlaces(response.body()); } }
RetrofitApiClient { public GeoPlaces geoCoder(final String search, final double lonW, final double latS, final double lonE, final double latN) throws IOException { String bbox = toBboxString(lonW, latS, lonE, latN); Response<FeatureCollection> response = v2Api.geoCoder(search, bbox).execute(); return GeoPlacesFactory.toGeoPlaces(response.body()); } @SuppressWarnings("deprecation")  RetrofitApiClient(Builder builder); }
RetrofitApiClient { public GeoPlaces geoCoder(final String search, final double lonW, final double latS, final double lonE, final double latN) throws IOException { String bbox = toBboxString(lonW, latS, lonE, latN); Response<FeatureCollection> response = v2Api.geoCoder(search, bbox).execute(); return GeoPlacesFactory.toGeoPlaces(response.body()); } @SuppressWarnings("deprecation")  RetrofitApiClient(Builder builder); String getJourneyJson(final String plan,
                               final String itineraryPoints,
                               final String leaving,
                               final String arriving,
                               final int speed); String retrievePreviousJourneyJson(final String plan,
                                            final long itineraryId); Blog getBlogEntries(); POICategories getPOICategories(); List<POI> getPOIs(final String type,
                           final double lonW,
                           final double latS,
                           final double lonE,
                           final double latN); List<POI> getPOIs(final String type,
                           final double lon,
                           final double lat,
                           final int radius); GeoPlaces geoCoder(final String search,
                            final double lonW,
                            final double latS,
                            final double lonE,
                            final double latN); PhotomapCategories getPhotomapCategories(); Photos getPhotos(final double lonW,
                          final double latS,
                          final double lonE,
                          final double latN); Photos getPhoto(final long photoId); UserJourneys getUserJourneys(final String username); Result register(final String username,
                         final String password,
                         final String name,
                         final String email); Signin.Result authenticate(final String identifier,
                                    final String password); Result sendFeedback(final int itinerary,
                             final String comments,
                             final String name,
                             final String email); Upload.Result uploadPhoto(final String username,
                                   final String password,
                                   final double lon,
                                   final double lat,
                                   final long dateTime,
                                   final String category,
                                   final String metaCat,
                                   final String caption,
                                   final String filename); }
RetrofitApiClient { public GeoPlaces geoCoder(final String search, final double lonW, final double latS, final double lonE, final double latN) throws IOException { String bbox = toBboxString(lonW, latS, lonE, latN); Response<FeatureCollection> response = v2Api.geoCoder(search, bbox).execute(); return GeoPlacesFactory.toGeoPlaces(response.body()); } @SuppressWarnings("deprecation")  RetrofitApiClient(Builder builder); String getJourneyJson(final String plan,
                               final String itineraryPoints,
                               final String leaving,
                               final String arriving,
                               final int speed); String retrievePreviousJourneyJson(final String plan,
                                            final long itineraryId); Blog getBlogEntries(); POICategories getPOICategories(); List<POI> getPOIs(final String type,
                           final double lonW,
                           final double latS,
                           final double lonE,
                           final double latN); List<POI> getPOIs(final String type,
                           final double lon,
                           final double lat,
                           final int radius); GeoPlaces geoCoder(final String search,
                            final double lonW,
                            final double latS,
                            final double lonE,
                            final double latN); PhotomapCategories getPhotomapCategories(); Photos getPhotos(final double lonW,
                          final double latS,
                          final double lonE,
                          final double latN); Photos getPhoto(final long photoId); UserJourneys getUserJourneys(final String username); Result register(final String username,
                         final String password,
                         final String name,
                         final String email); Signin.Result authenticate(final String identifier,
                                    final String password); Result sendFeedback(final int itinerary,
                             final String comments,
                             final String name,
                             final String email); Upload.Result uploadPhoto(final String username,
                                   final String password,
                                   final double lon,
                                   final double lat,
                                   final long dateTime,
                                   final String category,
                                   final String metaCat,
                                   final String caption,
                                   final String filename);  }