@Test public void testHourHistoryWeatherAtCity () throws IOException, JSONException { HttpClient mockHttpClient = createHttpClientThatRespondsWith (TestData.HISTORY_WEATHER_AT_CITY_ID); OwmClient owm = new OwmClient (mockHttpClient); WeatherHistoryCityResponse history = owm.historyWeatherAtCity (2885679, HistoryType.HOUR); assertEquals (0.0186d, history.getCalcTime (), 0.0001d); assertEquals (0.0056d, history.getCalcTimeFetch (), 0.0001d); assertEquals (0.0131d, history.getCalcTimeFind (), 0.0001d); assertEquals (2885679, history.getCityId ()); assertTrue (history.hasHistory ()); }
public WeatherHistoryCityResponse historyWeatherAtCity (int cityId, HistoryType type) throws JSONException, IOException { if (type == HistoryType.UNKNOWN) throw new IllegalArgumentException("Can't do a historic request for unknown type of history."); String subUrl = String.format (Locale.ROOT, "history/city/%d?type=%s", cityId, type); JSONObject response = doQuery (subUrl); return new WeatherHistoryCityResponse (response); }
OwmClient { public WeatherHistoryCityResponse historyWeatherAtCity (int cityId, HistoryType type) throws JSONException, IOException { if (type == HistoryType.UNKNOWN) throw new IllegalArgumentException("Can't do a historic request for unknown type of history."); String subUrl = String.format (Locale.ROOT, "history/city/%d?type=%s", cityId, type); JSONObject response = doQuery (subUrl); return new WeatherHistoryCityResponse (response); } }
OwmClient { public WeatherHistoryCityResponse historyWeatherAtCity (int cityId, HistoryType type) throws JSONException, IOException { if (type == HistoryType.UNKNOWN) throw new IllegalArgumentException("Can't do a historic request for unknown type of history."); String subUrl = String.format (Locale.ROOT, "history/city/%d?type=%s", cityId, type); JSONObject response = doQuery (subUrl); return new WeatherHistoryCityResponse (response); } OwmClient();  OwmClient(HttpClient httpClient); }
OwmClient { public WeatherHistoryCityResponse historyWeatherAtCity (int cityId, HistoryType type) throws JSONException, IOException { if (type == HistoryType.UNKNOWN) throw new IllegalArgumentException("Can't do a historic request for unknown type of history."); String subUrl = String.format (Locale.ROOT, "history/city/%d?type=%s", cityId, type); JSONObject response = doQuery (subUrl); return new WeatherHistoryCityResponse (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 WeatherHistoryCityResponse historyWeatherAtCity (int cityId, HistoryType type) throws JSONException, IOException { if (type == HistoryType.UNKNOWN) throw new IllegalArgumentException("Can't do a historic request for unknown type of history."); String subUrl = String.format (Locale.ROOT, "history/city/%d?type=%s", cityId, type); JSONObject response = doQuery (subUrl); return new WeatherHistoryCityResponse (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);  }