From 5d6b8c4d9711be1bc45dde3d3e1af5df35c1b0af Mon Sep 17 00:00:00 2001 From: Alexey Zinchenko Date: Mon, 22 Mar 2021 23:00:30 +0300 Subject: [PATCH] Rechecked weather API response mapping. Refactoring. --- .../api/OpenWeatherMapClient.java | 2 +- .../api/model/forecast/WeatherForecast.java | 1 - .../api/model/forecast/Wind.java | 158 ++++++++++++++++++ .../api/model/{ => weather}/Rain.java | 24 ++- .../api/model/{ => weather}/Snow.java | 24 ++- .../api/model/{ => weather}/Temperature.java | 20 ++- .../api/model/{ => weather}/Weather.java | 27 ++- .../api/model/{ => weather}/Wind.java | 17 +- ...ayThreeHourStepForecastResponseMapper.java | 4 +- .../weather/CurrentWeatherResponseMapper.java | 99 ++++++----- ...tCurrentWeatherAsyncRequestTerminator.java | 2 +- ...rentWeatherAsyncRequestTerminatorImpl.java | 2 +- ...ResultCurrentWeatherRequestTerminator.java | 2 +- ...ltCurrentWeatherRequestTerminatorImpl.java | 2 +- ...tCurrentWeatherAsyncRequestTerminator.java | 2 +- ...rentWeatherAsyncRequestTerminatorImpl.java | 2 +- ...ResultCurrentWeatherRequestTerminator.java | 2 +- ...ltCurrentWeatherRequestTerminatorImpl.java | 2 +- .../model/{ => weather}/CloudsUnitTest.java | 25 ++- .../CoordinateRectangleUnitTest.java | 25 ++- .../{ => weather}/CoordinateUnitTest.java | 25 ++- .../model/{ => weather}/HumidityUnitTest.java | 25 ++- .../model/{ => weather}/LocationUnitTest.java | 26 ++- .../model/{ => weather}/PressureUnitTest.java | 25 ++- .../api/model/{ => weather}/RainUnitTest.java | 25 ++- .../api/model/{ => weather}/SnowUnitTest.java | 25 ++- .../{ => weather}/TemperatureUnitTest.java | 24 ++- .../model/{ => weather}/WeatherUnitTest.java | 30 +++- .../api/model/{ => weather}/WindUnitTest.java | 25 ++- ...leResultCurrentWeatherIntegrationTest.java | 2 +- ...leResultCurrentWeatherIntegrationTest.java | 2 +- 31 files changed, 600 insertions(+), 76 deletions(-) create mode 100644 src/main/java/com/github/prominence/openweathermap/api/model/forecast/Wind.java rename src/main/java/com/github/prominence/openweathermap/api/model/{ => weather}/Rain.java (73%) rename src/main/java/com/github/prominence/openweathermap/api/model/{ => weather}/Snow.java (73%) rename src/main/java/com/github/prominence/openweathermap/api/model/{ => weather}/Temperature.java (86%) rename src/main/java/com/github/prominence/openweathermap/api/model/{ => weather}/Weather.java (84%) rename src/main/java/com/github/prominence/openweathermap/api/model/{ => weather}/Wind.java (89%) rename src/test/java/com/github/prominence/openweathermap/api/model/{ => weather}/CloudsUnitTest.java (64%) rename src/test/java/com/github/prominence/openweathermap/api/model/{ => weather}/CoordinateRectangleUnitTest.java (74%) rename src/test/java/com/github/prominence/openweathermap/api/model/{ => weather}/CoordinateUnitTest.java (76%) rename src/test/java/com/github/prominence/openweathermap/api/model/{ => weather}/HumidityUnitTest.java (65%) rename src/test/java/com/github/prominence/openweathermap/api/model/{ => weather}/LocationUnitTest.java (75%) rename src/test/java/com/github/prominence/openweathermap/api/model/{ => weather}/PressureUnitTest.java (70%) rename src/test/java/com/github/prominence/openweathermap/api/model/{ => weather}/RainUnitTest.java (66%) rename src/test/java/com/github/prominence/openweathermap/api/model/{ => weather}/SnowUnitTest.java (66%) rename src/test/java/com/github/prominence/openweathermap/api/model/{ => weather}/TemperatureUnitTest.java (71%) rename src/test/java/com/github/prominence/openweathermap/api/model/{ => weather}/WeatherUnitTest.java (83%) rename src/test/java/com/github/prominence/openweathermap/api/model/{ => weather}/WindUnitTest.java (74%) diff --git a/src/main/java/com/github/prominence/openweathermap/api/OpenWeatherMapClient.java b/src/main/java/com/github/prominence/openweathermap/api/OpenWeatherMapClient.java index 59e31f7..02134a0 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/OpenWeatherMapClient.java +++ b/src/main/java/com/github/prominence/openweathermap/api/OpenWeatherMapClient.java @@ -49,7 +49,7 @@ public class OpenWeatherMapClient { } // TODO: - // * Forecast: hourly, daily + // * Forecast: hourly, daily. Probably better to cover all free-plan functionality? // * Air Pollution // * Ultraviolet index // DOCS diff --git a/src/main/java/com/github/prominence/openweathermap/api/model/forecast/WeatherForecast.java b/src/main/java/com/github/prominence/openweathermap/api/model/forecast/WeatherForecast.java index fd1c8c1..67f0bc2 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/model/forecast/WeatherForecast.java +++ b/src/main/java/com/github/prominence/openweathermap/api/model/forecast/WeatherForecast.java @@ -25,7 +25,6 @@ package com.github.prominence.openweathermap.api.model.forecast; import com.github.prominence.openweathermap.api.model.Clouds; import com.github.prominence.openweathermap.api.model.Humidity; import com.github.prominence.openweathermap.api.model.Pressure; -import com.github.prominence.openweathermap.api.model.Wind; import com.github.prominence.openweathermap.api.model.DayTime; import java.time.LocalDateTime; diff --git a/src/main/java/com/github/prominence/openweathermap/api/model/forecast/Wind.java b/src/main/java/com/github/prominence/openweathermap/api/model/forecast/Wind.java new file mode 100644 index 0000000..edeb5e6 --- /dev/null +++ b/src/main/java/com/github/prominence/openweathermap/api/model/forecast/Wind.java @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2021 Alexey Zinchenko + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/* + * Copyright (c) 2021 Alexey Zinchenko + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.prominence.openweathermap.api.model.forecast; + +import java.util.Objects; + +/** + * The type Wind. + */ +public class Wind { + + private double speed; + private Double degrees; + private String unit; + + /** + * Instantiates a new Wind. + * + * @param speed the speed + * @param unit the unitSystem + */ + public Wind(double speed, String unit) { + if (speed < 0) { + throw new IllegalArgumentException("Wind speed value must be in positive or zero."); + } + if (unit == null) { + throw new IllegalArgumentException("Unit must be set."); + } + this.speed = speed; + this.unit = unit; + } + + /** + * Gets speed. + * + * @return the speed + */ + public double getSpeed() { + return speed; + } + + /** + * Sets speed. + * + * @param speed the speed + */ + public void setSpeed(double speed) { + if (speed < 0) { + throw new IllegalArgumentException("Wind speed value must be in positive or zero."); + } + this.speed = speed; + } + + /** + * Gets degrees. + * + * @return the degrees + */ + public Double getDegrees() { + return degrees; + } + + /** + * Sets degrees. + * + * @param degrees the degrees + */ + public void setDegrees(double degrees) { + if (degrees < 0 || degrees > 360) { + throw new IllegalArgumentException("Wind direction value must be in [0, 360] range."); + } + this.degrees = degrees; + } + + /** + * Gets unitSystem. + * + * @return the unitSystem + */ + public String getUnit() { + return unit; + } + + /** + * Sets unitSystem. + * + * @param unit the unitSystem + */ + public void setUnit(String unit) { + if (unit == null) { + throw new IllegalArgumentException("Unit must be set."); + } + this.unit = unit; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof Wind)) return false; + Wind wind = (Wind) o; + return Double.compare(wind.speed, speed) == 0 && + Objects.equals(degrees, wind.degrees) && + Objects.equals(unit, wind.unit); + } + + @Override + public int hashCode() { + return Objects.hash(speed, degrees, unit); + } + + @Override + public String toString() { + return "Wind speed: " + speed + " " + unit + + ", degrees: " + degrees; + } +} diff --git a/src/main/java/com/github/prominence/openweathermap/api/model/Rain.java b/src/main/java/com/github/prominence/openweathermap/api/model/weather/Rain.java similarity index 73% rename from src/main/java/com/github/prominence/openweathermap/api/model/Rain.java rename to src/main/java/com/github/prominence/openweathermap/api/model/weather/Rain.java index e146f38..24449ae 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/model/Rain.java +++ b/src/main/java/com/github/prominence/openweathermap/api/model/weather/Rain.java @@ -20,7 +20,29 @@ * SOFTWARE. */ -package com.github.prominence.openweathermap.api.model; +/* + * Copyright (c) 2021 Alexey Zinchenko + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.prominence.openweathermap.api.model.weather; import java.util.Objects; diff --git a/src/main/java/com/github/prominence/openweathermap/api/model/Snow.java b/src/main/java/com/github/prominence/openweathermap/api/model/weather/Snow.java similarity index 73% rename from src/main/java/com/github/prominence/openweathermap/api/model/Snow.java rename to src/main/java/com/github/prominence/openweathermap/api/model/weather/Snow.java index b9660f2..9c7e881 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/model/Snow.java +++ b/src/main/java/com/github/prominence/openweathermap/api/model/weather/Snow.java @@ -20,7 +20,29 @@ * SOFTWARE. */ -package com.github.prominence.openweathermap.api.model; +/* + * Copyright (c) 2021 Alexey Zinchenko + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.prominence.openweathermap.api.model.weather; import java.util.Objects; diff --git a/src/main/java/com/github/prominence/openweathermap/api/model/Temperature.java b/src/main/java/com/github/prominence/openweathermap/api/model/weather/Temperature.java similarity index 86% rename from src/main/java/com/github/prominence/openweathermap/api/model/Temperature.java rename to src/main/java/com/github/prominence/openweathermap/api/model/weather/Temperature.java index 9719dbc..1d56e5f 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/model/Temperature.java +++ b/src/main/java/com/github/prominence/openweathermap/api/model/weather/Temperature.java @@ -20,7 +20,7 @@ * SOFTWARE. */ -package com.github.prominence.openweathermap.api.model; +package com.github.prominence.openweathermap.api.model.weather; import java.util.Objects; @@ -29,6 +29,7 @@ public class Temperature { private double value; private Double maxTemperature; private Double minTemperature; + private Double feelsLike; private String unit; public Temperature(double value, String unit) { @@ -63,6 +64,14 @@ public class Temperature { this.minTemperature = minTemperature; } + public Double getFeelsLike() { + return feelsLike; + } + + public void setFeelsLike(Double feelsLike) { + this.feelsLike = feelsLike; + } + public String getUnit() { return unit; } @@ -82,12 +91,13 @@ public class Temperature { return Double.compare(that.value, value) == 0 && Objects.equals(maxTemperature, that.maxTemperature) && Objects.equals(minTemperature, that.minTemperature) && + Objects.equals(feelsLike, that.feelsLike) && Objects.equals(unit, that.unit); } @Override public int hashCode() { - return Objects.hash(value, maxTemperature, minTemperature, unit); + return Objects.hash(value, maxTemperature, minTemperature, feelsLike, unit); } @Override @@ -109,6 +119,12 @@ public class Temperature { stringBuilder.append(' '); stringBuilder.append(unit); } + if (feelsLike != null) { + stringBuilder.append(", Feels like: "); + stringBuilder.append(feelsLike); + stringBuilder.append(' '); + stringBuilder.append(unit); + } return stringBuilder.toString(); } diff --git a/src/main/java/com/github/prominence/openweathermap/api/model/Weather.java b/src/main/java/com/github/prominence/openweathermap/api/model/weather/Weather.java similarity index 84% rename from src/main/java/com/github/prominence/openweathermap/api/model/Weather.java rename to src/main/java/com/github/prominence/openweathermap/api/model/weather/Weather.java index 7baa830..92576f7 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/model/Weather.java +++ b/src/main/java/com/github/prominence/openweathermap/api/model/weather/Weather.java @@ -20,7 +20,31 @@ * SOFTWARE. */ -package com.github.prominence.openweathermap.api.model; +/* + * Copyright (c) 2021 Alexey Zinchenko + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.prominence.openweathermap.api.model.weather; + +import com.github.prominence.openweathermap.api.model.*; import java.time.LocalDateTime; import java.util.Objects; @@ -30,6 +54,7 @@ public class Weather { private String state; private String description; private String weatherIconUrl; + private LocalDateTime requestedOn; private Temperature temperature; diff --git a/src/main/java/com/github/prominence/openweathermap/api/model/Wind.java b/src/main/java/com/github/prominence/openweathermap/api/model/weather/Wind.java similarity index 89% rename from src/main/java/com/github/prominence/openweathermap/api/model/Wind.java rename to src/main/java/com/github/prominence/openweathermap/api/model/weather/Wind.java index bb62de3..d2128c3 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/model/Wind.java +++ b/src/main/java/com/github/prominence/openweathermap/api/model/weather/Wind.java @@ -20,7 +20,7 @@ * SOFTWARE. */ -package com.github.prominence.openweathermap.api.model; +package com.github.prominence.openweathermap.api.model.weather; import java.util.Objects; @@ -31,6 +31,7 @@ public class Wind { private double speed; private Double degrees; + private Double gust; private String unit; /** @@ -71,6 +72,14 @@ public class Wind { this.speed = speed; } + public Double getGust() { + return gust; + } + + public void setGust(double gust) { + this.gust = gust; + } + /** * Gets degrees. * @@ -130,7 +139,11 @@ public class Wind { @Override public String toString() { - return "Wind speed: " + speed + " " + unit + + String output = "Wind speed: " + speed + " " + unit + ", degrees: " + degrees; + if (gust != null) { + output += ", Gust: " + gust + " " + unit; + } + return output; } } diff --git a/src/main/java/com/github/prominence/openweathermap/api/request/forecast/free/FiveDayThreeHourStepForecastResponseMapper.java b/src/main/java/com/github/prominence/openweathermap/api/request/forecast/free/FiveDayThreeHourStepForecastResponseMapper.java index 9559ed9..7d9da11 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/request/forecast/free/FiveDayThreeHourStepForecastResponseMapper.java +++ b/src/main/java/com/github/prominence/openweathermap/api/request/forecast/free/FiveDayThreeHourStepForecastResponseMapper.java @@ -41,8 +41,8 @@ import java.util.List; import java.util.TimeZone; /** - * Official API response documentation: - * Parameters: + * Official API response documentation. + * Parameters(but the real response can differ): * --- cod Internal parameter * --- message Internal parameter * --- cnt A number of timestamps returned in the API response diff --git a/src/main/java/com/github/prominence/openweathermap/api/request/weather/CurrentWeatherResponseMapper.java b/src/main/java/com/github/prominence/openweathermap/api/request/weather/CurrentWeatherResponseMapper.java index 69e81b3..f85619e 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/request/weather/CurrentWeatherResponseMapper.java +++ b/src/main/java/com/github/prominence/openweathermap/api/request/weather/CurrentWeatherResponseMapper.java @@ -24,6 +24,7 @@ package com.github.prominence.openweathermap.api.request.weather; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import com.github.prominence.openweathermap.api.model.weather.*; import com.github.prominence.openweathermap.api.request.ResponseMapper; import com.github.prominence.openweathermap.api.enums.UnitSystem; import com.github.prominence.openweathermap.api.model.*; @@ -50,6 +51,7 @@ import java.util.TimeZone; * --- base Internal parameter * --- main * |- main.temp Temperature. UnitSystem Default: Kelvin, Metric: Celsius, Imperial: Fahrenheit. + * |- main.feels_like Temperature. This temperature parameter accounts for the human perception of weather. Unit Default: Kelvin, Metric: Celsius, Imperial: Fahrenheit. * |- main.pressure Atmospheric pressure (on the sea level, if there is no sea_level or grnd_level data), hPa * |- main.humidity Humidity, % * |- main.temp_min Minimum temperature at the moment. This is deviation from current temp that is possible for large cities and megalopolises geographically expanded (use these parameter optionally). UnitSystem Default: Kelvin, Metric: Celsius, Imperial: Fahrenheit. @@ -59,6 +61,7 @@ import java.util.TimeZone; * --- wind * |- wind.speed Wind speed. UnitSystem Default: meter/sec, Metric: meter/sec, Imperial: miles/hour. * |- wind.deg Wind direction, degrees (meteorological) + * |- wind.gust Wind gust. Unit Default: meter/sec, Metric: meter/sec, Imperial: miles/hour * --- clouds * |- clouds.all Cloudiness, % * --- rain @@ -75,6 +78,7 @@ import java.util.TimeZone; * |- sys.country Country code (GB, JP etc.) * |- sys.sunrise Sunrise time, unix, UTC * |- sys.sunset Sunset time, unix, UTC + * --- timezone Shift in seconds from UTC * --- id City ID * --- name City name * --- cod Internal parameter @@ -101,23 +105,21 @@ public class CurrentWeatherResponseMapper implements ResponseMapper { return weather; } - private Weather getSingle(JsonNode root) { - Weather weather; - - JsonNode weatherState = root.get("weather").get(0); - weather = new Weather(weatherState.get("main").asText(), weatherState.get("description").asText()); + private Weather getSingle(JsonNode rootNode) { + JsonNode weatherState = rootNode.get("weather").get(0); + Weather weather = new Weather(weatherState.get("main").asText(), weatherState.get("description").asText()); weather.setWeatherIconUrl("http://openweathermap.org/img/w/" + weatherState.get("icon").asText() + ".png"); - weather.setTemperature(parseTemperature(root)); - weather.setPressure(parsePressure(root)); - weather.setHumidity(parseHumidity(root)); - weather.setWind(parseWind(root)); - weather.setRain(parseRain(root)); - weather.setSnow(parseSnow(root)); - weather.setClouds(parseClouds(root)); - weather.setLocation(parseLocation(root)); + weather.setTemperature(parseTemperature(rootNode)); + weather.setPressure(parsePressure(rootNode)); + weather.setHumidity(parseHumidity(rootNode)); + weather.setWind(parseWind(rootNode)); + weather.setRain(parseRain(rootNode)); + weather.setSnow(parseSnow(rootNode)); + weather.setClouds(parseClouds(rootNode)); + weather.setLocation(parseLocation(rootNode)); - final JsonNode dtNode = root.get("dt"); + final JsonNode dtNode = rootNode.get("dt"); if (dtNode != null) { weather.setRequestedOn(LocalDateTime.ofInstant(Instant.ofEpochSecond(dtNode.asInt()), TimeZone.getDefault().toZoneId())); } @@ -140,12 +142,17 @@ public class CurrentWeatherResponseMapper implements ResponseMapper { return weatherList; } - private Temperature parseTemperature(JsonNode root) { + private Temperature parseTemperature(JsonNode rootNode) { Temperature temperature; - final JsonNode mainNode = root.get("main"); + final JsonNode mainNode = rootNode.get("main"); final double tempValue = mainNode.get("temp").asDouble(); temperature = new Temperature(tempValue, UnitSystem.getTemperatureUnit(unitSystem)); + + final JsonNode feelsLikeNode = mainNode.get("feels_like"); + if (feelsLikeNode != null) { + temperature.setFeelsLike(feelsLikeNode.asDouble()); + } final JsonNode tempMaxNode = mainNode.get("temp_max"); if (tempMaxNode != null) { temperature.setMaxTemperature(tempMaxNode.asDouble()); @@ -158,8 +165,8 @@ public class CurrentWeatherResponseMapper implements ResponseMapper { return temperature; } - private Pressure parsePressure(JsonNode root) { - final JsonNode mainNode = root.get("main"); + private Pressure parsePressure(JsonNode rootNode) { + final JsonNode mainNode = rootNode.get("main"); Pressure pressure = new Pressure(mainNode.get("pressure").asDouble()); final JsonNode seaLevelNode = mainNode.get("sea_level"); @@ -174,29 +181,34 @@ public class CurrentWeatherResponseMapper implements ResponseMapper { return pressure; } - private Humidity parseHumidity(JsonNode root) { - final JsonNode mainNode = root.get("main"); + private Humidity parseHumidity(JsonNode rootNode) { + final JsonNode mainNode = rootNode.get("main"); return new Humidity((byte) (mainNode.get("humidity").asInt())); } - private Wind parseWind(JsonNode root) { - final JsonNode windNode = root.get("wind"); + private Wind parseWind(JsonNode rootNode) { + final JsonNode windNode = rootNode.get("wind"); double speed = windNode.get("speed").asDouble(); Wind wind = new Wind(speed, UnitSystem.getWindUnit(unitSystem)); + final JsonNode degNode = windNode.get("deg"); if (degNode != null) { wind.setDegrees(degNode.asDouble()); } + final JsonNode gustNode = windNode.get("gust"); + if (gustNode != null) { + wind.setGust(gustNode.asDouble()); + } return wind; } - private Rain parseRain(JsonNode root) { + private Rain parseRain(JsonNode rootNode) { Rain rain = null; - final JsonNode rainNode = root.get("rain"); + final JsonNode rainNode = rootNode.get("rain"); if (rainNode != null) { rain = new Rain(); final JsonNode oneHourNode = rainNode.get("1h"); @@ -212,10 +224,10 @@ public class CurrentWeatherResponseMapper implements ResponseMapper { return rain; } - private Snow parseSnow(JsonNode root) { + private Snow parseSnow(JsonNode rootNode) { Snow snow = null; - final JsonNode snowNode = root.get("snow"); + final JsonNode snowNode = rootNode.get("snow"); if (snowNode != null) { snow = new Snow(); @@ -232,10 +244,10 @@ public class CurrentWeatherResponseMapper implements ResponseMapper { return snow; } - private Clouds parseClouds(JsonNode root) { + private Clouds parseClouds(JsonNode rootNode) { Clouds clouds = null; - final JsonNode cloudsNode = root.get("clouds"); + final JsonNode cloudsNode = rootNode.get("clouds"); final JsonNode allValueNode = cloudsNode.get("all"); if (allValueNode != null) { clouds = new Clouds((byte) allValueNode.asInt()); @@ -244,15 +256,15 @@ public class CurrentWeatherResponseMapper implements ResponseMapper { return clouds; } - private Location parseLocation(JsonNode root) { - Location location = new Location(root.get("id").asInt(), root.get("name").asText()); + private Location parseLocation(JsonNode rootNode) { + Location location = new Location(rootNode.get("id").asInt(), rootNode.get("name").asText()); - final JsonNode timezoneNode = root.get("timezone"); + final JsonNode timezoneNode = rootNode.get("timezone"); if (timezoneNode != null) { location.setZoneOffset(ZoneOffset.ofTotalSeconds(timezoneNode.asInt())); } - final JsonNode sysNode = root.get("sys"); + final JsonNode sysNode = rootNode.get("sys"); if (sysNode != null) { final JsonNode countryNode = sysNode.get("country"); if (countryNode != null) { @@ -269,21 +281,20 @@ public class CurrentWeatherResponseMapper implements ResponseMapper { } } - final JsonNode coordNode = root.get("coord"); + final JsonNode coordNode = rootNode.get("coord"); if (coordNode != null) { - JsonNode latitudeNode = coordNode.get("lat"); - if (latitudeNode == null) { - latitudeNode = coordNode.get("Lat"); // in multiple request - } - JsonNode longitudeNode = coordNode.get("lon"); - if (longitudeNode == null) { - longitudeNode = coordNode.get("Lon"); // in multiple request - } - if (latitudeNode != null && longitudeNode != null) { - location.setCoordinate(new Coordinate(latitudeNode.asDouble(), longitudeNode.asDouble())); - } + location.setCoordinate(parseCoordinate(coordNode)); } return location; } + + private Coordinate parseCoordinate(JsonNode rootNode) { + JsonNode latitudeNode = rootNode.get("lat"); + JsonNode longitudeNode = rootNode.get("lon"); + if (latitudeNode != null && longitudeNode != null) { + return new Coordinate(latitudeNode.asDouble(), longitudeNode.asDouble()); + } + return null; + } } diff --git a/src/main/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleResultCurrentWeatherAsyncRequestTerminator.java b/src/main/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleResultCurrentWeatherAsyncRequestTerminator.java index eb0e85a..e1c39ab 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleResultCurrentWeatherAsyncRequestTerminator.java +++ b/src/main/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleResultCurrentWeatherAsyncRequestTerminator.java @@ -22,7 +22,7 @@ package com.github.prominence.openweathermap.api.request.weather.multiple; -import com.github.prominence.openweathermap.api.model.Weather; +import com.github.prominence.openweathermap.api.model.weather.Weather; import com.github.prominence.openweathermap.api.request.weather.CurrentWeatherRequestTerminator; import java.util.List; diff --git a/src/main/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleResultCurrentWeatherAsyncRequestTerminatorImpl.java b/src/main/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleResultCurrentWeatherAsyncRequestTerminatorImpl.java index eb233d0..e071c0b 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleResultCurrentWeatherAsyncRequestTerminatorImpl.java +++ b/src/main/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleResultCurrentWeatherAsyncRequestTerminatorImpl.java @@ -25,7 +25,7 @@ package com.github.prominence.openweathermap.api.request.weather.multiple; import com.github.prominence.openweathermap.api.request.RequestUrlBuilder; import com.github.prominence.openweathermap.api.request.weather.CurrentWeatherResponseMapper; import com.github.prominence.openweathermap.api.enums.UnitSystem; -import com.github.prominence.openweathermap.api.model.Weather; +import com.github.prominence.openweathermap.api.model.weather.Weather; import com.github.prominence.openweathermap.api.utils.RequestUtils; import java.util.List; diff --git a/src/main/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleResultCurrentWeatherRequestTerminator.java b/src/main/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleResultCurrentWeatherRequestTerminator.java index cdd86df..77eaa8b 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleResultCurrentWeatherRequestTerminator.java +++ b/src/main/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleResultCurrentWeatherRequestTerminator.java @@ -22,7 +22,7 @@ package com.github.prominence.openweathermap.api.request.weather.multiple; -import com.github.prominence.openweathermap.api.model.Weather; +import com.github.prominence.openweathermap.api.model.weather.Weather; import com.github.prominence.openweathermap.api.request.weather.CurrentWeatherRequestTerminator; import java.util.List; diff --git a/src/main/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleResultCurrentWeatherRequestTerminatorImpl.java b/src/main/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleResultCurrentWeatherRequestTerminatorImpl.java index 7bf4648..852536e 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleResultCurrentWeatherRequestTerminatorImpl.java +++ b/src/main/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleResultCurrentWeatherRequestTerminatorImpl.java @@ -25,7 +25,7 @@ package com.github.prominence.openweathermap.api.request.weather.multiple; import com.github.prominence.openweathermap.api.request.RequestUrlBuilder; import com.github.prominence.openweathermap.api.request.weather.CurrentWeatherResponseMapper; import com.github.prominence.openweathermap.api.enums.UnitSystem; -import com.github.prominence.openweathermap.api.model.Weather; +import com.github.prominence.openweathermap.api.model.weather.Weather; import com.github.prominence.openweathermap.api.utils.RequestUtils; import java.util.List; diff --git a/src/main/java/com/github/prominence/openweathermap/api/request/weather/single/SingleResultCurrentWeatherAsyncRequestTerminator.java b/src/main/java/com/github/prominence/openweathermap/api/request/weather/single/SingleResultCurrentWeatherAsyncRequestTerminator.java index 2da33dc..fac39a9 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/request/weather/single/SingleResultCurrentWeatherAsyncRequestTerminator.java +++ b/src/main/java/com/github/prominence/openweathermap/api/request/weather/single/SingleResultCurrentWeatherAsyncRequestTerminator.java @@ -22,7 +22,7 @@ package com.github.prominence.openweathermap.api.request.weather.single; -import com.github.prominence.openweathermap.api.model.Weather; +import com.github.prominence.openweathermap.api.model.weather.Weather; import com.github.prominence.openweathermap.api.request.weather.CurrentWeatherRequestTerminator; import java.util.concurrent.CompletableFuture; diff --git a/src/main/java/com/github/prominence/openweathermap/api/request/weather/single/SingleResultCurrentWeatherAsyncRequestTerminatorImpl.java b/src/main/java/com/github/prominence/openweathermap/api/request/weather/single/SingleResultCurrentWeatherAsyncRequestTerminatorImpl.java index 1ff2cb1..de01dc4 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/request/weather/single/SingleResultCurrentWeatherAsyncRequestTerminatorImpl.java +++ b/src/main/java/com/github/prominence/openweathermap/api/request/weather/single/SingleResultCurrentWeatherAsyncRequestTerminatorImpl.java @@ -25,7 +25,7 @@ package com.github.prominence.openweathermap.api.request.weather.single; import com.github.prominence.openweathermap.api.request.RequestUrlBuilder; import com.github.prominence.openweathermap.api.request.weather.CurrentWeatherResponseMapper; import com.github.prominence.openweathermap.api.enums.UnitSystem; -import com.github.prominence.openweathermap.api.model.Weather; +import com.github.prominence.openweathermap.api.model.weather.Weather; import com.github.prominence.openweathermap.api.utils.RequestUtils; import java.util.concurrent.CompletableFuture; diff --git a/src/main/java/com/github/prominence/openweathermap/api/request/weather/single/SingleResultCurrentWeatherRequestTerminator.java b/src/main/java/com/github/prominence/openweathermap/api/request/weather/single/SingleResultCurrentWeatherRequestTerminator.java index 60e8f0d..4e738d4 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/request/weather/single/SingleResultCurrentWeatherRequestTerminator.java +++ b/src/main/java/com/github/prominence/openweathermap/api/request/weather/single/SingleResultCurrentWeatherRequestTerminator.java @@ -22,7 +22,7 @@ package com.github.prominence.openweathermap.api.request.weather.single; -import com.github.prominence.openweathermap.api.model.Weather; +import com.github.prominence.openweathermap.api.model.weather.Weather; import com.github.prominence.openweathermap.api.request.weather.CurrentWeatherRequestTerminator; public interface SingleResultCurrentWeatherRequestTerminator extends CurrentWeatherRequestTerminator { diff --git a/src/main/java/com/github/prominence/openweathermap/api/request/weather/single/SingleResultCurrentWeatherRequestTerminatorImpl.java b/src/main/java/com/github/prominence/openweathermap/api/request/weather/single/SingleResultCurrentWeatherRequestTerminatorImpl.java index 1ab380d..321cc92 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/request/weather/single/SingleResultCurrentWeatherRequestTerminatorImpl.java +++ b/src/main/java/com/github/prominence/openweathermap/api/request/weather/single/SingleResultCurrentWeatherRequestTerminatorImpl.java @@ -25,7 +25,7 @@ package com.github.prominence.openweathermap.api.request.weather.single; import com.github.prominence.openweathermap.api.request.RequestUrlBuilder; import com.github.prominence.openweathermap.api.request.weather.CurrentWeatherResponseMapper; import com.github.prominence.openweathermap.api.enums.UnitSystem; -import com.github.prominence.openweathermap.api.model.Weather; +import com.github.prominence.openweathermap.api.model.weather.Weather; import com.github.prominence.openweathermap.api.utils.RequestUtils; public class SingleResultCurrentWeatherRequestTerminatorImpl implements SingleResultCurrentWeatherRequestTerminator { diff --git a/src/test/java/com/github/prominence/openweathermap/api/model/CloudsUnitTest.java b/src/test/java/com/github/prominence/openweathermap/api/model/weather/CloudsUnitTest.java similarity index 64% rename from src/test/java/com/github/prominence/openweathermap/api/model/CloudsUnitTest.java rename to src/test/java/com/github/prominence/openweathermap/api/model/weather/CloudsUnitTest.java index ff0202d..c6cf66e 100644 --- a/src/test/java/com/github/prominence/openweathermap/api/model/CloudsUnitTest.java +++ b/src/test/java/com/github/prominence/openweathermap/api/model/weather/CloudsUnitTest.java @@ -1,5 +1,28 @@ -package com.github.prominence.openweathermap.api.model; +/* + * Copyright (c) 2021 Alexey Zinchenko + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.github.prominence.openweathermap.api.model.weather; + +import com.github.prominence.openweathermap.api.model.Clouds; import org.junit.Test; public class CloudsUnitTest { diff --git a/src/test/java/com/github/prominence/openweathermap/api/model/CoordinateRectangleUnitTest.java b/src/test/java/com/github/prominence/openweathermap/api/model/weather/CoordinateRectangleUnitTest.java similarity index 74% rename from src/test/java/com/github/prominence/openweathermap/api/model/CoordinateRectangleUnitTest.java rename to src/test/java/com/github/prominence/openweathermap/api/model/weather/CoordinateRectangleUnitTest.java index 6637ee3..c5312ca 100644 --- a/src/test/java/com/github/prominence/openweathermap/api/model/CoordinateRectangleUnitTest.java +++ b/src/test/java/com/github/prominence/openweathermap/api/model/weather/CoordinateRectangleUnitTest.java @@ -1,5 +1,28 @@ -package com.github.prominence.openweathermap.api.model; +/* + * Copyright (c) 2021 Alexey Zinchenko + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.github.prominence.openweathermap.api.model.weather; + +import com.github.prominence.openweathermap.api.model.CoordinateRectangle; import org.junit.Test; public class CoordinateRectangleUnitTest { diff --git a/src/test/java/com/github/prominence/openweathermap/api/model/CoordinateUnitTest.java b/src/test/java/com/github/prominence/openweathermap/api/model/weather/CoordinateUnitTest.java similarity index 76% rename from src/test/java/com/github/prominence/openweathermap/api/model/CoordinateUnitTest.java rename to src/test/java/com/github/prominence/openweathermap/api/model/weather/CoordinateUnitTest.java index 560f002..b9cb860 100644 --- a/src/test/java/com/github/prominence/openweathermap/api/model/CoordinateUnitTest.java +++ b/src/test/java/com/github/prominence/openweathermap/api/model/weather/CoordinateUnitTest.java @@ -1,5 +1,28 @@ -package com.github.prominence.openweathermap.api.model; +/* + * Copyright (c) 2021 Alexey Zinchenko + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.github.prominence.openweathermap.api.model.weather; + +import com.github.prominence.openweathermap.api.model.Coordinate; import org.junit.Test; public class CoordinateUnitTest { diff --git a/src/test/java/com/github/prominence/openweathermap/api/model/HumidityUnitTest.java b/src/test/java/com/github/prominence/openweathermap/api/model/weather/HumidityUnitTest.java similarity index 65% rename from src/test/java/com/github/prominence/openweathermap/api/model/HumidityUnitTest.java rename to src/test/java/com/github/prominence/openweathermap/api/model/weather/HumidityUnitTest.java index 3ea3130..be291f3 100644 --- a/src/test/java/com/github/prominence/openweathermap/api/model/HumidityUnitTest.java +++ b/src/test/java/com/github/prominence/openweathermap/api/model/weather/HumidityUnitTest.java @@ -1,5 +1,28 @@ -package com.github.prominence.openweathermap.api.model; +/* + * Copyright (c) 2021 Alexey Zinchenko + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.github.prominence.openweathermap.api.model.weather; + +import com.github.prominence.openweathermap.api.model.Humidity; import org.junit.Test; public class HumidityUnitTest { diff --git a/src/test/java/com/github/prominence/openweathermap/api/model/LocationUnitTest.java b/src/test/java/com/github/prominence/openweathermap/api/model/weather/LocationUnitTest.java similarity index 75% rename from src/test/java/com/github/prominence/openweathermap/api/model/LocationUnitTest.java rename to src/test/java/com/github/prominence/openweathermap/api/model/weather/LocationUnitTest.java index 2f54a36..0f2aac9 100644 --- a/src/test/java/com/github/prominence/openweathermap/api/model/LocationUnitTest.java +++ b/src/test/java/com/github/prominence/openweathermap/api/model/weather/LocationUnitTest.java @@ -1,5 +1,29 @@ -package com.github.prominence.openweathermap.api.model; +/* + * Copyright (c) 2021 Alexey Zinchenko + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.github.prominence.openweathermap.api.model.weather; + +import com.github.prominence.openweathermap.api.model.Coordinate; +import com.github.prominence.openweathermap.api.model.Location; import org.junit.Test; import java.time.LocalDateTime; diff --git a/src/test/java/com/github/prominence/openweathermap/api/model/PressureUnitTest.java b/src/test/java/com/github/prominence/openweathermap/api/model/weather/PressureUnitTest.java similarity index 70% rename from src/test/java/com/github/prominence/openweathermap/api/model/PressureUnitTest.java rename to src/test/java/com/github/prominence/openweathermap/api/model/weather/PressureUnitTest.java index 312e3cc..d95a581 100644 --- a/src/test/java/com/github/prominence/openweathermap/api/model/PressureUnitTest.java +++ b/src/test/java/com/github/prominence/openweathermap/api/model/weather/PressureUnitTest.java @@ -1,5 +1,28 @@ -package com.github.prominence.openweathermap.api.model; +/* + * Copyright (c) 2021 Alexey Zinchenko + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.github.prominence.openweathermap.api.model.weather; + +import com.github.prominence.openweathermap.api.model.Pressure; import org.junit.Test; public class PressureUnitTest { diff --git a/src/test/java/com/github/prominence/openweathermap/api/model/RainUnitTest.java b/src/test/java/com/github/prominence/openweathermap/api/model/weather/RainUnitTest.java similarity index 66% rename from src/test/java/com/github/prominence/openweathermap/api/model/RainUnitTest.java rename to src/test/java/com/github/prominence/openweathermap/api/model/weather/RainUnitTest.java index e0fa944..5dfd37f 100644 --- a/src/test/java/com/github/prominence/openweathermap/api/model/RainUnitTest.java +++ b/src/test/java/com/github/prominence/openweathermap/api/model/weather/RainUnitTest.java @@ -1,5 +1,28 @@ -package com.github.prominence.openweathermap.api.model; +/* + * Copyright (c) 2021 Alexey Zinchenko + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.github.prominence.openweathermap.api.model.weather; + +import com.github.prominence.openweathermap.api.model.weather.Rain; import org.junit.Test; public class RainUnitTest { diff --git a/src/test/java/com/github/prominence/openweathermap/api/model/SnowUnitTest.java b/src/test/java/com/github/prominence/openweathermap/api/model/weather/SnowUnitTest.java similarity index 66% rename from src/test/java/com/github/prominence/openweathermap/api/model/SnowUnitTest.java rename to src/test/java/com/github/prominence/openweathermap/api/model/weather/SnowUnitTest.java index a012e08..3364b24 100644 --- a/src/test/java/com/github/prominence/openweathermap/api/model/SnowUnitTest.java +++ b/src/test/java/com/github/prominence/openweathermap/api/model/weather/SnowUnitTest.java @@ -1,5 +1,28 @@ -package com.github.prominence.openweathermap.api.model; +/* + * Copyright (c) 2021 Alexey Zinchenko + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.github.prominence.openweathermap.api.model.weather; + +import com.github.prominence.openweathermap.api.model.weather.Snow; import org.junit.Test; public class SnowUnitTest { diff --git a/src/test/java/com/github/prominence/openweathermap/api/model/TemperatureUnitTest.java b/src/test/java/com/github/prominence/openweathermap/api/model/weather/TemperatureUnitTest.java similarity index 71% rename from src/test/java/com/github/prominence/openweathermap/api/model/TemperatureUnitTest.java rename to src/test/java/com/github/prominence/openweathermap/api/model/weather/TemperatureUnitTest.java index 198412c..c9396b4 100644 --- a/src/test/java/com/github/prominence/openweathermap/api/model/TemperatureUnitTest.java +++ b/src/test/java/com/github/prominence/openweathermap/api/model/weather/TemperatureUnitTest.java @@ -1,4 +1,26 @@ -package com.github.prominence.openweathermap.api.model; +/* + * Copyright (c) 2021 Alexey Zinchenko + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.prominence.openweathermap.api.model.weather; import org.junit.Test; diff --git a/src/test/java/com/github/prominence/openweathermap/api/model/WeatherUnitTest.java b/src/test/java/com/github/prominence/openweathermap/api/model/weather/WeatherUnitTest.java similarity index 83% rename from src/test/java/com/github/prominence/openweathermap/api/model/WeatherUnitTest.java rename to src/test/java/com/github/prominence/openweathermap/api/model/weather/WeatherUnitTest.java index 4a5ea73..1932956 100644 --- a/src/test/java/com/github/prominence/openweathermap/api/model/WeatherUnitTest.java +++ b/src/test/java/com/github/prominence/openweathermap/api/model/weather/WeatherUnitTest.java @@ -1,5 +1,33 @@ -package com.github.prominence.openweathermap.api.model; +/* + * Copyright (c) 2021 Alexey Zinchenko + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.github.prominence.openweathermap.api.model.weather; + +import com.github.prominence.openweathermap.api.model.Clouds; +import com.github.prominence.openweathermap.api.model.Humidity; +import com.github.prominence.openweathermap.api.model.Location; +import com.github.prominence.openweathermap.api.model.Pressure; +import com.github.prominence.openweathermap.api.model.weather.*; +import com.github.prominence.openweathermap.api.model.weather.Temperature; import org.junit.Test; import java.time.LocalDateTime; diff --git a/src/test/java/com/github/prominence/openweathermap/api/model/WindUnitTest.java b/src/test/java/com/github/prominence/openweathermap/api/model/weather/WindUnitTest.java similarity index 74% rename from src/test/java/com/github/prominence/openweathermap/api/model/WindUnitTest.java rename to src/test/java/com/github/prominence/openweathermap/api/model/weather/WindUnitTest.java index bf46150..0d772a7 100644 --- a/src/test/java/com/github/prominence/openweathermap/api/model/WindUnitTest.java +++ b/src/test/java/com/github/prominence/openweathermap/api/model/weather/WindUnitTest.java @@ -1,5 +1,28 @@ -package com.github.prominence.openweathermap.api.model; +/* + * Copyright (c) 2021 Alexey Zinchenko + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.github.prominence.openweathermap.api.model.weather; + +import com.github.prominence.openweathermap.api.model.forecast.Wind; import org.junit.Test; public class WindUnitTest { diff --git a/src/test/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleResultCurrentWeatherIntegrationTest.java b/src/test/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleResultCurrentWeatherIntegrationTest.java index 144fb80..68121a4 100644 --- a/src/test/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleResultCurrentWeatherIntegrationTest.java +++ b/src/test/java/com/github/prominence/openweathermap/api/request/weather/multiple/MultipleResultCurrentWeatherIntegrationTest.java @@ -29,7 +29,7 @@ import com.github.prominence.openweathermap.api.exception.InvalidAuthTokenExcept import com.github.prominence.openweathermap.api.exception.NoDataFoundException; import com.github.prominence.openweathermap.api.model.Coordinate; import com.github.prominence.openweathermap.api.model.CoordinateRectangle; -import com.github.prominence.openweathermap.api.model.Weather; +import com.github.prominence.openweathermap.api.model.weather.Weather; import com.github.prominence.openweathermap.api.OpenWeatherMapClient; import org.junit.Test; diff --git a/src/test/java/com/github/prominence/openweathermap/api/request/weather/single/SingleResultCurrentWeatherIntegrationTest.java b/src/test/java/com/github/prominence/openweathermap/api/request/weather/single/SingleResultCurrentWeatherIntegrationTest.java index c6aa723..0b24acb 100644 --- a/src/test/java/com/github/prominence/openweathermap/api/request/weather/single/SingleResultCurrentWeatherIntegrationTest.java +++ b/src/test/java/com/github/prominence/openweathermap/api/request/weather/single/SingleResultCurrentWeatherIntegrationTest.java @@ -28,7 +28,7 @@ import com.github.prominence.openweathermap.api.enums.UnitSystem; import com.github.prominence.openweathermap.api.exception.InvalidAuthTokenException; import com.github.prominence.openweathermap.api.exception.NoDataFoundException; import com.github.prominence.openweathermap.api.model.Coordinate; -import com.github.prominence.openweathermap.api.model.Weather; +import com.github.prominence.openweathermap.api.model.weather.Weather; import com.github.prominence.openweathermap.api.OpenWeatherMapClient; import org.junit.Test;