@Test public void testCurrentWeatherAtStationId () throws IOException, JSONException { HttpClient mockHttpClient = createHttpClientThatRespondsWith (TestData.CURRENT_WEATHER_AT_STATION_ID_9040); OwmClient owm = new OwmClient (mockHttpClient); StatusWeatherData weatherData = owm.currentWeatherAtStation (9040); assertEquals ("CT1AKV-10", weatherData.getName ()); assertEquals (9040, weatherData.getId ()); assertEquals (1360924205, weatherData.getDateTime ()); assertTrue (weatherData.hasMain ()); assertEquals ( 281.48f, weatherData.getMain ().getTemp (), 0.001f); assertEquals ( 99f, weatherData.getMain ().getHumidity (), 0.001f); assertEquals (1016f, weatherData.getMain ().getPressure (), 0.001f); assertTrue (weatherData.hasWind ()); assertEquals (0f, weatherData.getWind ().getSpeed (), 0.001f); assertEquals (0f, weatherData.getWind ().getGust (), 0.001f); assertEquals (0, weatherData.getWind ().getDeg ()); assertTrue (weatherData.hasRain ()); assertEquals (2, weatherData.getRainObj ().measurements ().size ()); assertEquals (0f, weatherData.getRainObj ().getMeasure (1), 0.001f); assertEquals (0f, weatherData.getRainObj ().getMeasure (24), 0.001f); assertEquals (0, weatherData.getRainObj ().getToday ()); assertTrue (weatherData.hasCoord ()); assertTrue (weatherData.getCoord ().hasLongitude ()); assertTrue (weatherData.getCoord ().hasLatitude ()); assertEquals (-8.7363f, weatherData.getCoord ().getLongitude (), 0.00001f); assertEquals (39.1862f, weatherData.getCoord ().getLatitude (), 0.00001f); assertTrue (weatherData.hasStation ()); assertEquals (7, weatherData.getStation ().getZoom ()); }
public StatusWeatherData currentWeatherAtStation (int stationId) throws IOException, JSONException { String subUrl = String.format (Locale.ROOT, "weather/station/%d?type=json", Integer.valueOf (stationId)); JSONObject response = doQuery (subUrl); return new StatusWeatherData (response); }
OwmClient { public StatusWeatherData currentWeatherAtStation (int stationId) throws IOException, JSONException { String subUrl = String.format (Locale.ROOT, "weather/station/%d?type=json", Integer.valueOf (stationId)); JSONObject response = doQuery (subUrl); return new StatusWeatherData (response); } }
OwmClient { public StatusWeatherData currentWeatherAtStation (int stationId) throws IOException, JSONException { String subUrl = String.format (Locale.ROOT, "weather/station/%d?type=json", Integer.valueOf (stationId)); JSONObject response = doQuery (subUrl); return new StatusWeatherData (response); } OwmClient();  OwmClient(HttpClient httpClient); }
OwmClient { public StatusWeatherData currentWeatherAtStation (int stationId) throws IOException, JSONException { String subUrl = String.format (Locale.ROOT, "weather/station/%d?type=json", Integer.valueOf (stationId)); JSONObject response = doQuery (subUrl); return new StatusWeatherData (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 StatusWeatherData currentWeatherAtStation (int stationId) throws IOException, JSONException { String subUrl = String.format (Locale.ROOT, "weather/station/%d?type=json", Integer.valueOf (stationId)); JSONObject response = doQuery (subUrl); return new StatusWeatherData (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);  }