@Test public void testHourlyHistoryWeatherAtStation () throws IOException, JSONException { HttpClient mockHttpClient = createHttpClientThatRespondsWith (TestData.HISTORY_WEATHER_AT_STATION_ID_BY_HOUR); OwmClient owm = new OwmClient (mockHttpClient); WeatherHistoryStationResponse historyResponse = owm.historyWeatherAtStation (9040, HistoryType.HOUR); assertNotNull (historyResponse); List<AbstractWeatherData> history = historyResponse.getHistory (); assertNotNull (history); assertTrue (history.size () == 14); AbstractWeatherData weather = history.get (0); assertNotNull (weather); assertEquals (289.26f, weather.getTemp (), 0.001f); assertEquals (1019f, weather.getPressure (), 0.01f); assertEquals (99f, weather.getHumidity (), 0.01f); assertEquals (0f, weather.getWindSpeed (), 0.01f); assertEquals (0f, weather.getWindGust (), 0.01f); assertEquals (Integer.MIN_VALUE, weather.getWindDeg ()); assertEquals (0, weather.getRain ()); assertEquals (Integer.MIN_VALUE, weather.getSnow ()); assertEquals (0, weather.getPrecipitation ()); }
public WeatherHistoryStationResponse historyWeatherAtStation (int stationId, 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/station/%d?type=%s", stationId, type); JSONObject response = doQuery (subUrl); return new WeatherHistoryStationResponse (response); }
OwmClient { public WeatherHistoryStationResponse historyWeatherAtStation (int stationId, 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/station/%d?type=%s", stationId, type); JSONObject response = doQuery (subUrl); return new WeatherHistoryStationResponse (response); } }
OwmClient { public WeatherHistoryStationResponse historyWeatherAtStation (int stationId, 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/station/%d?type=%s", stationId, type); JSONObject response = doQuery (subUrl); return new WeatherHistoryStationResponse (response); } OwmClient();  OwmClient(HttpClient httpClient); }
OwmClient { public WeatherHistoryStationResponse historyWeatherAtStation (int stationId, 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/station/%d?type=%s", stationId, type); JSONObject response = doQuery (subUrl); return new WeatherHistoryStationResponse (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 WeatherHistoryStationResponse historyWeatherAtStation (int stationId, 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/station/%d?type=%s", stationId, type); JSONObject response = doQuery (subUrl); return new WeatherHistoryStationResponse (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);  }