@Test public void testForecastAtCityName () throws IOException, JSONException { HttpClient mockHttpClient = createHttpClientThatRespondsWith (TestData.FORECAST_WEATHER_AT_CITY_NAME_LISBON); OwmClient owm = new OwmClient (mockHttpClient); WeatherForecastResponse forecastResponse = owm.forecastWeatherAtCity ("Lisbon"); City lisbon = forecastResponse.getCity (); assertNotNull (lisbon); assertTrue ("PT".equalsIgnoreCase (lisbon.getCountryCode ())); assertTrue ("Lisbon".equalsIgnoreCase (lisbon.getName ())); OwmClientTest.assertForecastWeatherDataList (forecastResponse.getForecasts (), Integer.MAX_VALUE); }
public WeatherForecastResponse forecastWeatherAtCity (int cityId) throws JSONException, IOException { String subUrl = String.format (Locale.ROOT, "forecast/city/%d?type=json&units=metric", cityId); JSONObject response = doQuery (subUrl); return new WeatherForecastResponse (response); }
OwmClient { public WeatherForecastResponse forecastWeatherAtCity (int cityId) throws JSONException, IOException { String subUrl = String.format (Locale.ROOT, "forecast/city/%d?type=json&units=metric", cityId); JSONObject response = doQuery (subUrl); return new WeatherForecastResponse (response); } }
OwmClient { public WeatherForecastResponse forecastWeatherAtCity (int cityId) throws JSONException, IOException { String subUrl = String.format (Locale.ROOT, "forecast/city/%d?type=json&units=metric", cityId); JSONObject response = doQuery (subUrl); return new WeatherForecastResponse (response); } OwmClient();  OwmClient(HttpClient httpClient); }
OwmClient { public WeatherForecastResponse forecastWeatherAtCity (int cityId) throws JSONException, IOException { String subUrl = String.format (Locale.ROOT, "forecast/city/%d?type=json&units=metric", cityId); JSONObject response = doQuery (subUrl); return new WeatherForecastResponse (response); } OwmClient();  OwmClient(HttpClient httpClient); void setAPPID(String appid); WeatherStatusResponse currentWeatherAroundPoint(float lat, float lon, int cnt); WeatherStatusResponse currentWeatherAtCity(float lat, float lon, int cnt); WeatherStatusResponse currentWeatherInBoundingBox(float northLat, float westLon, float southLat, float eastLon); WeatherStatusResponse currentWeatherAtCityBoundingBox(float northLat, float westLon, float southLat, float eastLon); WeatherStatusResponse currentWeatherInCircle(float lat, float lon, float radius); WeatherStatusResponse currentWeatherAtCityCircle(float lat, float lon, float radius); StatusWeatherData currentWeatherAtCity(int cityId); StatusWeatherData currentWeatherAtStation(int stationId); WeatherStatusResponse currentWeatherAtCity(String cityName); WeatherStatusResponse currentWeatherAtCity(String cityName, String countryCode); WeatherForecastResponse forecastWeatherAtCity(int cityId); WeatherForecastResponse forecastWeatherAtCity(String cityName); WeatherHistoryCityResponse historyWeatherAtCity(int cityId, HistoryType type); WeatherHistoryStationResponse historyWeatherAtStation(int stationId, HistoryType type); }
OwmClient { public WeatherForecastResponse forecastWeatherAtCity (int cityId) throws JSONException, IOException { String subUrl = String.format (Locale.ROOT, "forecast/city/%d?type=json&units=metric", cityId); JSONObject response = doQuery (subUrl); return new WeatherForecastResponse (response); } OwmClient();  OwmClient(HttpClient httpClient); void setAPPID(String appid); WeatherStatusResponse currentWeatherAroundPoint(float lat, float lon, int cnt); WeatherStatusResponse currentWeatherAtCity(float lat, float lon, int cnt); WeatherStatusResponse currentWeatherInBoundingBox(float northLat, float westLon, float southLat, float eastLon); WeatherStatusResponse currentWeatherAtCityBoundingBox(float northLat, float westLon, float southLat, float eastLon); WeatherStatusResponse currentWeatherInCircle(float lat, float lon, float radius); WeatherStatusResponse currentWeatherAtCityCircle(float lat, float lon, float radius); StatusWeatherData currentWeatherAtCity(int cityId); StatusWeatherData currentWeatherAtStation(int stationId); WeatherStatusResponse currentWeatherAtCity(String cityName); WeatherStatusResponse currentWeatherAtCity(String cityName, String countryCode); WeatherForecastResponse forecastWeatherAtCity(int cityId); WeatherForecastResponse forecastWeatherAtCity(String cityName); WeatherHistoryCityResponse historyWeatherAtCity(int cityId, HistoryType type); WeatherHistoryStationResponse historyWeatherAtStation(int stationId, HistoryType type);  }