mirror of
https://github.com/Prominence/openweathermap-java-api.git
synced 2026-07-04 03:36:44 +03:00
A bunch of global refactoring and improvements.
Improved coverage reports generation. Updated docs. Moved logic out of large mappers into small deserializers. Implemented Geocoding API functionality. Implemented Hourly forecast functionality. Implemented Daily forecast functionality. Renamed Coordinate class. Reimplemented Current Weather API: removed multiple locations requests. Marked officially deprecated methods as @Deprecated. Updated tests.
This commit is contained in:
+1254
File diff suppressed because it is too large
Load Diff
+199
@@ -0,0 +1,199 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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.mapper;
|
||||
|
||||
import com.github.prominence.openweathermap.api.model.Coordinates;
|
||||
import com.github.prominence.openweathermap.api.model.geocoding.GeocodingRecord;
|
||||
import com.github.prominence.openweathermap.api.model.geocoding.ZipCodeGeocodingRecord;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class GeocodingResponseMapperTest {
|
||||
|
||||
@Test
|
||||
public void reverseGeocodingResponseMappingTest() {
|
||||
String jsonResponse = """
|
||||
[
|
||||
{
|
||||
"name": "City of London",
|
||||
"local_names": {
|
||||
"ar": "مدينة لندن",
|
||||
"ascii": "City of London",
|
||||
"bg": "Сити",
|
||||
"ca": "La City",
|
||||
"de": "London City",
|
||||
"el": "Σίτι του Λονδίνου",
|
||||
"en": "City of London",
|
||||
"fa": "سیتی لندن",
|
||||
"feature_name": "City of London",
|
||||
"fi": "Lontoon City",
|
||||
"fr": "Cité de Londres",
|
||||
"gl": "Cidade de Londres",
|
||||
"he": "הסיטי של לונדון",
|
||||
"hi": "सिटी ऑफ़ लंदन",
|
||||
"id": "Kota London",
|
||||
"it": "Londra",
|
||||
"ja": "シティ・オブ・ロンドン",
|
||||
"la": "Civitas Londinium",
|
||||
"lt": "Londono Sitis",
|
||||
"pt": "Cidade de Londres",
|
||||
"ru": "Сити",
|
||||
"sr": "Сити",
|
||||
"th": "นครลอนดอน",
|
||||
"tr": "Londra Şehri",
|
||||
"vi": "Thành phố Luân Đôn",
|
||||
"zu": "Idolobha weLondon"
|
||||
},
|
||||
"lat": 51.5128,
|
||||
"lon": -0.0918,
|
||||
"country": "GB"
|
||||
},
|
||||
{
|
||||
"name": "London",
|
||||
"local_names": {
|
||||
"af": "Londen",
|
||||
"ar": "لندن",
|
||||
"ascii": "London",
|
||||
"az": "London",
|
||||
"bg": "Лондон",
|
||||
"ca": "Londres",
|
||||
"da": "London",
|
||||
"de": "London",
|
||||
"el": "Λονδίνο",
|
||||
"en": "London",
|
||||
"eu": "Londres",
|
||||
"fa": "لندن",
|
||||
"feature_name": "London",
|
||||
"fi": "Lontoo",
|
||||
"fr": "Londres",
|
||||
"gl": "Londres",
|
||||
"he": "לונדון",
|
||||
"hi": "लंदन",
|
||||
"hr": "London",
|
||||
"hu": "London",
|
||||
"id": "London",
|
||||
"it": "Londra",
|
||||
"ja": "ロンドン",
|
||||
"la": "Londinium",
|
||||
"lt": "Londonas",
|
||||
"mk": "Лондон",
|
||||
"nl": "Londen",
|
||||
"no": "London",
|
||||
"pl": "Londyn",
|
||||
"pt": "Londres",
|
||||
"ro": "Londra",
|
||||
"ru": "Лондон",
|
||||
"sk": "Londýn",
|
||||
"sl": "London",
|
||||
"sr": "Лондон",
|
||||
"th": "ลอนดอน",
|
||||
"tr": "Londra",
|
||||
"vi": "Luân Đôn",
|
||||
"zu": "ILondon"
|
||||
},
|
||||
"lat": 51.5085,
|
||||
"lon": -0.1257,
|
||||
"country": "GB"
|
||||
},
|
||||
{
|
||||
"name": "Islington",
|
||||
"local_names": {
|
||||
"ascii": "Islington",
|
||||
"az": "İslinqton",
|
||||
"fa": "ایزلینتن",
|
||||
"feature_name": "Islington",
|
||||
"fr": "District londonien d'Islington",
|
||||
"he": "איזלינגטון",
|
||||
"ja": "イズリントン",
|
||||
"ru": "Ислингтон"
|
||||
},
|
||||
"lat": 51.5362,
|
||||
"lon": -0.103,
|
||||
"country": "GB"
|
||||
},
|
||||
{
|
||||
"name": "Lewisham",
|
||||
"local_names": {
|
||||
"ascii": "Lewisham",
|
||||
"de": "London Borough of Lewisham",
|
||||
"en": "Lewisham",
|
||||
"feature_name": "Lewisham",
|
||||
"fi": "Lewisham",
|
||||
"fr": "Lewisham",
|
||||
"hu": "Lewisham kerület",
|
||||
"nl": "Lewisham",
|
||||
"no": "Lewisham",
|
||||
"ro": "Lewisham"
|
||||
},
|
||||
"lat": 51.4535,
|
||||
"lon": -0.018,
|
||||
"country": "GB"
|
||||
},
|
||||
{
|
||||
"name": "Islington",
|
||||
"local_names": {
|
||||
"ascii": "Islington",
|
||||
"de": "London Borough of Islington",
|
||||
"en": "Islington",
|
||||
"feature_name": "Islington",
|
||||
"fr": "Islington",
|
||||
"nl": "Islington",
|
||||
"no": "Islington",
|
||||
"ro": "Islington"
|
||||
},
|
||||
"lat": 51.547,
|
||||
"lon": -0.1094,
|
||||
"country": "GB"
|
||||
}
|
||||
]
|
||||
""";
|
||||
|
||||
List<GeocodingRecord> geocodingRecords = new GeocodingResponseMapper().mapGeocodingResponse(jsonResponse);
|
||||
|
||||
assertNotNull(geocodingRecords);
|
||||
assertEquals(5, geocodingRecords.size());
|
||||
}
|
||||
|
||||
public void zipGeocodingInfoResponseMappingTest() {
|
||||
String jsonResponse = """
|
||||
{
|
||||
"zip": "90210",
|
||||
"name": "Beverly Hills",
|
||||
"lat": 34.0901,
|
||||
"lon": -118.4065,
|
||||
"country": "US"
|
||||
}
|
||||
""";
|
||||
|
||||
ZipCodeGeocodingRecord zipCodeGeocodingRecord = new GeocodingResponseMapper().mapZipCodeGeocodingResponse(jsonResponse);
|
||||
|
||||
assertNotNull(zipCodeGeocodingRecord);
|
||||
assertEquals("90210", zipCodeGeocodingRecord.getZip());
|
||||
assertEquals("Beverly Hills", zipCodeGeocodingRecord.getName());
|
||||
assertEquals("US", zipCodeGeocodingRecord.getCountryCode());
|
||||
assertEquals(Coordinates.of(34.0901, -118.4065), zipCodeGeocodingRecord.getCoordinates());
|
||||
}
|
||||
}
|
||||
+158
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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.mapper;
|
||||
|
||||
import com.github.prominence.openweathermap.api.enums.UnitSystem;
|
||||
import com.github.prominence.openweathermap.api.model.*;
|
||||
import com.github.prominence.openweathermap.api.model.forecast.hourly.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class HourlyForecastResponseMapperTest {
|
||||
|
||||
@Test
|
||||
void forecastMappingTestWithOfficialExample() {
|
||||
final String jsonResponse = """
|
||||
{
|
||||
"cod": "200",
|
||||
"message": 0.0179,
|
||||
"cnt": 96,
|
||||
"list": [
|
||||
{
|
||||
"dt": 1596632400,
|
||||
"main": {
|
||||
"temp": 289.16,
|
||||
"feels_like": 288.41,
|
||||
"temp_min": 289.16,
|
||||
"temp_max": 289.16,
|
||||
"pressure": 1013,
|
||||
"sea_level": 1013,
|
||||
"grnd_level": 1010,
|
||||
"humidity": 78,
|
||||
"temp_kf": 0
|
||||
},
|
||||
"weather": [
|
||||
{
|
||||
"id": 804,
|
||||
"main": "Clouds",
|
||||
"description": "overcast clouds",
|
||||
"icon": "04n"
|
||||
}
|
||||
],
|
||||
"clouds": {
|
||||
"all": 100
|
||||
},
|
||||
"wind": {
|
||||
"speed": 2.03,
|
||||
"deg": 252,
|
||||
"gust": 5.46
|
||||
},
|
||||
"rain": {
|
||||
"1h": 23.3
|
||||
},
|
||||
"snow": {
|
||||
"1h": 27.945
|
||||
},
|
||||
"visibility": 10000,
|
||||
"pop": 0.04,
|
||||
"sys": {
|
||||
"pod": "n"
|
||||
},
|
||||
"dt_txt": "2020-08-05 13:00:00"
|
||||
}
|
||||
],
|
||||
"city": {
|
||||
"id": 2643743,
|
||||
"name": "London",
|
||||
"coord": {
|
||||
"lat": 51.5085,
|
||||
"lon": -0.1258
|
||||
},
|
||||
"country": "GB",
|
||||
"timezone": 0,
|
||||
"sunrise": 1568958164,
|
||||
"sunset": 1569002733
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
final HourlyForecast hourlyForecast = new HourlyForecastResponseMapper(UnitSystem.METRIC).mapToForecast(jsonResponse);
|
||||
assertNotNull(hourlyForecast);
|
||||
|
||||
final Location location = hourlyForecast.getLocation();
|
||||
assertEquals(2643743, location.getId());
|
||||
assertEquals("London", location.getName());
|
||||
assertEquals(Coordinates.of(51.5085, -0.1258), location.getCoordinate());
|
||||
assertEquals("GB", location.getCountryCode());
|
||||
assertEquals(ZoneOffset.ofTotalSeconds(0), location.getZoneOffset());
|
||||
assertEquals(LocalDateTime.ofInstant(Instant.ofEpochSecond(1568958164), TimeZone.getDefault().toZoneId()), location.getSunriseTime());
|
||||
assertEquals(LocalDateTime.ofInstant(Instant.ofEpochSecond(1569002733), TimeZone.getDefault().toZoneId()), location.getSunsetTime());
|
||||
|
||||
final WeatherForecast weatherForecast = hourlyForecast.getWeatherForecasts().get(0);
|
||||
assertEquals(LocalDateTime.ofInstant(Instant.ofEpochSecond(1596632400), TimeZone.getDefault().toZoneId()), weatherForecast.getForecastTime());
|
||||
assertEquals("2020-08-05 13:00:00", weatherForecast.getForecastTimeISO());
|
||||
assertEquals(DayTime.NIGHT, weatherForecast.getDayTime());
|
||||
assertEquals(10000, weatherForecast.getAverageVisibilityInMetres());
|
||||
assertEquals(0.04, weatherForecast.getProbabilityOfPrecipitation());
|
||||
|
||||
final Temperature temperature = weatherForecast.getTemperature();
|
||||
assertEquals(289.16, temperature.getValue());
|
||||
assertEquals(288.41, temperature.getFeelsLike());
|
||||
assertEquals(289.16, temperature.getMinTemperature());
|
||||
assertEquals(289.16, temperature.getMaxTemperature());
|
||||
|
||||
final AtmosphericPressure pressure = weatherForecast.getAtmosphericPressure();
|
||||
assertEquals(1013, pressure.getValue());
|
||||
assertEquals(1013, pressure.getSeaLevelValue());
|
||||
assertEquals(1010, pressure.getGroundLevelValue());
|
||||
|
||||
final Humidity humidity = weatherForecast.getHumidity();
|
||||
assertEquals(78, humidity.getValue());
|
||||
|
||||
final WeatherState weatherState = weatherForecast.getWeatherStates().get(0);
|
||||
assertEquals(804, weatherState.getId());
|
||||
assertEquals("Clouds", weatherState.getName());
|
||||
assertEquals("overcast clouds", weatherState.getDescription());
|
||||
assertEquals("04n", weatherState.getIconId());
|
||||
|
||||
final Clouds clouds = weatherForecast.getClouds();
|
||||
assertEquals(100, clouds.getValue());
|
||||
|
||||
final Wind wind = weatherForecast.getWind();
|
||||
assertEquals(2.03, wind.getSpeed());
|
||||
assertEquals(252, wind.getDegrees());
|
||||
assertEquals(5.46, wind.getGust());
|
||||
|
||||
final Rain rain = weatherForecast.getRain();
|
||||
assertEquals(23.3, rain.getOneHourLevel());
|
||||
|
||||
final Snow snow = weatherForecast.getSnow();
|
||||
assertEquals(27.945, snow.getOneHourLevel());
|
||||
}
|
||||
}
|
||||
+223
@@ -0,0 +1,223 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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.mapper;
|
||||
|
||||
import com.github.prominence.openweathermap.api.enums.UnitSystem;
|
||||
import com.github.prominence.openweathermap.api.model.onecall.current.CurrentWeatherData;
|
||||
import com.github.prominence.openweathermap.api.model.onecall.historical.HistoricalWeatherData;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class OneCallWeatherResponseMapperTest {
|
||||
|
||||
@Test
|
||||
void mapToCurrent() {
|
||||
final String jsonResponse = """
|
||||
{
|
||||
"lat": 33.44,
|
||||
"lon": -94.04,
|
||||
"timezone": "America/Chicago",
|
||||
"timezone_offset": -21600,
|
||||
"current": {
|
||||
"dt": 1618317040,
|
||||
"sunrise": 1618282134,
|
||||
"sunset": 1618333901,
|
||||
"temp": 284.07,
|
||||
"feels_like": 282.84,
|
||||
"pressure": 1019,
|
||||
"humidity": 62,
|
||||
"dew_point": 277.08,
|
||||
"uvi": 0.89,
|
||||
"clouds": 0,
|
||||
"visibility": 10000,
|
||||
"wind_speed": 6,
|
||||
"wind_deg": 300,
|
||||
"weather": [
|
||||
{
|
||||
"id": 500,
|
||||
"main": "Rain",
|
||||
"description": "light rain",
|
||||
"icon": "10d"
|
||||
}
|
||||
],
|
||||
"rain": {
|
||||
"1h": 0.21
|
||||
}
|
||||
},
|
||||
"minutely": [
|
||||
{
|
||||
"dt": 1618317060,
|
||||
"precipitation": 0.205
|
||||
}
|
||||
],
|
||||
"hourly": [
|
||||
{
|
||||
"dt": 1618315200,
|
||||
"temp": 282.58,
|
||||
"feels_like": 280.4,
|
||||
"pressure": 1019,
|
||||
"humidity": 68,
|
||||
"dew_point": 276.98,
|
||||
"uvi": 1.4,
|
||||
"clouds": 19,
|
||||
"visibility": 306,
|
||||
"wind_speed": 4.12,
|
||||
"wind_deg": 296,
|
||||
"wind_gust": 7.33,
|
||||
"weather": [
|
||||
{
|
||||
"id": 801,
|
||||
"main": "Clouds",
|
||||
"description": "few clouds",
|
||||
"icon": "02d"
|
||||
}
|
||||
],
|
||||
"pop": 0
|
||||
}
|
||||
],
|
||||
"daily": [
|
||||
{
|
||||
"dt": 1618308000,
|
||||
"sunrise": 1618282134,
|
||||
"sunset": 1618333901,
|
||||
"moonrise": 1618284960,
|
||||
"moonset": 1618339740,
|
||||
"moon_phase": 0.04,
|
||||
"temp": {
|
||||
"day": 279.79,
|
||||
"min": 275.09,
|
||||
"max": 284.07,
|
||||
"night": 275.09,
|
||||
"eve": 279.21,
|
||||
"morn": 278.49
|
||||
},
|
||||
"feels_like": {
|
||||
"day": 277.59,
|
||||
"night": 276.27,
|
||||
"eve": 276.49,
|
||||
"morn": 276.27
|
||||
},
|
||||
"pressure": 1020,
|
||||
"humidity": 81,
|
||||
"dew_point": 276.77,
|
||||
"wind_speed": 3.06,
|
||||
"wind_deg": 294,
|
||||
"weather": [
|
||||
{
|
||||
"id": 500,
|
||||
"main": "Rain",
|
||||
"description": "light rain",
|
||||
"icon": "10d"
|
||||
}
|
||||
],
|
||||
"clouds": 56,
|
||||
"pop": 0.2,
|
||||
"rain": 0.62,
|
||||
"uvi": 1.93
|
||||
}
|
||||
],
|
||||
"alerts": [
|
||||
{
|
||||
"sender_name": "NWS Tulsa",
|
||||
"event": "Heat Advisory",
|
||||
"start": 1597341600,
|
||||
"end": 1597366800,
|
||||
"description": "...HEAT ADVISORY REMAINS IN EFFECT FROM 1 PM THIS AFTERNOON TO\\n8 PM CDT THIS EVENING...\\n* WHAT...Heat index values of 105 to 109 degrees expected.\\n* WHERE...Creek, Okfuskee, Okmulgee, McIntosh, Pittsburg,\\nLatimer, Pushmataha, and Choctaw Counties.\\n* WHEN...From 1 PM to 8 PM CDT Thursday.\\n* IMPACTS...The combination of hot temperatures and high\\nhumidity will combine to create a dangerous situation in which\\nheat illnesses are possible.",
|
||||
"tags": [
|
||||
"Extreme temperature value"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
""";
|
||||
|
||||
final CurrentWeatherData weatherData = new OneCallWeatherResponseMapper(UnitSystem.METRIC).mapToCurrent(jsonResponse);
|
||||
|
||||
assertNotNull(weatherData);
|
||||
assertNotEquals(0, weatherData.getDailyList().size());
|
||||
assertEquals(1, weatherData.getAlerts().get(0).getTags().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
void mapToHistorical() {
|
||||
final String jsonResponse = """
|
||||
{
|
||||
"lat": 60.99,
|
||||
"lon": 30.9,
|
||||
"timezone": "Europe/Moscow",
|
||||
"timezone_offset": 10800,
|
||||
"current": {
|
||||
"dt": 1586468027,
|
||||
"sunrise": 1586487424,
|
||||
"sunset": 1586538297,
|
||||
"temp": 274.31,
|
||||
"feels_like": 269.79,
|
||||
"pressure": 1006,
|
||||
"humidity": 72,
|
||||
"dew_point": 270.21,
|
||||
"clouds": 0,
|
||||
"visibility": 10000,
|
||||
"wind_speed": 3,
|
||||
"wind_deg": 260,
|
||||
"weather": [
|
||||
{
|
||||
"id": 800,
|
||||
"main": "Clear",
|
||||
"description": "clear sky",
|
||||
"icon": "01n"
|
||||
}
|
||||
]
|
||||
},
|
||||
"hourly": [
|
||||
{
|
||||
"dt": 1586390400,
|
||||
"temp": 278.41,
|
||||
"feels_like": 269.43,
|
||||
"pressure": 1006,
|
||||
"humidity": 65,
|
||||
"dew_point": 272.46,
|
||||
"clouds": 0,
|
||||
"wind_speed": 9.83,
|
||||
"wind_deg": 60,
|
||||
"wind_gust": 15.65,
|
||||
"weather": [
|
||||
{
|
||||
"id": 800,
|
||||
"main": "Clear",
|
||||
"description": "clear sky",
|
||||
"icon": "01n"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
""";
|
||||
|
||||
final HistoricalWeatherData weatherData = new OneCallWeatherResponseMapper(UnitSystem.METRIC).mapToHistorical(jsonResponse);
|
||||
|
||||
assertNotNull(weatherData);
|
||||
assertNotNull(weatherData.getHistoricalWeather());
|
||||
assertNotEquals(0, weatherData.getHourlyList().size());
|
||||
}
|
||||
}
|
||||
+35
-35
@@ -26,116 +26,116 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class CoordinateRectangleUnitTest {
|
||||
public class CoordinatesRectangleUnitTest {
|
||||
@Test
|
||||
public void whenCreateObjectWithValidArgs_thenObjectIsCreated() {
|
||||
CoordinateRectangle.withValues(44.5, 22.4, 54.4, 22.2);
|
||||
CoordinatesRectangle.withValues(44.5, 22.4, 54.4, 22.2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenCreateObjectWithLatitudeBottomBelowMinus90_thenThrowAnException() {
|
||||
assertThrows(IllegalArgumentException.class, () -> CoordinateRectangle.withValues(44.5, -91.2, 54.4, 22.2));
|
||||
assertThrows(IllegalArgumentException.class, () -> CoordinatesRectangle.withValues(44.5, -91.2, 54.4, 22.2));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenCreateObjectWithLatitudeBottomAbove90_thenThrowAnException() {
|
||||
assertThrows(IllegalArgumentException.class, () -> CoordinateRectangle.withValues(44.5, 91.2, 54.4, 22.2));
|
||||
assertThrows(IllegalArgumentException.class, () -> CoordinatesRectangle.withValues(44.5, 91.2, 54.4, 22.2));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenCreateObjectWithLatitudeTopBelowMinus90_thenThrowAnException() {
|
||||
assertThrows(IllegalArgumentException.class, () -> CoordinateRectangle.withValues(44.5, 22.4, 54.4, -92.3));
|
||||
assertThrows(IllegalArgumentException.class, () -> CoordinatesRectangle.withValues(44.5, 22.4, 54.4, -92.3));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenCreateObjectWithLatitudeTopAbove90_thenThrowAnException() {
|
||||
assertThrows(IllegalArgumentException.class, () -> CoordinateRectangle.withValues(44.5, 22.5, 54.4, 94.887));
|
||||
assertThrows(IllegalArgumentException.class, () -> CoordinatesRectangle.withValues(44.5, 22.5, 54.4, 94.887));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenCreateObjectWithLongitudeLeftBelowMinus180_thenThrowAnException() {
|
||||
assertThrows(IllegalArgumentException.class, () -> CoordinateRectangle.withValues(-944.5, 22.4, 54.4, 22.2));
|
||||
assertThrows(IllegalArgumentException.class, () -> CoordinatesRectangle.withValues(-944.5, 22.4, 54.4, 22.2));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenCreateObjectWithLongitudeLeftAbove180_thenThrowAnException() {
|
||||
assertThrows(IllegalArgumentException.class, () -> CoordinateRectangle.withValues(544.5, 22.4, 54.4, 22.2));
|
||||
assertThrows(IllegalArgumentException.class, () -> CoordinatesRectangle.withValues(544.5, 22.4, 54.4, 22.2));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenCreateObjectWithLongitudeRightBelowMinus180_thenThrowAnException() {
|
||||
assertThrows(IllegalArgumentException.class, () -> CoordinateRectangle.withValues(44.5, 22.4, -254.4, 22.2));
|
||||
assertThrows(IllegalArgumentException.class, () -> CoordinatesRectangle.withValues(44.5, 22.4, -254.4, 22.2));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenCreateObjectWithLongitudeRightAbove180_thenThrowAnException() {
|
||||
assertThrows(IllegalArgumentException.class, () -> CoordinateRectangle.withValues(44.5, 22.4, 354.4, 22.2));
|
||||
assertThrows(IllegalArgumentException.class, () -> CoordinatesRectangle.withValues(44.5, 22.4, 354.4, 22.2));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenCreateObjectUsingBuilderWithInvalidLatitudeBottom_thenFail() {
|
||||
assertThrows(IllegalArgumentException.class, () -> new CoordinateRectangle.Builder()
|
||||
assertThrows(IllegalArgumentException.class, () -> new CoordinatesRectangle.Builder()
|
||||
.setLatitudeBottom(-1000));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenCreateObjectUsingBuilderWithInvalidLatitudeBottom2_thenFail() {
|
||||
assertThrows(IllegalArgumentException.class, () -> new CoordinateRectangle.Builder()
|
||||
assertThrows(IllegalArgumentException.class, () -> new CoordinatesRectangle.Builder()
|
||||
.setLatitudeBottom(1000));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenCreateObjectUsingBuilderWithInvalidLatitudeTop_thenFail() {
|
||||
assertThrows(IllegalArgumentException.class, () -> new CoordinateRectangle.Builder()
|
||||
assertThrows(IllegalArgumentException.class, () -> new CoordinatesRectangle.Builder()
|
||||
.setLatitudeTop(-1000));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenCreateObjectUsingBuilderWithInvalidLatitudeTop2_thenFail() {
|
||||
assertThrows(IllegalArgumentException.class, () -> new CoordinateRectangle.Builder()
|
||||
assertThrows(IllegalArgumentException.class, () -> new CoordinatesRectangle.Builder()
|
||||
.setLatitudeTop(1000));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenCreateObjectUsingBuilderWithInvalidLongitudeLeft_thenFail() {
|
||||
assertThrows(IllegalArgumentException.class, () -> new CoordinateRectangle.Builder()
|
||||
assertThrows(IllegalArgumentException.class, () -> new CoordinatesRectangle.Builder()
|
||||
.setLongitudeLeft(-1000));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenCreateObjectUsingBuilderWithInvalidLongitudeLeft2_thenFail() {
|
||||
assertThrows(IllegalArgumentException.class, () -> new CoordinateRectangle.Builder()
|
||||
assertThrows(IllegalArgumentException.class, () -> new CoordinatesRectangle.Builder()
|
||||
.setLongitudeLeft(1000));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenCreateObjectUsingBuilderWithInvalidLongitudeRight_thenFail() {
|
||||
assertThrows(IllegalArgumentException.class, () -> new CoordinateRectangle.Builder()
|
||||
assertThrows(IllegalArgumentException.class, () -> new CoordinatesRectangle.Builder()
|
||||
.setLongitudeRight(-1000));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenCreateObjectUsingBuilderWithInvalidLongitudeRight2_thenFail() {
|
||||
assertThrows(IllegalArgumentException.class, () -> new CoordinateRectangle.Builder()
|
||||
assertThrows(IllegalArgumentException.class, () -> new CoordinatesRectangle.Builder()
|
||||
.setLongitudeRight(1000));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenCreateObjectUsingBuilderWithoutAllPropertiesSet_thenFail() {
|
||||
assertThrows(IllegalStateException.class, () -> new CoordinateRectangle.Builder()
|
||||
assertThrows(IllegalStateException.class, () -> new CoordinatesRectangle.Builder()
|
||||
.build());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenCreateObjectUsingBuilderWithoutAllPropertiesSet1_thenFail() {
|
||||
assertThrows(IllegalStateException.class, () -> new CoordinateRectangle.Builder()
|
||||
assertThrows(IllegalStateException.class, () -> new CoordinatesRectangle.Builder()
|
||||
.setLongitudeLeft(10)
|
||||
.build());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenCreateObjectUsingBuilderWithoutAllPropertiesSet2_thenFail() {
|
||||
assertThrows(IllegalStateException.class, () -> new CoordinateRectangle.Builder()
|
||||
assertThrows(IllegalStateException.class, () -> new CoordinatesRectangle.Builder()
|
||||
.setLongitudeRight(10)
|
||||
.setLatitudeBottom(10)
|
||||
.build());
|
||||
@@ -143,7 +143,7 @@ public class CoordinateRectangleUnitTest {
|
||||
|
||||
@Test
|
||||
public void whenCreateObjectUsingBuilderWithoutAllPropertiesSet3_thenFail() {
|
||||
assertThrows(IllegalStateException.class, () -> new CoordinateRectangle.Builder()
|
||||
assertThrows(IllegalStateException.class, () -> new CoordinatesRectangle.Builder()
|
||||
.setLongitudeLeft(10)
|
||||
.setLatitudeBottom(10)
|
||||
.setLongitudeRight(10)
|
||||
@@ -152,7 +152,7 @@ public class CoordinateRectangleUnitTest {
|
||||
|
||||
@Test
|
||||
public void whenCreateObjectUsingBuilderWithoutAllPropertiesSet4_thenFail() {
|
||||
assertThrows(IllegalStateException.class, () -> new CoordinateRectangle.Builder()
|
||||
assertThrows(IllegalStateException.class, () -> new CoordinatesRectangle.Builder()
|
||||
.setLongitudeLeft(10)
|
||||
.setLatitudeTop(10)
|
||||
.setLatitudeBottom(10)
|
||||
@@ -161,7 +161,7 @@ public class CoordinateRectangleUnitTest {
|
||||
|
||||
@Test
|
||||
public void whenCreateObjectUsingBuilderWithCorrectUsage_thenOk() {
|
||||
final CoordinateRectangle rectangle = new CoordinateRectangle.Builder()
|
||||
final CoordinatesRectangle rectangle = new CoordinatesRectangle.Builder()
|
||||
.setLongitudeRight(10)
|
||||
.setLongitudeLeft(10)
|
||||
.setLatitudeTop(10)
|
||||
@@ -173,7 +173,7 @@ public class CoordinateRectangleUnitTest {
|
||||
|
||||
@Test
|
||||
public void whenGetAllParameters_thenAllIsFine() {
|
||||
final CoordinateRectangle rectangle = CoordinateRectangle.withValues(44.5, 22.4, 54.4, 22.2);
|
||||
final CoordinatesRectangle rectangle = CoordinatesRectangle.withValues(44.5, 22.4, 54.4, 22.2);
|
||||
assertEquals(44.5, rectangle.getLongitudeLeft(), 0.00001);
|
||||
assertEquals(22.4, rectangle.getLatitudeBottom(), 0.00001);
|
||||
assertEquals(54.4, rectangle.getLongitudeRight(), 0.00001);
|
||||
@@ -182,7 +182,7 @@ public class CoordinateRectangleUnitTest {
|
||||
|
||||
@Test
|
||||
public void whenCallToString_thenAllIsFine() {
|
||||
final CoordinateRectangle rectangle = CoordinateRectangle.withValues(44.5, 22.4, 54.4, 22.2);
|
||||
final CoordinatesRectangle rectangle = CoordinatesRectangle.withValues(44.5, 22.4, 54.4, 22.2);
|
||||
|
||||
assertNotNull(rectangle.toString());
|
||||
assertNotEquals("", rectangle.toString());
|
||||
@@ -190,12 +190,12 @@ public class CoordinateRectangleUnitTest {
|
||||
|
||||
@Test
|
||||
public void whenCallHashCode_thenAllIsFine() {
|
||||
final CoordinateRectangle first = CoordinateRectangle.withValues(44.5, 22.4, 54.4, 22.2);
|
||||
final CoordinateRectangle second = CoordinateRectangle.withValues(44.5, 22.4, 54.4, 22.2);
|
||||
final CoordinatesRectangle first = CoordinatesRectangle.withValues(44.5, 22.4, 54.4, 22.2);
|
||||
final CoordinatesRectangle second = CoordinatesRectangle.withValues(44.5, 22.4, 54.4, 22.2);
|
||||
|
||||
assertEquals(first.hashCode(), second.hashCode());
|
||||
|
||||
final CoordinateRectangle third = CoordinateRectangle.withValues(44.5, 22.4, 54.4, 23.566);
|
||||
final CoordinatesRectangle third = CoordinatesRectangle.withValues(44.5, 22.4, 54.4, 23.566);
|
||||
|
||||
assertNotEquals(first.hashCode(), third.hashCode());
|
||||
assertNotEquals(second.hashCode(), third.hashCode());
|
||||
@@ -203,26 +203,26 @@ public class CoordinateRectangleUnitTest {
|
||||
|
||||
@Test
|
||||
public void whenCheckEquality_thenAllIsFine() {
|
||||
CoordinateRectangle first = CoordinateRectangle.withValues(44.5, 22.4, 54.4, 22.2);
|
||||
CoordinateRectangle second = CoordinateRectangle.withValues(44.5, 22.4, 54.4, 22.2);
|
||||
CoordinatesRectangle first = CoordinatesRectangle.withValues(44.5, 22.4, 54.4, 22.2);
|
||||
CoordinatesRectangle second = CoordinatesRectangle.withValues(44.5, 22.4, 54.4, 22.2);
|
||||
|
||||
assertEquals(first, second);
|
||||
assertEquals(first, first);
|
||||
assertNotEquals(first, new Object());
|
||||
|
||||
first = CoordinateRectangle.withValues(49.5, 22.4, 54.4, 22.2);
|
||||
first = CoordinatesRectangle.withValues(49.5, 22.4, 54.4, 22.2);
|
||||
|
||||
assertNotEquals(first, second);
|
||||
|
||||
first = CoordinateRectangle.withValues(44.5, 29.4, 54.4, 22.2);
|
||||
first = CoordinatesRectangle.withValues(44.5, 29.4, 54.4, 22.2);
|
||||
|
||||
assertNotEquals(first, second);
|
||||
|
||||
first = CoordinateRectangle.withValues(44.5, 22.4, 24.4, 22.2);
|
||||
first = CoordinatesRectangle.withValues(44.5, 22.4, 24.4, 22.2);
|
||||
|
||||
assertNotEquals(first, second);
|
||||
|
||||
first = CoordinateRectangle.withValues(44.5, 22.4, 54.4, -2.2);
|
||||
first = CoordinatesRectangle.withValues(44.5, 22.4, 54.4, -2.2);
|
||||
|
||||
assertNotEquals(first, second);
|
||||
}
|
||||
+42
-42
@@ -26,107 +26,107 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class CoordinateUnitTest {
|
||||
public class CoordinatesUnitTest {
|
||||
|
||||
@Test
|
||||
public void whenCreateCoordinateWithValidValues_thenObjectCreated() {
|
||||
Coordinate.of(44, 53);
|
||||
Coordinates.of(44, 53);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenCreateCoordinateWithInvalidLatitudeBelowMinus90_thenThrowAnException() {
|
||||
assertThrows(IllegalArgumentException.class, () -> Coordinate.of(-333, 44));
|
||||
assertThrows(IllegalArgumentException.class, () -> Coordinates.of(-333, 44));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenCreateCoordinateWithInvalidLatitudeAbove90_thenThrowAnException() {
|
||||
assertThrows(IllegalArgumentException.class, () -> Coordinate.of(223, 44));
|
||||
assertThrows(IllegalArgumentException.class, () -> Coordinates.of(223, 44));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenCreateCoordinateWithInvalidLongitudeBelowMinus180_thenThrowAnException() {
|
||||
assertThrows(IllegalArgumentException.class, () -> Coordinate.of(33, -999));
|
||||
assertThrows(IllegalArgumentException.class, () -> Coordinates.of(33, -999));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenCreateCoordinateWithInvalidLongitudeAbove180_thenThrowAnException() {
|
||||
assertThrows(IllegalArgumentException.class, () -> Coordinate.of(33, 999));
|
||||
assertThrows(IllegalArgumentException.class, () -> Coordinates.of(33, 999));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenSetValidCoordinates_thenAllIsFine() {
|
||||
final Coordinate coordinate = Coordinate.of(0, 0);
|
||||
final Coordinates coordinates = Coordinates.of(0, 0);
|
||||
|
||||
coordinate.setLatitude(-90);
|
||||
assertEquals(-90, coordinate.getLatitude(), 0.00001);
|
||||
coordinate.setLatitude(90);
|
||||
assertEquals(90, coordinate.getLatitude(), 0.00001);
|
||||
coordinate.setLatitude(44);
|
||||
assertEquals(44, coordinate.getLatitude(), 0.00001);
|
||||
coordinates.setLatitude(-90);
|
||||
assertEquals(-90, coordinates.getLatitude(), 0.00001);
|
||||
coordinates.setLatitude(90);
|
||||
assertEquals(90, coordinates.getLatitude(), 0.00001);
|
||||
coordinates.setLatitude(44);
|
||||
assertEquals(44, coordinates.getLatitude(), 0.00001);
|
||||
|
||||
coordinate.setLongitude(-180);
|
||||
assertEquals(-180, coordinate.getLongitude(), 0.00001);
|
||||
coordinate.setLongitude(180);
|
||||
assertEquals(180, coordinate.getLongitude(), 0.00001);
|
||||
coordinate.setLongitude(130);
|
||||
assertEquals(130, coordinate.getLongitude(), 0.00001);
|
||||
coordinates.setLongitude(-180);
|
||||
assertEquals(-180, coordinates.getLongitude(), 0.00001);
|
||||
coordinates.setLongitude(180);
|
||||
assertEquals(180, coordinates.getLongitude(), 0.00001);
|
||||
coordinates.setLongitude(130);
|
||||
assertEquals(130, coordinates.getLongitude(), 0.00001);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenSetInvalidLatitudeBelowMinus90_thenThrowAnException() {
|
||||
final Coordinate coordinate = Coordinate.of(0, 0);
|
||||
assertThrows(IllegalArgumentException.class, () -> coordinate.setLatitude(-91));
|
||||
final Coordinates coordinates = Coordinates.of(0, 0);
|
||||
assertThrows(IllegalArgumentException.class, () -> coordinates.setLatitude(-91));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenSetInvalidLatitudeAbove90_thenThrowAnException() {
|
||||
final Coordinate coordinate = Coordinate.of(0, 0);
|
||||
assertThrows(IllegalArgumentException.class, () -> coordinate.setLatitude(92));
|
||||
final Coordinates coordinates = Coordinates.of(0, 0);
|
||||
assertThrows(IllegalArgumentException.class, () -> coordinates.setLatitude(92));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenSetInvalidLongitudeBelowMinus180_thenThrowAnException() {
|
||||
final Coordinate coordinate = Coordinate.of(0, 0);
|
||||
assertThrows(IllegalArgumentException.class, () -> coordinate.setLongitude(-194));
|
||||
final Coordinates coordinates = Coordinates.of(0, 0);
|
||||
assertThrows(IllegalArgumentException.class, () -> coordinates.setLongitude(-194));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenSetInvalidLongitudeAbove180_thenThrowAnException() {
|
||||
final Coordinate coordinate = Coordinate.of(0, 0);
|
||||
assertThrows(IllegalArgumentException.class, () -> coordinate.setLongitude(444));
|
||||
final Coordinates coordinates = Coordinates.of(0, 0);
|
||||
assertThrows(IllegalArgumentException.class, () -> coordinates.setLongitude(444));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenGetLatitude_thenAllIsFine() {
|
||||
final Coordinate coordinate = Coordinate.of(0, 0);
|
||||
assertEquals(0, coordinate.getLatitude(), 0.00001);
|
||||
final Coordinates coordinates = Coordinates.of(0, 0);
|
||||
assertEquals(0, coordinates.getLatitude(), 0.00001);
|
||||
|
||||
coordinate.setLatitude(45);
|
||||
coordinates.setLatitude(45);
|
||||
|
||||
assertEquals(45, coordinate.getLatitude(), 0.00001);
|
||||
assertEquals(45, coordinates.getLatitude(), 0.00001);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenGetLongitude_thenAllIsFine() {
|
||||
final Coordinate coordinate = Coordinate.of(0, 0);
|
||||
assertEquals(0, coordinate.getLongitude(), 0.00001);
|
||||
final Coordinates coordinates = Coordinates.of(0, 0);
|
||||
assertEquals(0, coordinates.getLongitude(), 0.00001);
|
||||
|
||||
coordinate.setLongitude(33);
|
||||
coordinates.setLongitude(33);
|
||||
|
||||
assertEquals(33, coordinate.getLongitude(), 0.00001);
|
||||
assertEquals(33, coordinates.getLongitude(), 0.00001);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenCallToString_thenAllIsFine() {
|
||||
final Coordinate coordinate = Coordinate.of(0, 0);
|
||||
assertNotNull(coordinate.toString());
|
||||
assertNotEquals("", coordinate.toString());
|
||||
final Coordinates coordinates = Coordinates.of(0, 0);
|
||||
assertNotNull(coordinates.toString());
|
||||
assertNotEquals("", coordinates.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenCallHashCode_thenAllIsFine() {
|
||||
final Coordinate first = Coordinate.of(22, 66);
|
||||
final Coordinate second = Coordinate.of(22, 44);
|
||||
final Coordinates first = Coordinates.of(22, 66);
|
||||
final Coordinates second = Coordinates.of(22, 44);
|
||||
|
||||
assertNotEquals(first.hashCode(), second.hashCode());
|
||||
|
||||
@@ -145,8 +145,8 @@ public class CoordinateUnitTest {
|
||||
|
||||
@Test
|
||||
public void whenCheckEquality_thenAllIsFine() {
|
||||
final Coordinate first = Coordinate.of(11, 99);
|
||||
final Coordinate second = Coordinate.of(11, 99);
|
||||
final Coordinates first = Coordinates.of(11, 99);
|
||||
final Coordinates second = Coordinates.of(11, 99);
|
||||
|
||||
assertEquals(first, second);
|
||||
assertEquals(first, first);
|
||||
+9
-9
@@ -24,7 +24,7 @@
|
||||
|
||||
package com.github.prominence.openweathermap.api.model.air.pollution;
|
||||
|
||||
import com.github.prominence.openweathermap.api.model.Coordinate;
|
||||
import com.github.prominence.openweathermap.api.model.Coordinates;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -36,10 +36,10 @@ public class AirPollutionDetailsUnitTest {
|
||||
@Test
|
||||
public void getCoordinate() {
|
||||
final AirPollutionDetails airPollutionDetails = new AirPollutionDetails();
|
||||
final Coordinate coordinate = Coordinate.of(22.3, 44.2);
|
||||
airPollutionDetails.setCoordinate(coordinate);
|
||||
final Coordinates coordinates = Coordinates.of(22.3, 44.2);
|
||||
airPollutionDetails.setCoordinate(coordinates);
|
||||
|
||||
assertEquals(coordinate, airPollutionDetails.getCoordinate());
|
||||
assertEquals(coordinates, airPollutionDetails.getCoordinate());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -55,7 +55,7 @@ public class AirPollutionDetailsUnitTest {
|
||||
public void testEquals() {
|
||||
final AirPollutionDetails first = new AirPollutionDetails();
|
||||
final AirPollutionDetails second = new AirPollutionDetails();
|
||||
final Coordinate coordinate = Coordinate.of(22.3, 44.2);
|
||||
final Coordinates coordinates = Coordinates.of(22.3, 44.2);
|
||||
final List<AirPollutionRecord> airPollutionRecords = new ArrayList<>();
|
||||
|
||||
assertEquals(first, first);
|
||||
@@ -65,11 +65,11 @@ public class AirPollutionDetailsUnitTest {
|
||||
|
||||
assertEquals(first, second);
|
||||
|
||||
first.setCoordinate(coordinate);
|
||||
first.setCoordinate(coordinates);
|
||||
|
||||
assertNotEquals(first, second);
|
||||
|
||||
second.setCoordinate(coordinate);
|
||||
second.setCoordinate(coordinates);
|
||||
|
||||
assertEquals(first, second);
|
||||
|
||||
@@ -86,11 +86,11 @@ public class AirPollutionDetailsUnitTest {
|
||||
public void testHashCode() {
|
||||
final AirPollutionDetails first = new AirPollutionDetails();
|
||||
final AirPollutionDetails second = new AirPollutionDetails();
|
||||
final Coordinate coordinate = Coordinate.of(22.3, 44.2);
|
||||
final Coordinates coordinates = Coordinates.of(22.3, 44.2);
|
||||
|
||||
assertEquals(first.hashCode(), second.hashCode());
|
||||
|
||||
first.setCoordinate(coordinate);
|
||||
first.setCoordinate(coordinates);
|
||||
|
||||
assertNotEquals(first.hashCode(), second.hashCode());
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Alexey Zinchenko
|
||||
* Copyright (c) 2022 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
|
||||
@@ -20,7 +20,7 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.github.prominence.openweathermap.api.model.forecast;
|
||||
package com.github.prominence.openweathermap.api.model.forecast.free;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
+10
-10
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Alexey Zinchenko
|
||||
* Copyright (c) 2022 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
|
||||
@@ -20,9 +20,9 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.github.prominence.openweathermap.api.model.forecast;
|
||||
package com.github.prominence.openweathermap.api.model.forecast.free;
|
||||
|
||||
import com.github.prominence.openweathermap.api.model.Coordinate;
|
||||
import com.github.prominence.openweathermap.api.model.Coordinates;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
@@ -95,10 +95,10 @@ public class LocationUnitTest {
|
||||
@Test
|
||||
public void whenSetCoordinate_thenValueIsSet() {
|
||||
final Location location = Location.withValues(33, "test");
|
||||
final Coordinate coordinate = Coordinate.of(33.2, 64.2);
|
||||
location.setCoordinate(coordinate);
|
||||
final Coordinates coordinates = Coordinates.of(33.2, 64.2);
|
||||
location.setCoordinate(coordinates);
|
||||
|
||||
assertEquals(coordinate, location.getCoordinate());
|
||||
assertEquals(coordinates, location.getCoordinate());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -115,7 +115,7 @@ public class LocationUnitTest {
|
||||
|
||||
assertNotEquals("", location.toString());
|
||||
|
||||
location.setCoordinate(Coordinate.of(33.2, 56.3));
|
||||
location.setCoordinate(Coordinates.of(33.2, 56.3));
|
||||
|
||||
assertNotEquals("", location.toString());
|
||||
|
||||
@@ -201,13 +201,13 @@ public class LocationUnitTest {
|
||||
|
||||
assertEquals(one, two);
|
||||
|
||||
final Coordinate coordinate = Coordinate.of(33.5, -22.4);
|
||||
final Coordinates coordinates = Coordinates.of(33.5, -22.4);
|
||||
|
||||
one.setCoordinate(coordinate);
|
||||
one.setCoordinate(coordinates);
|
||||
|
||||
assertNotEquals(one, two);
|
||||
|
||||
two.setCoordinate(coordinate);
|
||||
two.setCoordinate(coordinates);
|
||||
|
||||
assertEquals(one, two);
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Alexey Zinchenko
|
||||
* Copyright (c) 2022 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
|
||||
@@ -20,7 +20,7 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.github.prominence.openweathermap.api.model.forecast;
|
||||
package com.github.prominence.openweathermap.api.model.forecast.free;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
+3
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Alexey Zinchenko
|
||||
* Copyright (c) 2022 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
|
||||
@@ -20,7 +20,7 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.github.prominence.openweathermap.api.model.forecast;
|
||||
package com.github.prominence.openweathermap.api.model.forecast.free;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -32,6 +32,7 @@ public class SnowUnitTest {
|
||||
Snow.withThreeHourLevelValue(2222.3);
|
||||
Snow.withThreeHourLevelValue(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenCreateWithInvalidData_thenFail() {
|
||||
assertThrows(IllegalArgumentException.class, () -> Snow.withThreeHourLevelValue(-20));
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Alexey Zinchenko
|
||||
* Copyright (c) 2022 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
|
||||
@@ -20,7 +20,7 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.github.prominence.openweathermap.api.model.forecast;
|
||||
package com.github.prominence.openweathermap.api.model.forecast.free;
|
||||
|
||||
import com.github.prominence.openweathermap.api.model.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
+3
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Alexey Zinchenko
|
||||
* Copyright (c) 2022 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
|
||||
@@ -20,8 +20,9 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.github.prominence.openweathermap.api.model.forecast;
|
||||
package com.github.prominence.openweathermap.api.model.forecast.free;
|
||||
|
||||
import com.github.prominence.openweathermap.api.model.Wind;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
+6
-4
@@ -25,9 +25,11 @@ package com.github.prominence.openweathermap.api.model.onecall;
|
||||
import com.github.prominence.openweathermap.api.model.Clouds;
|
||||
import com.github.prominence.openweathermap.api.model.Humidity;
|
||||
import com.github.prominence.openweathermap.api.model.WeatherState;
|
||||
import com.github.prominence.openweathermap.api.model.Wind;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
@@ -63,9 +65,9 @@ public class CurrentUnitTest {
|
||||
public void getWeatherState() {
|
||||
final Current current = new Current();
|
||||
final WeatherState weatherState = new WeatherState(800, "Clear", "clear sky");
|
||||
current.setWeatherState(weatherState);
|
||||
current.setWeatherStates(List.of(weatherState));
|
||||
|
||||
assertEquals(weatherState, current.getWeatherState());
|
||||
assertEquals(weatherState, current.getWeatherStates().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -211,11 +213,11 @@ public class CurrentUnitTest {
|
||||
|
||||
final WeatherState weatherState = new WeatherState(800, "Clear", "clear sky");
|
||||
|
||||
first.setWeatherState(weatherState);
|
||||
first.setWeatherStates(List.of(weatherState));
|
||||
|
||||
assertNotEquals(first, second);
|
||||
|
||||
second.setWeatherState(weatherState);
|
||||
second.setWeatherStates(List.of(weatherState));
|
||||
|
||||
assertEquals(first, second);
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
package com.github.prominence.openweathermap.api.model.onecall;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import com.github.prominence.openweathermap.api.model.Wind;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
|
||||
+4
-3
@@ -26,6 +26,7 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
@@ -131,8 +132,8 @@ public class AlertUnitTest {
|
||||
|
||||
@Test
|
||||
public void getHashCode() {
|
||||
final Alert event1 = new Alert("Sender", "Event1", LocalDateTime.now(), LocalDateTime.now().plus(2, ChronoUnit.HOURS), "Description1");
|
||||
final Alert event2 = new Alert("Sender", "Event2", LocalDateTime.now(), LocalDateTime.now().plus(2, ChronoUnit.HOURS), "Description2");
|
||||
final Alert event1 = new Alert("Sender", "Event1", LocalDateTime.now(), LocalDateTime.now().plus(2, ChronoUnit.HOURS), "Description1", Collections.emptyList());
|
||||
final Alert event2 = new Alert("Sender", "Event2", LocalDateTime.now(), LocalDateTime.now().plus(2, ChronoUnit.HOURS), "Description2", Collections.emptyList());
|
||||
|
||||
assertEquals(event1.hashCode(), event1.hashCode());
|
||||
assertNotEquals(event1.hashCode(), event2.hashCode());
|
||||
@@ -140,7 +141,7 @@ public class AlertUnitTest {
|
||||
|
||||
@Test
|
||||
public void getToString() {
|
||||
final Alert alert = new Alert("Sender", "Event", LocalDateTime.now(), LocalDateTime.now().plus(2, ChronoUnit.HOURS), "Description");
|
||||
final Alert alert = new Alert("Sender", "Event", LocalDateTime.now(), LocalDateTime.now().plus(2, ChronoUnit.HOURS), "Description", Collections.emptyList());
|
||||
|
||||
assertNotNull(alert.toString());
|
||||
assertNotEquals("", alert.toString());
|
||||
|
||||
+9
-9
@@ -22,7 +22,7 @@
|
||||
|
||||
package com.github.prominence.openweathermap.api.model.onecall.current;
|
||||
|
||||
import com.github.prominence.openweathermap.api.model.Coordinate;
|
||||
import com.github.prominence.openweathermap.api.model.Coordinates;
|
||||
import com.github.prominence.openweathermap.api.model.onecall.Current;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -37,10 +37,10 @@ public class CurrentWeatherDataUnitTest {
|
||||
@Test
|
||||
public void getCoordinate() {
|
||||
final CurrentWeatherData currentWeatherData = new CurrentWeatherData();
|
||||
final Coordinate coordinate = Coordinate.of(11.2, 43.2);
|
||||
currentWeatherData.setCoordinate(coordinate);
|
||||
final Coordinates coordinates = Coordinates.of(11.2, 43.2);
|
||||
currentWeatherData.setCoordinate(coordinates);
|
||||
|
||||
assertEquals(coordinate, currentWeatherData.getCoordinate());
|
||||
assertEquals(coordinates, currentWeatherData.getCoordinate());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -115,7 +115,7 @@ public class CurrentWeatherDataUnitTest {
|
||||
assertNotEquals(first, null);
|
||||
assertNotEquals(first, new Object());
|
||||
|
||||
final Coordinate coordinate = Coordinate.of(11, 12);
|
||||
final Coordinates coordinates = Coordinates.of(11, 12);
|
||||
final ZoneId timeZone = ZoneId.of("GMT");
|
||||
final ZoneOffset offset = ZoneOffset.UTC;
|
||||
final Current current = new Current();
|
||||
@@ -126,11 +126,11 @@ public class CurrentWeatherDataUnitTest {
|
||||
|
||||
assertEquals(first, second);
|
||||
|
||||
first.setCoordinate(coordinate);
|
||||
first.setCoordinate(coordinates);
|
||||
|
||||
assertNotEquals(first, second);
|
||||
|
||||
second.setCoordinate(coordinate);
|
||||
second.setCoordinate(coordinates);
|
||||
|
||||
assertEquals(first, second);
|
||||
|
||||
@@ -198,7 +198,7 @@ public class CurrentWeatherDataUnitTest {
|
||||
|
||||
assertEquals(first.hashCode(), second.hashCode());
|
||||
|
||||
first.setCoordinate(Coordinate.of(11, 42));
|
||||
first.setCoordinate(Coordinates.of(11, 42));
|
||||
|
||||
assertNotEquals(first.hashCode(), second.hashCode());
|
||||
}
|
||||
@@ -206,7 +206,7 @@ public class CurrentWeatherDataUnitTest {
|
||||
@Test
|
||||
public void getToString() {
|
||||
final CurrentWeatherData currentWeatherData = new CurrentWeatherData();
|
||||
currentWeatherData.setCoordinate(Coordinate.of(32, 22));
|
||||
currentWeatherData.setCoordinate(Coordinates.of(32, 22));
|
||||
|
||||
assertNotNull(currentWeatherData.toString());
|
||||
assertNotEquals("", currentWeatherData.toString());
|
||||
|
||||
+7
-6
@@ -26,10 +26,11 @@ import com.github.prominence.openweathermap.api.model.Clouds;
|
||||
import com.github.prominence.openweathermap.api.model.Humidity;
|
||||
import com.github.prominence.openweathermap.api.model.WeatherState;
|
||||
import com.github.prominence.openweathermap.api.model.onecall.AtmosphericPressure;
|
||||
import com.github.prominence.openweathermap.api.model.onecall.Wind;
|
||||
import com.github.prominence.openweathermap.api.model.Wind;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
@@ -65,9 +66,9 @@ public class DailyUnitTest {
|
||||
public void getWeatherState() {
|
||||
final Daily daily = new Daily();
|
||||
final WeatherState weatherState = new WeatherState(800, "Clear", "clear sky");
|
||||
daily.setWeatherState(weatherState);
|
||||
daily.setWeatherStates(List.of(weatherState));
|
||||
|
||||
assertEquals(weatherState, daily.getWeatherState());
|
||||
assertEquals(weatherState, daily.getWeatherStates().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -224,11 +225,11 @@ public class DailyUnitTest {
|
||||
|
||||
final WeatherState weatherState = new WeatherState(800, "Clear", "clear sky");
|
||||
|
||||
first.setWeatherState(weatherState);
|
||||
first.setWeatherStates(List.of(weatherState));
|
||||
|
||||
assertNotEquals(first, second);
|
||||
|
||||
second.setWeatherState(weatherState);
|
||||
second.setWeatherStates(List.of(weatherState));
|
||||
|
||||
assertEquals(first, second);
|
||||
|
||||
@@ -347,7 +348,7 @@ public class DailyUnitTest {
|
||||
|
||||
final WeatherState weatherState = new WeatherState(800, "Clear", "clear sky");
|
||||
|
||||
daily.setWeatherState(weatherState);
|
||||
daily.setWeatherStates(List.of(weatherState));
|
||||
|
||||
assertNotNull(daily.toString());
|
||||
assertNotEquals("", daily.toString());
|
||||
|
||||
+6
-4
@@ -25,10 +25,12 @@ package com.github.prominence.openweathermap.api.model.onecall.current;
|
||||
import com.github.prominence.openweathermap.api.model.Clouds;
|
||||
import com.github.prominence.openweathermap.api.model.Humidity;
|
||||
import com.github.prominence.openweathermap.api.model.WeatherState;
|
||||
import com.github.prominence.openweathermap.api.model.Wind;
|
||||
import com.github.prominence.openweathermap.api.model.onecall.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
@@ -46,9 +48,9 @@ public class HourlyUnitTest {
|
||||
public void getWeatherState() {
|
||||
final Hourly hourly = new Hourly();
|
||||
final WeatherState weatherState = new WeatherState(800, "Clear", "clear sky");
|
||||
hourly.setWeatherState(weatherState);
|
||||
hourly.setWeatherStates(List.of(weatherState));
|
||||
|
||||
assertEquals(weatherState, hourly.getWeatherState());
|
||||
assertEquals(weatherState, hourly.getWeatherStates().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -193,11 +195,11 @@ public class HourlyUnitTest {
|
||||
|
||||
assertEquals(first, second);
|
||||
|
||||
first.setWeatherState(weatherState);
|
||||
first.setWeatherStates(List.of(weatherState));
|
||||
|
||||
assertNotEquals(first, second);
|
||||
|
||||
second.setWeatherState(weatherState);
|
||||
second.setWeatherStates(List.of(weatherState));
|
||||
|
||||
assertEquals(first, second);
|
||||
|
||||
|
||||
+9
-9
@@ -22,7 +22,7 @@
|
||||
|
||||
package com.github.prominence.openweathermap.api.model.onecall.historical;
|
||||
|
||||
import com.github.prominence.openweathermap.api.model.Coordinate;
|
||||
import com.github.prominence.openweathermap.api.model.Coordinates;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.ZoneId;
|
||||
@@ -36,10 +36,10 @@ public class HistoricalWeatherDataUnitTest {
|
||||
@Test
|
||||
public void getCoordinate() {
|
||||
final HistoricalWeatherData historicalWeatherData = new HistoricalWeatherData();
|
||||
final Coordinate coordinate = Coordinate.of(11.2, 43.2);
|
||||
historicalWeatherData.setCoordinate(coordinate);
|
||||
final Coordinates coordinates = Coordinates.of(11.2, 43.2);
|
||||
historicalWeatherData.setCoordinate(coordinates);
|
||||
|
||||
assertEquals(coordinate, historicalWeatherData.getCoordinate());
|
||||
assertEquals(coordinates, historicalWeatherData.getCoordinate());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -87,7 +87,7 @@ public class HistoricalWeatherDataUnitTest {
|
||||
assertNotEquals(first, null);
|
||||
assertNotEquals(first, new Object());
|
||||
|
||||
final Coordinate coordinate = Coordinate.of(11, 12);
|
||||
final Coordinates coordinates = Coordinates.of(11, 12);
|
||||
final ZoneId timeZone = ZoneId.of("GMT");
|
||||
final ZoneOffset offset = ZoneOffset.UTC;
|
||||
final HistoricalWeather historicalWeather = new HistoricalWeather();
|
||||
@@ -95,11 +95,11 @@ public class HistoricalWeatherDataUnitTest {
|
||||
|
||||
assertEquals(first, second);
|
||||
|
||||
first.setCoordinate(coordinate);
|
||||
first.setCoordinate(coordinates);
|
||||
|
||||
assertNotEquals(first, second);
|
||||
|
||||
second.setCoordinate(coordinate);
|
||||
second.setCoordinate(coordinates);
|
||||
|
||||
assertEquals(first, second);
|
||||
|
||||
@@ -143,7 +143,7 @@ public class HistoricalWeatherDataUnitTest {
|
||||
|
||||
assertEquals(first.hashCode(), second.hashCode());
|
||||
|
||||
first.setCoordinate(Coordinate.of(11, 42));
|
||||
first.setCoordinate(Coordinates.of(11, 42));
|
||||
|
||||
assertNotEquals(first.hashCode(), second.hashCode());
|
||||
}
|
||||
@@ -151,7 +151,7 @@ public class HistoricalWeatherDataUnitTest {
|
||||
@Test
|
||||
public void getToString() {
|
||||
final HistoricalWeatherData historicalWeatherData = new HistoricalWeatherData();
|
||||
historicalWeatherData.setCoordinate(Coordinate.of(32, 22));
|
||||
historicalWeatherData.setCoordinate(Coordinates.of(32, 22));
|
||||
|
||||
assertNotNull(historicalWeatherData.toString());
|
||||
assertNotEquals("", historicalWeatherData.toString());
|
||||
|
||||
+6
-4
@@ -25,10 +25,12 @@ package com.github.prominence.openweathermap.api.model.onecall.historical;
|
||||
import com.github.prominence.openweathermap.api.model.Clouds;
|
||||
import com.github.prominence.openweathermap.api.model.Humidity;
|
||||
import com.github.prominence.openweathermap.api.model.WeatherState;
|
||||
import com.github.prominence.openweathermap.api.model.Wind;
|
||||
import com.github.prominence.openweathermap.api.model.onecall.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
@@ -64,9 +66,9 @@ public class HistoricalWeatherUnitTest {
|
||||
public void getWeatherState() {
|
||||
final HistoricalWeather historicalWeather = new HistoricalWeather();
|
||||
final WeatherState weatherState = new WeatherState(800, "Clear", "clear sky");
|
||||
historicalWeather.setWeatherState(weatherState);
|
||||
historicalWeather.setWeatherStates(List.of(weatherState));
|
||||
|
||||
assertEquals(weatherState, historicalWeather.getWeatherState());
|
||||
assertEquals(weatherState, historicalWeather.getWeatherStates().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -212,11 +214,11 @@ public class HistoricalWeatherUnitTest {
|
||||
|
||||
final WeatherState weatherState = new WeatherState(800, "Clear", "clear sky");
|
||||
|
||||
first.setWeatherState(weatherState);
|
||||
first.setWeatherStates(List.of(weatherState));
|
||||
|
||||
assertNotEquals(first, second);
|
||||
|
||||
second.setWeatherState(weatherState);
|
||||
second.setWeatherStates(List.of(weatherState));
|
||||
|
||||
assertEquals(first, second);
|
||||
|
||||
|
||||
+6
-4
@@ -25,10 +25,12 @@ package com.github.prominence.openweathermap.api.model.onecall.historical;
|
||||
import com.github.prominence.openweathermap.api.model.Clouds;
|
||||
import com.github.prominence.openweathermap.api.model.Humidity;
|
||||
import com.github.prominence.openweathermap.api.model.WeatherState;
|
||||
import com.github.prominence.openweathermap.api.model.Wind;
|
||||
import com.github.prominence.openweathermap.api.model.onecall.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
@@ -46,9 +48,9 @@ public class HourlyHistoricalUnitTest {
|
||||
public void getWeatherState() {
|
||||
final HourlyHistorical hourlyHistorical = new HourlyHistorical();
|
||||
final WeatherState weatherState = new WeatherState(800, "Clear", "clear sky");
|
||||
hourlyHistorical.setWeatherState(weatherState);
|
||||
hourlyHistorical.setWeatherStates(List.of(weatherState));
|
||||
|
||||
assertEquals(weatherState, hourlyHistorical.getWeatherState());
|
||||
assertEquals(weatherState, hourlyHistorical.getWeatherStates().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -153,11 +155,11 @@ public class HourlyHistoricalUnitTest {
|
||||
|
||||
assertEquals(first, second);
|
||||
|
||||
first.setWeatherState(weatherState);
|
||||
first.setWeatherStates(List.of(weatherState));
|
||||
|
||||
assertNotEquals(first, second);
|
||||
|
||||
second.setWeatherState(weatherState);
|
||||
second.setWeatherStates(List.of(weatherState));
|
||||
|
||||
assertEquals(first, second);
|
||||
|
||||
|
||||
+8
-8
@@ -22,7 +22,7 @@
|
||||
|
||||
package com.github.prominence.openweathermap.api.model.weather;
|
||||
|
||||
import com.github.prominence.openweathermap.api.model.Coordinate;
|
||||
import com.github.prominence.openweathermap.api.model.Coordinates;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
@@ -95,10 +95,10 @@ public class LocationUnitTest {
|
||||
@Test
|
||||
public void whenSetCoordinate_thenValueIsSet() {
|
||||
final Location location = Location.withValues(33, "test");
|
||||
final Coordinate coordinate = Coordinate.of(33.2, 64.2);
|
||||
location.setCoordinate(coordinate);
|
||||
final Coordinates coordinates = Coordinates.of(33.2, 64.2);
|
||||
location.setCoordinate(coordinates);
|
||||
|
||||
assertEquals(coordinate, location.getCoordinate());
|
||||
assertEquals(coordinates, location.getCoordinate());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -107,7 +107,7 @@ public class LocationUnitTest {
|
||||
|
||||
assertNotEquals("", location.toString());
|
||||
|
||||
location.setCoordinate(Coordinate.of(33.2, 56.3));
|
||||
location.setCoordinate(Coordinates.of(33.2, 56.3));
|
||||
|
||||
assertNotEquals("", location.toString());
|
||||
|
||||
@@ -189,13 +189,13 @@ public class LocationUnitTest {
|
||||
|
||||
assertEquals(one, two);
|
||||
|
||||
final Coordinate coordinate = Coordinate.of(33.5, -22.4);
|
||||
final Coordinates coordinates = Coordinates.of(33.5, -22.4);
|
||||
|
||||
one.setCoordinate(coordinate);
|
||||
one.setCoordinate(coordinates);
|
||||
|
||||
assertNotEquals(one, two);
|
||||
|
||||
two.setCoordinate(coordinate);
|
||||
two.setCoordinate(coordinates);
|
||||
|
||||
assertEquals(one, two);
|
||||
}
|
||||
|
||||
+4
-2
@@ -26,6 +26,8 @@ import com.github.prominence.openweathermap.api.model.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
@@ -201,11 +203,11 @@ public class WeatherUnitTest {
|
||||
assertEquals(one, two);
|
||||
|
||||
final WeatherState weatherState = new WeatherState(800, "Clear", "clear sky");
|
||||
one.setWeatherState(weatherState);
|
||||
one.setWeatherStates(Collections.singletonList(weatherState));
|
||||
|
||||
assertNotEquals(one, two);
|
||||
|
||||
two.setWeatherState(weatherState);
|
||||
two.setWeatherStates(Collections.singletonList(weatherState));
|
||||
|
||||
assertEquals(one, two);
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
package com.github.prominence.openweathermap.api.model.weather;
|
||||
|
||||
import com.github.prominence.openweathermap.api.model.Wind;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
+13
-13
@@ -25,7 +25,7 @@
|
||||
package com.github.prominence.openweathermap.api.request.air.pollution;
|
||||
|
||||
import com.github.prominence.openweathermap.api.ApiTest;
|
||||
import com.github.prominence.openweathermap.api.model.Coordinate;
|
||||
import com.github.prominence.openweathermap.api.model.Coordinates;
|
||||
import com.github.prominence.openweathermap.api.model.air.pollution.AirPollutionDetails;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -40,7 +40,7 @@ public class AirPollutionIntegrationTest extends ApiTest {
|
||||
final AirPollutionDetails airPollutionDetails = getClient()
|
||||
.airPollution()
|
||||
.current()
|
||||
.byCoordinate(Coordinate.of(53.54, 27.34))
|
||||
.byCoordinates(Coordinates.of(53.54, 27.34))
|
||||
.retrieve()
|
||||
.asJava();
|
||||
|
||||
@@ -56,7 +56,7 @@ public class AirPollutionIntegrationTest extends ApiTest {
|
||||
final String jsonString = getClient()
|
||||
.airPollution()
|
||||
.current()
|
||||
.byCoordinate(Coordinate.of(53.54, 27.34))
|
||||
.byCoordinates(Coordinates.of(53.54, 27.34))
|
||||
.retrieve()
|
||||
.asJSON();
|
||||
|
||||
@@ -69,7 +69,7 @@ public class AirPollutionIntegrationTest extends ApiTest {
|
||||
final CompletableFuture<AirPollutionDetails> pollutionDetailsFuture = getClient()
|
||||
.airPollution()
|
||||
.current()
|
||||
.byCoordinate(Coordinate.of(53.54, 27.34))
|
||||
.byCoordinates(Coordinates.of(53.54, 27.34))
|
||||
.retrieveAsync()
|
||||
.asJava();
|
||||
|
||||
@@ -82,7 +82,7 @@ public class AirPollutionIntegrationTest extends ApiTest {
|
||||
final CompletableFuture<String> jsonStringFuture = getClient()
|
||||
.airPollution()
|
||||
.current()
|
||||
.byCoordinate(Coordinate.of(53.54, 27.34))
|
||||
.byCoordinates(Coordinates.of(53.54, 27.34))
|
||||
.retrieveAsync()
|
||||
.asJSON();
|
||||
|
||||
@@ -97,7 +97,7 @@ public class AirPollutionIntegrationTest extends ApiTest {
|
||||
final AirPollutionDetails airPollutionDetails = getClient()
|
||||
.airPollution()
|
||||
.forecast()
|
||||
.byCoordinate(Coordinate.of(53.54, 27.34))
|
||||
.byCoordinates(Coordinates.of(53.54, 27.34))
|
||||
.retrieve()
|
||||
.asJava();
|
||||
|
||||
@@ -113,7 +113,7 @@ public class AirPollutionIntegrationTest extends ApiTest {
|
||||
final String jsonString = getClient()
|
||||
.airPollution()
|
||||
.forecast()
|
||||
.byCoordinate(Coordinate.of(53.54, 27.34))
|
||||
.byCoordinates(Coordinates.of(53.54, 27.34))
|
||||
.retrieve()
|
||||
.asJSON();
|
||||
|
||||
@@ -126,7 +126,7 @@ public class AirPollutionIntegrationTest extends ApiTest {
|
||||
final CompletableFuture<AirPollutionDetails> pollutionDetailsFuture = getClient()
|
||||
.airPollution()
|
||||
.forecast()
|
||||
.byCoordinate(Coordinate.of(53.54, 27.34))
|
||||
.byCoordinates(Coordinates.of(53.54, 27.34))
|
||||
.retrieveAsync()
|
||||
.asJava();
|
||||
|
||||
@@ -139,7 +139,7 @@ public class AirPollutionIntegrationTest extends ApiTest {
|
||||
final CompletableFuture<String> jsonStringFuture = getClient()
|
||||
.airPollution()
|
||||
.forecast()
|
||||
.byCoordinate(Coordinate.of(53.54, 27.34))
|
||||
.byCoordinates(Coordinates.of(53.54, 27.34))
|
||||
.retrieveAsync()
|
||||
.asJSON();
|
||||
|
||||
@@ -154,7 +154,7 @@ public class AirPollutionIntegrationTest extends ApiTest {
|
||||
final AirPollutionDetails airPollutionDetails = getClient()
|
||||
.airPollution()
|
||||
.historical()
|
||||
.byCoordinateAndPeriod(Coordinate.of(53.54, 27.34), 1606223802, 1606482999)
|
||||
.byCoordinateAndPeriod(Coordinates.of(53.54, 27.34), 1606223802, 1606482999)
|
||||
.retrieve()
|
||||
.asJava();
|
||||
|
||||
@@ -170,7 +170,7 @@ public class AirPollutionIntegrationTest extends ApiTest {
|
||||
final String jsonString = getClient()
|
||||
.airPollution()
|
||||
.historical()
|
||||
.byCoordinateAndPeriod(Coordinate.of(53.54, 27.34), 1606223802, 1606482999)
|
||||
.byCoordinateAndPeriod(Coordinates.of(53.54, 27.34), 1606223802, 1606482999)
|
||||
.retrieve()
|
||||
.asJSON();
|
||||
|
||||
@@ -183,7 +183,7 @@ public class AirPollutionIntegrationTest extends ApiTest {
|
||||
final CompletableFuture<AirPollutionDetails> pollutionDetailsFuture = getClient()
|
||||
.airPollution()
|
||||
.historical()
|
||||
.byCoordinateAndPeriod(Coordinate.of(53.54, 27.34), 1606223802, 1606482999)
|
||||
.byCoordinateAndPeriod(Coordinates.of(53.54, 27.34), 1606223802, 1606482999)
|
||||
.retrieveAsync()
|
||||
.asJava();
|
||||
|
||||
@@ -196,7 +196,7 @@ public class AirPollutionIntegrationTest extends ApiTest {
|
||||
final CompletableFuture<String> jsonStringFuture = getClient()
|
||||
.airPollution()
|
||||
.historical()
|
||||
.byCoordinateAndPeriod(Coordinate.of(53.54, 27.34), 1606223802, 1606482999)
|
||||
.byCoordinateAndPeriod(Coordinates.of(53.54, 27.34), 1606223802, 1606482999)
|
||||
.retrieveAsync()
|
||||
.asJSON();
|
||||
|
||||
|
||||
+6
-6
@@ -28,9 +28,9 @@ import com.github.prominence.openweathermap.api.enums.Language;
|
||||
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.forecast.Forecast;
|
||||
import com.github.prominence.openweathermap.api.model.forecast.WeatherForecast;
|
||||
import com.github.prominence.openweathermap.api.model.Coordinates;
|
||||
import com.github.prominence.openweathermap.api.model.forecast.free.Forecast;
|
||||
import com.github.prominence.openweathermap.api.model.forecast.free.WeatherForecast;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
@@ -249,7 +249,7 @@ public class FiveDayThreeHourStepForecastIntegrationTest extends ApiTest {
|
||||
public void whenGetForecastByCoordinatesRequestAsJava_thenReturnNotNull() {
|
||||
final Forecast forecast = getClient()
|
||||
.forecast5Day3HourStep()
|
||||
.byCoordinate(Coordinate.of(5, 5))
|
||||
.byCoordinates(Coordinates.of(5, 5))
|
||||
.language(Language.ENGLISH)
|
||||
.unitSystem(UnitSystem.METRIC)
|
||||
.count(15)
|
||||
@@ -273,7 +273,7 @@ public class FiveDayThreeHourStepForecastIntegrationTest extends ApiTest {
|
||||
public void whenGetForecastByCoordinatesRequestAsJSON_thenReturnNotNull() {
|
||||
final String forecastJson = getClient()
|
||||
.forecast5Day3HourStep()
|
||||
.byCoordinate(Coordinate.of(5, 5))
|
||||
.byCoordinates(Coordinates.of(5, 5))
|
||||
.language(Language.SPANISH)
|
||||
.unitSystem(UnitSystem.IMPERIAL)
|
||||
.count(15)
|
||||
@@ -287,7 +287,7 @@ public class FiveDayThreeHourStepForecastIntegrationTest extends ApiTest {
|
||||
public void whenGetForecastByCoordinatesRequestAsXML_thenReturnNotNull() {
|
||||
final String forecastXml = getClient()
|
||||
.forecast5Day3HourStep()
|
||||
.byCoordinate(Coordinate.of(5, 5))
|
||||
.byCoordinates(Coordinates.of(5, 5))
|
||||
.language(Language.ENGLISH)
|
||||
.unitSystem(UnitSystem.METRIC)
|
||||
.retrieve()
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ package com.github.prominence.openweathermap.api.request.forecast.free;
|
||||
|
||||
import com.github.prominence.openweathermap.api.enums.UnitSystem;
|
||||
import com.github.prominence.openweathermap.api.mapper.FiveDayThreeHourStepForecastResponseMapper;
|
||||
import com.github.prominence.openweathermap.api.model.forecast.Forecast;
|
||||
import com.github.prominence.openweathermap.api.model.forecast.free.Forecast;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
+514
-1
File diff suppressed because one or more lines are too long
+7
-8
@@ -28,8 +28,7 @@ import com.github.prominence.openweathermap.api.enums.Language;
|
||||
import com.github.prominence.openweathermap.api.enums.OneCallResultOptions;
|
||||
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.Coordinates;
|
||||
import com.github.prominence.openweathermap.api.model.onecall.current.CurrentWeatherData;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -44,7 +43,7 @@ public class CurrentWeatherOneCallIntegrationTest extends ApiTest {
|
||||
final CurrentWeatherData currentWeatherData = getClient()
|
||||
.oneCall()
|
||||
.current()
|
||||
.byCoordinate(Coordinate.of(53.54, 27.34))
|
||||
.byCoordinates(Coordinates.of(53.54, 27.34))
|
||||
.language(Language.ENGLISH)
|
||||
.unitSystem(UnitSystem.METRIC)
|
||||
.retrieve()
|
||||
@@ -58,7 +57,7 @@ public class CurrentWeatherOneCallIntegrationTest extends ApiTest {
|
||||
final String responseJson = getClient()
|
||||
.oneCall()
|
||||
.current()
|
||||
.byCoordinate(Coordinate.of(53.54, 27.34))
|
||||
.byCoordinates(Coordinates.of(53.54, 27.34))
|
||||
.language(Language.ENGLISH)
|
||||
.unitSystem(UnitSystem.METRIC)
|
||||
.retrieve()
|
||||
@@ -74,7 +73,7 @@ public class CurrentWeatherOneCallIntegrationTest extends ApiTest {
|
||||
final CurrentWeatherData currentWeatherData = getClient()
|
||||
.oneCall()
|
||||
.current()
|
||||
.byCoordinate(Coordinate.of(53.54, 27.34))
|
||||
.byCoordinates(Coordinates.of(53.54, 27.34))
|
||||
.language(Language.ENGLISH)
|
||||
.unitSystem(UnitSystem.METRIC)
|
||||
.exclude(OneCallResultOptions.CURRENT, OneCallResultOptions.MINUTELY)
|
||||
@@ -91,7 +90,7 @@ public class CurrentWeatherOneCallIntegrationTest extends ApiTest {
|
||||
final CompletableFuture<CurrentWeatherData> currentWeatherDataFuture = getClient()
|
||||
.oneCall()
|
||||
.current()
|
||||
.byCoordinate(Coordinate.of(53.54, 27.34))
|
||||
.byCoordinates(Coordinates.of(53.54, 27.34))
|
||||
.language(Language.ENGLISH)
|
||||
.unitSystem(UnitSystem.METRIC)
|
||||
.retrieveAsync()
|
||||
@@ -106,7 +105,7 @@ public class CurrentWeatherOneCallIntegrationTest extends ApiTest {
|
||||
final CompletableFuture<String> responseJsonFuture = getClient()
|
||||
.oneCall()
|
||||
.current()
|
||||
.byCoordinate(Coordinate.of(53.54, 27.34))
|
||||
.byCoordinates(Coordinates.of(53.54, 27.34))
|
||||
.language(Language.ENGLISH)
|
||||
.unitSystem(UnitSystem.METRIC)
|
||||
.retrieveAsync()
|
||||
@@ -125,7 +124,7 @@ public class CurrentWeatherOneCallIntegrationTest extends ApiTest {
|
||||
client
|
||||
.oneCall()
|
||||
.current()
|
||||
.byCoordinate(Coordinate.of(53.54, 27.34))
|
||||
.byCoordinates(Coordinates.of(53.54, 27.34))
|
||||
.language(Language.ENGLISH)
|
||||
.unitSystem(UnitSystem.METRIC)
|
||||
.retrieve()
|
||||
|
||||
+6
-7
@@ -27,8 +27,7 @@ import com.github.prominence.openweathermap.api.OpenWeatherMapClient;
|
||||
import com.github.prominence.openweathermap.api.enums.Language;
|
||||
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.Coordinates;
|
||||
import com.github.prominence.openweathermap.api.model.onecall.historical.HistoricalWeatherData;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -45,7 +44,7 @@ public class HistoricalWeatherOneCallIntegrationTest extends ApiTest {
|
||||
final HistoricalWeatherData historicalWeatherData = getClient()
|
||||
.oneCall()
|
||||
.historical()
|
||||
.byCoordinateAndTimestamp(Coordinate.of(60.99, 30.9), LocalDateTime.now().minusDays(5).toEpochSecond(ZoneOffset.UTC))
|
||||
.byCoordinateAndTimestamp(Coordinates.of(60.99, 30.9), LocalDateTime.now().minusDays(5).toEpochSecond(ZoneOffset.UTC))
|
||||
.language(Language.ENGLISH)
|
||||
.unitSystem(UnitSystem.METRIC)
|
||||
.retrieve()
|
||||
@@ -59,7 +58,7 @@ public class HistoricalWeatherOneCallIntegrationTest extends ApiTest {
|
||||
final String responseJson = getClient()
|
||||
.oneCall()
|
||||
.historical()
|
||||
.byCoordinateAndTimestamp(Coordinate.of(60.99, 30.9), LocalDateTime.now().minusDays(5).toEpochSecond(ZoneOffset.UTC))
|
||||
.byCoordinateAndTimestamp(Coordinates.of(60.99, 30.9), LocalDateTime.now().minusDays(5).toEpochSecond(ZoneOffset.UTC))
|
||||
.language(Language.ENGLISH)
|
||||
.unitSystem(UnitSystem.METRIC)
|
||||
.retrieve()
|
||||
@@ -75,7 +74,7 @@ public class HistoricalWeatherOneCallIntegrationTest extends ApiTest {
|
||||
final CompletableFuture<HistoricalWeatherData> historicalWeatherDataFuture = getClient()
|
||||
.oneCall()
|
||||
.historical()
|
||||
.byCoordinateAndTimestamp(Coordinate.of(60.99, 30.9), LocalDateTime.now().minusDays(5).toEpochSecond(ZoneOffset.UTC))
|
||||
.byCoordinateAndTimestamp(Coordinates.of(60.99, 30.9), LocalDateTime.now().minusDays(5).toEpochSecond(ZoneOffset.UTC))
|
||||
.language(Language.ENGLISH)
|
||||
.unitSystem(UnitSystem.METRIC)
|
||||
.retrieveAsync()
|
||||
@@ -90,7 +89,7 @@ public class HistoricalWeatherOneCallIntegrationTest extends ApiTest {
|
||||
final CompletableFuture<String> responseJsonFuture = getClient()
|
||||
.oneCall()
|
||||
.historical()
|
||||
.byCoordinateAndTimestamp(Coordinate.of(60.99, 30.9), LocalDateTime.now().minusDays(5).toEpochSecond(ZoneOffset.UTC))
|
||||
.byCoordinateAndTimestamp(Coordinates.of(60.99, 30.9), LocalDateTime.now().minusDays(5).toEpochSecond(ZoneOffset.UTC))
|
||||
.language(Language.ENGLISH)
|
||||
.unitSystem(UnitSystem.METRIC)
|
||||
.retrieveAsync()
|
||||
@@ -109,7 +108,7 @@ public class HistoricalWeatherOneCallIntegrationTest extends ApiTest {
|
||||
client
|
||||
.oneCall()
|
||||
.historical()
|
||||
.byCoordinateAndTimestamp(Coordinate.of(53.54, 27.34), LocalDateTime.now().minusDays(5).toEpochSecond(ZoneOffset.UTC))
|
||||
.byCoordinateAndTimestamp(Coordinates.of(53.54, 27.34), LocalDateTime.now().minusDays(5).toEpochSecond(ZoneOffset.UTC))
|
||||
.language(Language.ENGLISH)
|
||||
.unitSystem(UnitSystem.METRIC)
|
||||
.retrieve()
|
||||
|
||||
+278
-308
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Alexey Zinchenko
|
||||
* Copyright (c) 2022 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
|
||||
@@ -20,288 +20,34 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.github.prominence.openweathermap.api.request.weather.single;
|
||||
package com.github.prominence.openweathermap.api.request.weather;
|
||||
|
||||
import com.github.prominence.openweathermap.api.ApiTest;
|
||||
import com.github.prominence.openweathermap.api.enums.Language;
|
||||
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.Coordinates;
|
||||
import com.github.prominence.openweathermap.api.model.weather.Weather;
|
||||
import com.github.prominence.openweathermap.api.OpenWeatherMapClient;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class SingleResultCurrentWeatherIntegrationTest extends ApiTest {
|
||||
@Test
|
||||
public void whenGetSingleCurrentWeatherByCityNameRequestAsJava_thenReturnNotNull() {
|
||||
final Weather weather = getClient()
|
||||
.currentWeather()
|
||||
.single()
|
||||
.byCityName("Minsk")
|
||||
.language(Language.RUSSIAN)
|
||||
.unitSystem(UnitSystem.METRIC)
|
||||
.retrieve()
|
||||
.asJava();
|
||||
|
||||
assertNotNull(weather);
|
||||
assertNotNull(weather.getWeatherState());
|
||||
assertNotNull(weather.getCalculationTime());
|
||||
assertNotNull(weather.getTemperature());
|
||||
assertNotNull(weather.getLocation());
|
||||
assertNotNull(weather.getAtmosphericPressure());
|
||||
assertNotNull(weather.getHumidity());
|
||||
assertNotNull(weather.getWind());
|
||||
System.out.println(weather);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenGetSingleCurrentWeatherByCityNameRequestAsJSON_thenReturnNotNull() {
|
||||
final String weatherJson = getClient()
|
||||
.currentWeather()
|
||||
.single()
|
||||
.byCityName("Minsk")
|
||||
.language(Language.RUSSIAN)
|
||||
.unitSystem(UnitSystem.IMPERIAL)
|
||||
.retrieve()
|
||||
.asJSON();
|
||||
|
||||
assertTrue(weatherJson.startsWith("{"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenGetSingleCurrentWeatherByCityNameRequestAsXML_thenReturnNotNull() {
|
||||
final String weatherXml = getClient()
|
||||
.currentWeather()
|
||||
.single()
|
||||
.byCityName("Minsk")
|
||||
.language(Language.RUSSIAN)
|
||||
.unitSystem(UnitSystem.STANDARD)
|
||||
.retrieve()
|
||||
.asXML();
|
||||
|
||||
assertTrue(weatherXml.startsWith("<"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenGetSingleCurrentWeatherByCityNameRequestAsHTML_thenReturnNotNull() {
|
||||
final String weatherHtml = getClient()
|
||||
.currentWeather()
|
||||
.single()
|
||||
.byCityName("Minsk")
|
||||
.language(Language.RUSSIAN)
|
||||
.unitSystem(UnitSystem.METRIC)
|
||||
.retrieve()
|
||||
.asHTML();
|
||||
|
||||
assertTrue(weatherHtml.startsWith("<"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenGetSingleCurrentWeatherByCityNameAndCountryCodeRequestAsJava_thenReturnNotNull() {
|
||||
final Weather weather = getClient()
|
||||
.currentWeather()
|
||||
.single()
|
||||
.byCityName("Minsk", "BY")
|
||||
.language(Language.RUSSIAN)
|
||||
.unitSystem(UnitSystem.METRIC)
|
||||
.retrieve()
|
||||
.asJava();
|
||||
|
||||
assertNotNull(weather);
|
||||
assertNotNull(weather.getWeatherState());
|
||||
assertNotNull(weather.getCalculationTime());
|
||||
assertNotNull(weather.getTemperature());
|
||||
assertNotNull(weather.getLocation());
|
||||
assertNotNull(weather.getAtmosphericPressure());
|
||||
assertNotNull(weather.getHumidity());
|
||||
assertNotNull(weather.getWind());
|
||||
System.out.println(weather);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenGetSingleCurrentWeatherByCityNameAndCountryCodeRequestAsJSON_thenReturnNotNull() {
|
||||
final String weatherJson = getClient()
|
||||
.currentWeather()
|
||||
.single()
|
||||
.byCityName("Minsk", "by")
|
||||
.language(Language.RUSSIAN)
|
||||
.unitSystem(UnitSystem.METRIC)
|
||||
.retrieve()
|
||||
.asJSON();
|
||||
|
||||
assertTrue(weatherJson.startsWith("{"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenGetSingleCurrentWeatherByCityNameAndCountryCodeRequestAsXML_thenReturnNotNull() {
|
||||
final String weatherXml = getClient()
|
||||
.currentWeather()
|
||||
.single()
|
||||
.byCityName("Minsk", "by")
|
||||
.language(Language.RUSSIAN)
|
||||
.unitSystem(UnitSystem.METRIC)
|
||||
.retrieve()
|
||||
.asXML();
|
||||
|
||||
assertTrue(weatherXml.startsWith("<"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenGetSingleCurrentWeatherByCityNameAndCountryCodeRequestAsHTML_thenReturnNotNull() {
|
||||
final String weatherHtml = getClient()
|
||||
.currentWeather()
|
||||
.single()
|
||||
.byCityName("Minsk", "by")
|
||||
.language(Language.RUSSIAN)
|
||||
.unitSystem(UnitSystem.STANDARD)
|
||||
.retrieve()
|
||||
.asHTML();
|
||||
|
||||
assertTrue(weatherHtml.startsWith("<"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenGetSingleCurrentWeatherByCityNameAndStateCodeAndCountryCodeRequestAsJava_thenReturnNotNull() {
|
||||
final Weather weather = getClient()
|
||||
.currentWeather()
|
||||
.single()
|
||||
.byCityName("New York", "ny", "us")
|
||||
.language(Language.SLOVAK)
|
||||
.unitSystem(UnitSystem.METRIC)
|
||||
.retrieve()
|
||||
.asJava();
|
||||
|
||||
assertNotNull(weather);
|
||||
assertNotNull(weather.getWeatherState());
|
||||
assertNotNull(weather.getCalculationTime());
|
||||
assertNotNull(weather.getTemperature());
|
||||
assertNotNull(weather.getLocation());
|
||||
assertNotNull(weather.getAtmosphericPressure());
|
||||
assertNotNull(weather.getHumidity());
|
||||
assertNotNull(weather.getWind());
|
||||
System.out.println(weather);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenGetSingleCurrentWeatherByCityNameAndStateCodeAndCountryCodeRequestAsJSON_thenReturnNotNull() {
|
||||
final String weatherJson = getClient()
|
||||
.currentWeather()
|
||||
.single()
|
||||
.byCityName("New York", "ny", "us")
|
||||
.language(Language.HUNGARIAN)
|
||||
.unitSystem(UnitSystem.IMPERIAL)
|
||||
.retrieve()
|
||||
.asJSON();
|
||||
|
||||
assertTrue(weatherJson.startsWith("{"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenGetSingleCurrentWeatherByCityNameAndStateCodeAndCountryCodeRequestAsXML_thenReturnNotNull() {
|
||||
final String weatherXml = getClient()
|
||||
.currentWeather()
|
||||
.single()
|
||||
.byCityName("New York", "ny", "us")
|
||||
.language(Language.ROMANIAN)
|
||||
.unitSystem(UnitSystem.METRIC)
|
||||
.retrieve()
|
||||
.asXML();
|
||||
|
||||
assertTrue(weatherXml.startsWith("<"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenGetSingleCurrentWeatherByCityNameAndStateCodeAndCountryCodeRequestAsHTML_thenReturnNotNull() {
|
||||
final String weatherHtml = getClient()
|
||||
.currentWeather()
|
||||
.single()
|
||||
.byCityName("New York", "ny", "us")
|
||||
.language(Language.ARABIC)
|
||||
.unitSystem(UnitSystem.METRIC)
|
||||
.retrieve()
|
||||
.asHTML();
|
||||
|
||||
assertTrue(weatherHtml.startsWith("<"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenGetSingleCurrentWeatherByCityIdRequestAsJava_thenReturnNotNull() {
|
||||
final Weather weather = getClient()
|
||||
.currentWeather()
|
||||
.single()
|
||||
.byCityId(350001514)
|
||||
.language(Language.GERMAN)
|
||||
.retrieve()
|
||||
.asJava();
|
||||
|
||||
assertNotNull(weather);
|
||||
assertNotNull(weather.getWeatherState());
|
||||
assertNotNull(weather.getCalculationTime());
|
||||
assertNotNull(weather.getTemperature());
|
||||
assertNotNull(weather.getLocation());
|
||||
assertNotNull(weather.getAtmosphericPressure());
|
||||
assertNotNull(weather.getHumidity());
|
||||
assertNotNull(weather.getWind());
|
||||
System.out.println(weather);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenGetSingleCurrentWeatherByCityIdRequestAsJSON_thenReturnNotNull() {
|
||||
final String weatherJson = getClient()
|
||||
.currentWeather()
|
||||
.single()
|
||||
.byCityId(350001514)
|
||||
.language(Language.GERMAN)
|
||||
.retrieve()
|
||||
.asJSON();
|
||||
|
||||
assertTrue(weatherJson.startsWith("{"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenGetSingleCurrentWeatherByCityIdRequestAsXML_thenReturnNotNull() {
|
||||
final String weatherXml = getClient()
|
||||
.currentWeather()
|
||||
.single()
|
||||
.byCityId(350001514)
|
||||
.language(Language.GERMAN)
|
||||
.retrieve()
|
||||
.asXML();
|
||||
|
||||
assertTrue(weatherXml.startsWith("<"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenGetSingleCurrentWeatherByCityIdRequestAsHTML_thenReturnNotNull() {
|
||||
final String weatherHtml = getClient()
|
||||
.currentWeather()
|
||||
.single()
|
||||
.byCityId(350001514)
|
||||
.language(Language.GERMAN)
|
||||
.retrieve()
|
||||
.asXML();
|
||||
|
||||
assertTrue(weatherHtml.startsWith("<"));
|
||||
}
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class CurrentWeatherIntegrationTest extends ApiTest {
|
||||
@Test
|
||||
public void whenGetSingleCurrentWeatherByCoordinateRequestAsJava_thenReturnNotNull() {
|
||||
final Weather weather = getClient()
|
||||
.currentWeather()
|
||||
.single()
|
||||
.byCoordinate(Coordinate.of(5, 5))
|
||||
.byCoordinates(Coordinates.of(5, 5))
|
||||
.unitSystem(UnitSystem.METRIC)
|
||||
.retrieve()
|
||||
.asJava();
|
||||
|
||||
assertNotNull(weather);
|
||||
assertNotNull(weather.getWeatherState());
|
||||
assertNotNull(weather.getWeatherStates());
|
||||
assertNotNull(weather.getCalculationTime());
|
||||
assertNotNull(weather.getTemperature());
|
||||
assertNotNull(weather.getLocation());
|
||||
@@ -315,8 +61,7 @@ public class SingleResultCurrentWeatherIntegrationTest extends ApiTest {
|
||||
public void whenGetSingleCurrentWeatherByCoordinateRequestAsJSON_thenReturnNotNull() {
|
||||
final String weatherJson = getClient()
|
||||
.currentWeather()
|
||||
.single()
|
||||
.byCoordinate(Coordinate.of(5, 5))
|
||||
.byCoordinates(Coordinates.of(5, 5))
|
||||
.unitSystem(UnitSystem.METRIC)
|
||||
.retrieve()
|
||||
.asJSON();
|
||||
@@ -328,8 +73,7 @@ public class SingleResultCurrentWeatherIntegrationTest extends ApiTest {
|
||||
public void whenGetSingleCurrentWeatherByCoordinateRequestAsXML_thenReturnNotNull() {
|
||||
final String weatherXml = getClient()
|
||||
.currentWeather()
|
||||
.single()
|
||||
.byCoordinate(Coordinate.of(5, 5))
|
||||
.byCoordinates(Coordinates.of(5, 5))
|
||||
.unitSystem(UnitSystem.METRIC)
|
||||
.retrieve()
|
||||
.asXML();
|
||||
@@ -341,8 +85,7 @@ public class SingleResultCurrentWeatherIntegrationTest extends ApiTest {
|
||||
public void whenGetSingleCurrentWeatherByCoordinateRequestAsHTML_thenReturnNotNull() {
|
||||
final String weatherHtml = getClient()
|
||||
.currentWeather()
|
||||
.single()
|
||||
.byCoordinate(Coordinate.of(5, 5))
|
||||
.byCoordinates(Coordinates.of(5, 5))
|
||||
.unitSystem(UnitSystem.METRIC)
|
||||
.retrieve()
|
||||
.asHTML();
|
||||
@@ -351,10 +94,262 @@ public class SingleResultCurrentWeatherIntegrationTest extends ApiTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void whenGetSingleCurrentWeatherByCityNameRequestAsJava_thenReturnNotNull() {
|
||||
final Weather weather = getClient()
|
||||
.currentWeather()
|
||||
.byCityName("Minsk")
|
||||
.language(Language.RUSSIAN)
|
||||
.unitSystem(UnitSystem.METRIC)
|
||||
.retrieve()
|
||||
.asJava();
|
||||
|
||||
assertNotNull(weather);
|
||||
assertNotNull(weather.getWeatherStates());
|
||||
assertNotNull(weather.getCalculationTime());
|
||||
assertNotNull(weather.getTemperature());
|
||||
assertNotNull(weather.getLocation());
|
||||
assertNotNull(weather.getAtmosphericPressure());
|
||||
assertNotNull(weather.getHumidity());
|
||||
assertNotNull(weather.getWind());
|
||||
System.out.println(weather);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void whenGetSingleCurrentWeatherByCityNameRequestAsJSON_thenReturnNotNull() {
|
||||
final String weatherJson = getClient()
|
||||
.currentWeather()
|
||||
.byCityName("Minsk")
|
||||
.language(Language.RUSSIAN)
|
||||
.unitSystem(UnitSystem.IMPERIAL)
|
||||
.retrieve()
|
||||
.asJSON();
|
||||
|
||||
assertTrue(weatherJson.startsWith("{"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void whenGetSingleCurrentWeatherByCityNameRequestAsXML_thenReturnNotNull() {
|
||||
final String weatherXml = getClient()
|
||||
.currentWeather()
|
||||
.byCityName("Minsk")
|
||||
.language(Language.RUSSIAN)
|
||||
.unitSystem(UnitSystem.STANDARD)
|
||||
.retrieve()
|
||||
.asXML();
|
||||
|
||||
assertTrue(weatherXml.startsWith("<"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void whenGetSingleCurrentWeatherByCityNameRequestAsHTML_thenReturnNotNull() {
|
||||
final String weatherHtml = getClient()
|
||||
.currentWeather()
|
||||
.byCityName("Minsk")
|
||||
.language(Language.RUSSIAN)
|
||||
.unitSystem(UnitSystem.METRIC)
|
||||
.retrieve()
|
||||
.asHTML();
|
||||
|
||||
assertTrue(weatherHtml.startsWith("<"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void whenGetSingleCurrentWeatherByCityNameAndCountryCodeRequestAsJava_thenReturnNotNull() {
|
||||
final Weather weather = getClient()
|
||||
.currentWeather()
|
||||
.byCityName("Minsk", "BY")
|
||||
.language(Language.RUSSIAN)
|
||||
.unitSystem(UnitSystem.METRIC)
|
||||
.retrieve()
|
||||
.asJava();
|
||||
|
||||
assertNotNull(weather);
|
||||
assertNotNull(weather.getWeatherStates());
|
||||
assertNotNull(weather.getCalculationTime());
|
||||
assertNotNull(weather.getTemperature());
|
||||
assertNotNull(weather.getLocation());
|
||||
assertNotNull(weather.getAtmosphericPressure());
|
||||
assertNotNull(weather.getHumidity());
|
||||
assertNotNull(weather.getWind());
|
||||
System.out.println(weather);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void whenGetSingleCurrentWeatherByCityNameAndCountryCodeRequestAsJSON_thenReturnNotNull() {
|
||||
final String weatherJson = getClient()
|
||||
.currentWeather()
|
||||
.byCityName("Minsk", "by")
|
||||
.language(Language.RUSSIAN)
|
||||
.unitSystem(UnitSystem.METRIC)
|
||||
.retrieve()
|
||||
.asJSON();
|
||||
|
||||
assertTrue(weatherJson.startsWith("{"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void whenGetSingleCurrentWeatherByCityNameAndCountryCodeRequestAsXML_thenReturnNotNull() {
|
||||
final String weatherXml = getClient()
|
||||
.currentWeather()
|
||||
.byCityName("Minsk", "by")
|
||||
.language(Language.RUSSIAN)
|
||||
.unitSystem(UnitSystem.METRIC)
|
||||
.retrieve()
|
||||
.asXML();
|
||||
|
||||
assertTrue(weatherXml.startsWith("<"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void whenGetSingleCurrentWeatherByCityNameAndCountryCodeRequestAsHTML_thenReturnNotNull() {
|
||||
final String weatherHtml = getClient()
|
||||
.currentWeather()
|
||||
.byCityName("Minsk", "by")
|
||||
.language(Language.RUSSIAN)
|
||||
.unitSystem(UnitSystem.STANDARD)
|
||||
.retrieve()
|
||||
.asHTML();
|
||||
|
||||
assertTrue(weatherHtml.startsWith("<"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void whenGetSingleCurrentWeatherByCityNameAndStateCodeAndCountryCodeRequestAsJava_thenReturnNotNull() {
|
||||
final Weather weather = getClient()
|
||||
.currentWeather()
|
||||
.byCityName("New York", "ny", "us")
|
||||
.language(Language.SLOVAK)
|
||||
.unitSystem(UnitSystem.METRIC)
|
||||
.retrieve()
|
||||
.asJava();
|
||||
|
||||
assertNotNull(weather);
|
||||
assertNotNull(weather.getWeatherStates());
|
||||
assertNotNull(weather.getCalculationTime());
|
||||
assertNotNull(weather.getTemperature());
|
||||
assertNotNull(weather.getLocation());
|
||||
assertNotNull(weather.getAtmosphericPressure());
|
||||
assertNotNull(weather.getHumidity());
|
||||
assertNotNull(weather.getWind());
|
||||
System.out.println(weather);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void whenGetSingleCurrentWeatherByCityNameAndStateCodeAndCountryCodeRequestAsJSON_thenReturnNotNull() {
|
||||
final String weatherJson = getClient()
|
||||
.currentWeather()
|
||||
.byCityName("New York", "ny", "us")
|
||||
.language(Language.HUNGARIAN)
|
||||
.unitSystem(UnitSystem.IMPERIAL)
|
||||
.retrieve()
|
||||
.asJSON();
|
||||
|
||||
assertTrue(weatherJson.startsWith("{"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void whenGetSingleCurrentWeatherByCityNameAndStateCodeAndCountryCodeRequestAsXML_thenReturnNotNull() {
|
||||
final String weatherXml = getClient()
|
||||
.currentWeather()
|
||||
.byCityName("New York", "ny", "us")
|
||||
.language(Language.ROMANIAN)
|
||||
.unitSystem(UnitSystem.METRIC)
|
||||
.retrieve()
|
||||
.asXML();
|
||||
|
||||
assertTrue(weatherXml.startsWith("<"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void whenGetSingleCurrentWeatherByCityNameAndStateCodeAndCountryCodeRequestAsHTML_thenReturnNotNull() {
|
||||
final String weatherHtml = getClient()
|
||||
.currentWeather()
|
||||
.byCityName("New York", "ny", "us")
|
||||
.language(Language.ARABIC)
|
||||
.unitSystem(UnitSystem.METRIC)
|
||||
.retrieve()
|
||||
.asHTML();
|
||||
|
||||
assertTrue(weatherHtml.startsWith("<"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void whenGetSingleCurrentWeatherByCityIdRequestAsJava_thenReturnNotNull() {
|
||||
final Weather weather = getClient()
|
||||
.currentWeather()
|
||||
.byCityId(350001514)
|
||||
.language(Language.GERMAN)
|
||||
.retrieve()
|
||||
.asJava();
|
||||
|
||||
assertNotNull(weather);
|
||||
assertNotNull(weather.getWeatherStates());
|
||||
assertNotNull(weather.getCalculationTime());
|
||||
assertNotNull(weather.getTemperature());
|
||||
assertNotNull(weather.getLocation());
|
||||
assertNotNull(weather.getAtmosphericPressure());
|
||||
assertNotNull(weather.getHumidity());
|
||||
assertNotNull(weather.getWind());
|
||||
System.out.println(weather);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void whenGetSingleCurrentWeatherByCityIdRequestAsJSON_thenReturnNotNull() {
|
||||
final String weatherJson = getClient()
|
||||
.currentWeather()
|
||||
.byCityId(350001514)
|
||||
.language(Language.GERMAN)
|
||||
.retrieve()
|
||||
.asJSON();
|
||||
|
||||
assertTrue(weatherJson.startsWith("{"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void whenGetSingleCurrentWeatherByCityIdRequestAsXML_thenReturnNotNull() {
|
||||
final String weatherXml = getClient()
|
||||
.currentWeather()
|
||||
.byCityId(350001514)
|
||||
.language(Language.GERMAN)
|
||||
.retrieve()
|
||||
.asXML();
|
||||
|
||||
assertTrue(weatherXml.startsWith("<"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void whenGetSingleCurrentWeatherByCityIdRequestAsHTML_thenReturnNotNull() {
|
||||
final String weatherHtml = getClient()
|
||||
.currentWeather()
|
||||
.byCityId(350001514)
|
||||
.language(Language.GERMAN)
|
||||
.retrieve()
|
||||
.asXML();
|
||||
|
||||
assertTrue(weatherHtml.startsWith("<"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void whenGetSingleCurrentWeatherByZipCodeAndCountryRequestAsJava_thenReturnNotNull() {
|
||||
final Weather weather = getClient()
|
||||
.currentWeather()
|
||||
.single()
|
||||
.byZipCodeAndCountry("220015", "by")
|
||||
.language(Language.ENGLISH)
|
||||
.unitSystem(UnitSystem.METRIC)
|
||||
@@ -362,7 +357,7 @@ public class SingleResultCurrentWeatherIntegrationTest extends ApiTest {
|
||||
.asJava();
|
||||
|
||||
assertNotNull(weather);
|
||||
assertNotNull(weather.getWeatherState());
|
||||
assertNotNull(weather.getWeatherStates());
|
||||
assertNotNull(weather.getCalculationTime());
|
||||
assertNotNull(weather.getTemperature());
|
||||
assertNotNull(weather.getLocation());
|
||||
@@ -373,10 +368,10 @@ public class SingleResultCurrentWeatherIntegrationTest extends ApiTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void whenGetSingleCurrentWeatherByZipCodeAndCountryRequestAsJSON_thenReturnNotNull() {
|
||||
final String weatherJson = getClient()
|
||||
.currentWeather()
|
||||
.single()
|
||||
.byZipCodeAndCountry("220015", "by")
|
||||
.language(Language.ENGLISH)
|
||||
.unitSystem(UnitSystem.METRIC)
|
||||
@@ -387,10 +382,10 @@ public class SingleResultCurrentWeatherIntegrationTest extends ApiTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void whenGetSingleCurrentWeatherByZipCodeAndCountryRequestAsXML_thenReturnNotNull() {
|
||||
final String weatherXml = getClient()
|
||||
.currentWeather()
|
||||
.single()
|
||||
.byZipCodeAndCountry("220015", "by")
|
||||
.language(Language.ENGLISH)
|
||||
.unitSystem(UnitSystem.METRIC)
|
||||
@@ -401,10 +396,10 @@ public class SingleResultCurrentWeatherIntegrationTest extends ApiTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void whenGetSingleCurrentWeatherByZipCodeAndCountryRequestAsHTML_thenReturnNotNull() {
|
||||
final String weatherHtml = getClient()
|
||||
.currentWeather()
|
||||
.single()
|
||||
.byZipCodeAndCountry("220015", "by")
|
||||
.language(Language.ENGLISH)
|
||||
.unitSystem(UnitSystem.METRIC)
|
||||
@@ -415,10 +410,10 @@ public class SingleResultCurrentWeatherIntegrationTest extends ApiTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void whenGetSingleCurrentWeatherByZipCodeInUSARequestAsJava_thenReturnNotNull() {
|
||||
final Weather weather = getClient()
|
||||
.currentWeather()
|
||||
.single()
|
||||
.byZipCodeInUSA("10006")
|
||||
.language(Language.ENGLISH)
|
||||
.unitSystem(UnitSystem.METRIC)
|
||||
@@ -426,7 +421,7 @@ public class SingleResultCurrentWeatherIntegrationTest extends ApiTest {
|
||||
.asJava();
|
||||
|
||||
assertNotNull(weather);
|
||||
assertNotNull(weather.getWeatherState());
|
||||
assertNotNull(weather.getWeatherStates());
|
||||
assertNotNull(weather.getCalculationTime());
|
||||
assertNotNull(weather.getTemperature());
|
||||
assertNotNull(weather.getLocation());
|
||||
@@ -437,10 +432,10 @@ public class SingleResultCurrentWeatherIntegrationTest extends ApiTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void whenGetSingleCurrentWeatherByZipCodeInUSARequestAsJSON_thenReturnNotNull() {
|
||||
final String weatherJson = getClient()
|
||||
.currentWeather()
|
||||
.single()
|
||||
.byZipCodeInUSA("10006")
|
||||
.language(Language.ENGLISH)
|
||||
.unitSystem(UnitSystem.METRIC)
|
||||
@@ -451,10 +446,10 @@ public class SingleResultCurrentWeatherIntegrationTest extends ApiTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void whenGetSingleCurrentWeatherByZipCodeInUSARequestAsXML_thenReturnNotNull() {
|
||||
final String weatherXml = getClient()
|
||||
.currentWeather()
|
||||
.single()
|
||||
.byZipCodeInUSA("10006")
|
||||
.language(Language.ENGLISH)
|
||||
.unitSystem(UnitSystem.METRIC)
|
||||
@@ -465,10 +460,10 @@ public class SingleResultCurrentWeatherIntegrationTest extends ApiTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void whenGetSingleCurrentWeatherByZipCodeInUSARequestAsHTML_thenReturnNotNull() {
|
||||
final String weatherHtml = getClient()
|
||||
.currentWeather()
|
||||
.single()
|
||||
.byZipCodeInUSA("10006")
|
||||
.language(Language.ENGLISH)
|
||||
.unitSystem(UnitSystem.METRIC)
|
||||
@@ -479,10 +474,10 @@ public class SingleResultCurrentWeatherIntegrationTest extends ApiTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void whenGetAnySingleCurrentWeatherAsyncRequestAsJava_thenReturnNotNull() throws ExecutionException, InterruptedException {
|
||||
final CompletableFuture<Weather> weatherFuture = getClient()
|
||||
.currentWeather()
|
||||
.single()
|
||||
.byZipCodeAndCountry("220015", "by")
|
||||
.language(Language.RUSSIAN)
|
||||
.unitSystem(UnitSystem.METRIC)
|
||||
@@ -494,10 +489,10 @@ public class SingleResultCurrentWeatherIntegrationTest extends ApiTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void whenGetAnySingleCurrentWeatherAsyncRequestAsJson_thenReturnNotNull() throws ExecutionException, InterruptedException {
|
||||
final CompletableFuture<String> weatherFuture = getClient()
|
||||
.currentWeather()
|
||||
.single()
|
||||
.byZipCodeAndCountry("220015", "by")
|
||||
.language(Language.RUSSIAN)
|
||||
.unitSystem(UnitSystem.METRIC)
|
||||
@@ -509,10 +504,10 @@ public class SingleResultCurrentWeatherIntegrationTest extends ApiTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void whenGetAnySingleCurrentWeatherAsyncRequestAsXml_thenReturnNotNull() throws ExecutionException, InterruptedException {
|
||||
final CompletableFuture<String> weatherXmlFuture = getClient()
|
||||
.currentWeather()
|
||||
.single()
|
||||
.byZipCodeAndCountry("220015", "by")
|
||||
.language(Language.RUSSIAN)
|
||||
.unitSystem(UnitSystem.METRIC)
|
||||
@@ -524,10 +519,10 @@ public class SingleResultCurrentWeatherIntegrationTest extends ApiTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void whenGetAnySingleCurrentWeatherAsyncRequestAsHtml_thenReturnNotNull() throws ExecutionException, InterruptedException {
|
||||
final CompletableFuture<String> weatherFuture = getClient()
|
||||
.currentWeather()
|
||||
.single()
|
||||
.byZipCodeAndCountry("220015", "by")
|
||||
.language(Language.RUSSIAN)
|
||||
.unitSystem(UnitSystem.METRIC)
|
||||
@@ -537,29 +532,4 @@ public class SingleResultCurrentWeatherIntegrationTest extends ApiTest {
|
||||
assertNotNull(weatherFuture);
|
||||
System.out.println(weatherFuture.get());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenRequestCurrentWeatherWithInvalidApiKey_thenThrowAnException() {
|
||||
OpenWeatherMapClient client = new OpenWeatherMapClient("invalidKey");
|
||||
assertThrows(InvalidAuthTokenException.class, () ->
|
||||
client
|
||||
.currentWeather()
|
||||
.multiple()
|
||||
.byCitiesInCycle(Coordinate.of(34.53, 66.74), 10)
|
||||
.retrieve()
|
||||
.asJSON()
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenRequestCurrentWeatherForInvalidLocation_thenThrowAnException() {
|
||||
assertThrows(NoDataFoundException.class, () ->
|
||||
getClient()
|
||||
.currentWeather()
|
||||
.multiple()
|
||||
.byCitiesInCycle(Coordinate.of(90.00, 66.74), 10)
|
||||
.retrieve()
|
||||
.asJava()
|
||||
);
|
||||
}
|
||||
}
|
||||
-245
File diff suppressed because one or more lines are too long
-295
@@ -1,295 +0,0 @@
|
||||
/*
|
||||
* 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.request.weather.multiple;
|
||||
|
||||
import com.github.prominence.openweathermap.api.ApiTest;
|
||||
import com.github.prominence.openweathermap.api.enums.Language;
|
||||
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.CoordinateRectangle;
|
||||
import com.github.prominence.openweathermap.api.model.weather.Weather;
|
||||
import com.github.prominence.openweathermap.api.OpenWeatherMapClient;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class MultipleResultCurrentWeatherIntegrationTest extends ApiTest {
|
||||
@Test
|
||||
public void whenGetMultipleCurrentWeatherByCoordinateRectangleRequestAsJava_thenReturnNotNull() {
|
||||
final List<Weather> weatherList = getClient()
|
||||
.currentWeather()
|
||||
.multiple()
|
||||
.byRectangle(
|
||||
new CoordinateRectangle.Builder()
|
||||
.setLongitudeLeft(12)
|
||||
.setLatitudeBottom(32)
|
||||
.setLongitudeRight(15)
|
||||
.setLatitudeTop(37)
|
||||
.build(),
|
||||
10
|
||||
)
|
||||
.language(Language.ROMANIAN)
|
||||
.unitSystem(UnitSystem.METRIC)
|
||||
.retrieve()
|
||||
.asJava();
|
||||
|
||||
assertNotNull(weatherList);
|
||||
for (Weather weather : weatherList) {
|
||||
assertNotNull(weather);
|
||||
assertNotNull(weather.getWeatherState());
|
||||
assertNotNull(weather.getCalculationTime());
|
||||
assertNotNull(weather.getTemperature());
|
||||
assertNotNull(weather.getLocation());
|
||||
assertNotNull(weather.getAtmosphericPressure());
|
||||
assertNotNull(weather.getHumidity());
|
||||
assertNotNull(weather.getWind());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenGetMultipleCurrentWeatherByCoordinateRectangleRequestAsJSON_thenReturnNotNull() {
|
||||
final String weatherJson = getClient()
|
||||
.currentWeather()
|
||||
.multiple()
|
||||
.byRectangle(CoordinateRectangle.withValues(12, 32, 15, 37), 10)
|
||||
.language(Language.ROMANIAN)
|
||||
.unitSystem(UnitSystem.METRIC)
|
||||
.retrieve()
|
||||
.asJSON();
|
||||
|
||||
assertTrue(weatherJson.startsWith("{"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenGetMultipleCurrentWeatherByCoordinateRectangleAsyncRequestAsJava_thenReturnNotNull() throws ExecutionException, InterruptedException {
|
||||
final CompletableFuture<List<Weather>> weatherListFuture = getClient()
|
||||
.currentWeather()
|
||||
.multiple()
|
||||
.byRectangle(CoordinateRectangle.withValues(12, 32, 15, 37), 10)
|
||||
.language(Language.ROMANIAN)
|
||||
.unitSystem(UnitSystem.METRIC)
|
||||
.retrieveAsync()
|
||||
.asJava();
|
||||
|
||||
assertNotNull(weatherListFuture.get());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenGetMultipleCurrentWeatherByCoordinateRectangleAsyncRequestAsJSON_thenReturnNotNull() throws ExecutionException, InterruptedException {
|
||||
final CompletableFuture<String> weatherJsonFuture = getClient()
|
||||
.currentWeather()
|
||||
.multiple()
|
||||
.byRectangle(CoordinateRectangle.withValues(12, 32, 15, 37), 10)
|
||||
.language(Language.ROMANIAN)
|
||||
.unitSystem(UnitSystem.METRIC)
|
||||
.retrieveAsync()
|
||||
.asJSON();
|
||||
|
||||
assertTrue(weatherJsonFuture.get().startsWith("{"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenGetMultipleCurrentWeatherByCitiesInCycleRequestAsJava_thenReturnNotNull() {
|
||||
final List<Weather> weatherList = getClient()
|
||||
.currentWeather()
|
||||
.multiple()
|
||||
.byCitiesInCycle(Coordinate.of(55.5, 37.5))
|
||||
.language(Language.GERMAN)
|
||||
.unitSystem(UnitSystem.IMPERIAL)
|
||||
.retrieve()
|
||||
.asJava();
|
||||
|
||||
assertNotNull(weatherList);
|
||||
for (Weather weather : weatherList) {
|
||||
System.out.println(weather);
|
||||
assertNotNull(weather);
|
||||
assertNotNull(weather.getWeatherState());
|
||||
assertNotNull(weather.getCalculationTime());
|
||||
assertNotNull(weather.getTemperature());
|
||||
assertNotNull(weather.getLocation());
|
||||
assertNotNull(weather.getAtmosphericPressure());
|
||||
assertNotNull(weather.getHumidity());
|
||||
assertNotNull(weather.getWind());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenGetMultipleCurrentWeatherByCitiesInCycleRequestAsJSON_thenReturnNotNull() {
|
||||
final String weatherJson = getClient()
|
||||
.currentWeather()
|
||||
.multiple()
|
||||
.byCitiesInCycle(Coordinate.of(55.5, 37.5))
|
||||
.language(Language.GERMAN)
|
||||
.unitSystem(UnitSystem.IMPERIAL)
|
||||
.retrieve()
|
||||
.asJSON();
|
||||
|
||||
assertTrue(weatherJson.startsWith("{"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenGetMultipleCurrentWeatherByCitiesInCycleRequestAsXML_thenReturnNotNull() {
|
||||
final String weatherXml = getClient()
|
||||
.currentWeather()
|
||||
.multiple()
|
||||
.byCitiesInCycle(Coordinate.of(55.5, 37.5))
|
||||
.language(Language.GERMAN)
|
||||
.unitSystem(UnitSystem.IMPERIAL)
|
||||
.retrieve()
|
||||
.asXML();
|
||||
|
||||
assertTrue(weatherXml.startsWith("<"));
|
||||
System.out.println(weatherXml);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenGetMultipleCurrentWeatherByCitiesInCycleAndCountRequestAsJava_thenReturnNotNull() {
|
||||
final List<Weather> weatherList = getClient()
|
||||
.currentWeather()
|
||||
.multiple()
|
||||
.byCitiesInCycle(Coordinate.of(55.5, 37.5), 10)
|
||||
.language(Language.GERMAN)
|
||||
.unitSystem(UnitSystem.IMPERIAL)
|
||||
.retrieve()
|
||||
.asJava();
|
||||
|
||||
assertNotNull(weatherList);
|
||||
for (Weather weather : weatherList) {
|
||||
System.out.println(weather);
|
||||
assertNotNull(weather);
|
||||
assertNotNull(weather.getWeatherState());
|
||||
assertNotNull(weather.getCalculationTime());
|
||||
assertNotNull(weather.getTemperature());
|
||||
assertNotNull(weather.getLocation());
|
||||
assertNotNull(weather.getAtmosphericPressure());
|
||||
assertNotNull(weather.getHumidity());
|
||||
assertNotNull(weather.getWind());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenGetMultipleCurrentWeatherByCitiesInCycleAndCountRequestAsJSON_thenReturnNotNull() {
|
||||
final String weatherJson = getClient()
|
||||
.currentWeather()
|
||||
.multiple()
|
||||
.byCitiesInCycle(Coordinate.of(55.5, 37.5), 10)
|
||||
.language(Language.GERMAN)
|
||||
.unitSystem(UnitSystem.IMPERIAL)
|
||||
.retrieve()
|
||||
.asJSON();
|
||||
|
||||
assertTrue(weatherJson.startsWith("{"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenGetMultipleCurrentWeatherByCitiesInCycleAndCountRequestAsXML_thenReturnNotNull() {
|
||||
final String weatherXml = getClient()
|
||||
.currentWeather()
|
||||
.multiple()
|
||||
.byCitiesInCycle(Coordinate.of(55.5, 37.5), 10)
|
||||
.language(Language.GERMAN)
|
||||
.unitSystem(UnitSystem.IMPERIAL)
|
||||
.retrieve()
|
||||
.asXML();
|
||||
|
||||
assertTrue(weatherXml.startsWith("<"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenGetMultipleCurrentWeatherByCoordinateAsyncRequestAsJava_thenReturnNotNull() throws ExecutionException, InterruptedException {
|
||||
final CompletableFuture<List<Weather>> weatherListFuture = getClient()
|
||||
.currentWeather()
|
||||
.multiple()
|
||||
.byCitiesInCycle(Coordinate.of(55.5, 37.5), 10)
|
||||
.language(Language.GERMAN)
|
||||
.unitSystem(UnitSystem.IMPERIAL)
|
||||
.retrieveAsync()
|
||||
.asJava();
|
||||
|
||||
assertNotNull(weatherListFuture);
|
||||
List<Weather> weatherList = weatherListFuture.get();
|
||||
assertTrue(weatherList.size() > 0);
|
||||
System.out.println(weatherList);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenGetMultipleCurrentWeatherByCoordinateAsyncRequestAsJson_thenReturnNotNull() throws ExecutionException, InterruptedException {
|
||||
final CompletableFuture<String> weatherFuture = getClient()
|
||||
.currentWeather()
|
||||
.multiple()
|
||||
.byCitiesInCycle(Coordinate.of(55.5, 37.5), 10)
|
||||
.language(Language.GERMAN)
|
||||
.unitSystem(UnitSystem.IMPERIAL)
|
||||
.retrieveAsync()
|
||||
.asJSON();
|
||||
|
||||
assertNotNull(weatherFuture);
|
||||
System.out.println(weatherFuture.get());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenGetMultipleCurrentWeatherByCoordinateAsyncRequestAsXML_thenReturnNotNull() throws ExecutionException, InterruptedException {
|
||||
final CompletableFuture<String> weatherXMLFuture = getClient()
|
||||
.currentWeather()
|
||||
.multiple()
|
||||
.byCitiesInCycle(Coordinate.of(55.5, 37.5), 10)
|
||||
.language(Language.GERMAN)
|
||||
.unitSystem(UnitSystem.IMPERIAL)
|
||||
.retrieveAsync()
|
||||
.asXML();
|
||||
|
||||
assertNotNull(weatherXMLFuture);
|
||||
System.out.println(weatherXMLFuture.get());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenRequestCurrentWeatherWithInvalidApiKey_thenThrowAnException() {
|
||||
OpenWeatherMapClient client = new OpenWeatherMapClient("invalidKey");
|
||||
assertThrows(InvalidAuthTokenException.class, () ->
|
||||
client
|
||||
.currentWeather()
|
||||
.single()
|
||||
.byCityName("London")
|
||||
.retrieve()
|
||||
.asJSON()
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenRequestCurrentWeatherForInvalidLocation_thenThrowAnException() {
|
||||
assertThrows(NoDataFoundException.class, () ->
|
||||
getClient()
|
||||
.currentWeather()
|
||||
.single()
|
||||
.byCityName("InvalidCity")
|
||||
.retrieve()
|
||||
.asJava()
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user