Added unit tests. Removed obsolete API parameter.

This commit is contained in:
2021-03-24 00:04:55 +03:00
parent ae082d41c1
commit ef138d3bfe
27 changed files with 1364 additions and 220 deletions
@@ -20,14 +20,34 @@
* SOFTWARE.
*/
package com.github.prominence.openweathermap.api.model.weather;
/*
* Copyright (c) 2021 Alexey Zinchenko
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.prominence.openweathermap.api.model;
import com.github.prominence.openweathermap.api.model.AtmosphericPressure;
import org.junit.Assert;
import org.junit.Test;
public class AtmosphericPressureUnitTest {
@Test
public void whenCreatePressureWithArgs_thenValueIsSet() {
AtmosphericPressure atmosphericPressure = AtmosphericPressure.forValue(100);
@@ -20,14 +20,34 @@
* SOFTWARE.
*/
package com.github.prominence.openweathermap.api.model.weather;
/*
* Copyright (c) 2021 Alexey Zinchenko
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.prominence.openweathermap.api.model;
import com.github.prominence.openweathermap.api.model.Clouds;
import org.junit.Assert;
import org.junit.Test;
public class CloudsUnitTest {
@Test
public void whenCreateCloudsWithValidArgs_thenValueIsSet() {
Clouds clouds = Clouds.forValue((byte) 100);
@@ -20,14 +20,34 @@
* SOFTWARE.
*/
package com.github.prominence.openweathermap.api.model.weather;
/*
* Copyright (c) 2021 Alexey Zinchenko
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.prominence.openweathermap.api.model;
import com.github.prominence.openweathermap.api.model.CoordinateRectangle;
import org.junit.Assert;
import org.junit.Test;
public class CoordinateRectangleUnitTest {
@Test
public void whenCreateObjectWithValidArgs_thenObjectIsCreated() {
CoordinateRectangle.forValues(44.5, 22.4, 54.4, 22.2);
@@ -20,14 +20,34 @@
* SOFTWARE.
*/
package com.github.prominence.openweathermap.api.model.weather;
/*
* Copyright (c) 2021 Alexey Zinchenko
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.prominence.openweathermap.api.model;
import com.github.prominence.openweathermap.api.model.Coordinate;
import org.junit.Assert;
import org.junit.Test;
public class CoordinateUnitTest {
@Test
public void whenCreateCoordinateWithValidValues_thenObjectCreated() {
Coordinate.forValues(44, 53);
@@ -0,0 +1,34 @@
/*
* Copyright (c) 2021 Alexey Zinchenko
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.prominence.openweathermap.api.model;
import org.junit.Assert;
import org.junit.Test;
public class DayTimeUnitTest {
@Test
public void whenGetValue_thenValueIsPresentAndValid() {
Assert.assertEquals("d", DayTime.DAY.getValue());
Assert.assertEquals("n", DayTime.NIGHT.getValue());
}
}
@@ -20,14 +20,34 @@
* SOFTWARE.
*/
package com.github.prominence.openweathermap.api.model.weather;
/*
* Copyright (c) 2021 Alexey Zinchenko
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.prominence.openweathermap.api.model;
import com.github.prominence.openweathermap.api.model.Humidity;
import org.junit.Assert;
import org.junit.Test;
public class HumidityUnitTest {
@Test
public void whenCreateHumidityWithArgs_thenValueIsSet() {
Humidity humidity = Humidity.forValue((byte) 100);
@@ -20,13 +20,34 @@
* SOFTWARE.
*/
package com.github.prominence.openweathermap.api.model.weather;
/*
* Copyright (c) 2021 Alexey Zinchenko
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.prominence.openweathermap.api.model;
import org.junit.Assert;
import org.junit.Test;
public class TemperatureUnitTest {
@Test
public void whenCreateObjectWithValidArgs_thenObjectIsCreated() {
Temperature.forValue(22.2, "K");
@@ -69,6 +90,18 @@ public class TemperatureUnitTest {
Assert.assertNull(temperature.getMinTemperature());
}
@Test
public void whenSetFeelsLikeTemperature_thenAllIsOk() {
final Temperature temperature = Temperature.forValue(22.2, "K");
temperature.setFeelsLike(22.3);
Assert.assertEquals(22.3, temperature.getFeelsLike(), 0.00001);
temperature.setFeelsLike(null);
Assert.assertNull(temperature.getFeelsLike());
}
@Test
public void whenSetNonNullUnit_thenAllIsOk() {
final Temperature temperature = Temperature.forValue(22.2, "K");
@@ -88,14 +121,22 @@ public class TemperatureUnitTest {
public void whenCallToString_thenAllIsFine() {
final Temperature temperature = Temperature.forValue(22.2, "K");
Assert.assertNotNull(temperature.toString());
Assert.assertNotEquals("", temperature.toString());
temperature.setMinTemperature(11.2);
Assert.assertNotNull(temperature.toString());
Assert.assertNotEquals("", temperature.toString());
temperature.setMaxTemperature(44.3);
Assert.assertNotNull(temperature.toString());
Assert.assertNotEquals("", temperature.toString());
temperature.setFeelsLike(22.4);
Assert.assertNotNull(temperature.toString());
Assert.assertNotEquals("", temperature.toString());
}
@@ -139,5 +180,17 @@ public class TemperatureUnitTest {
two.setUnit("U");
Assert.assertFalse(one.equals(two));
one.setUnit("U");
Assert.assertTrue(one.equals(two));
one.setFeelsLike(22.3);
Assert.assertFalse(one.equals(two));
two.setFeelsLike(22.3);
Assert.assertTrue(one.equals(two));
}
}
@@ -0,0 +1,81 @@
/*
* Copyright (c) 2021 Alexey Zinchenko
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.prominence.openweathermap.api.model.forecast;
import org.junit.Assert;
import org.junit.Test;
import java.util.ArrayList;
public class ForecastUnitTest {
@Test
public void whenLocationIsSet_thenAllIsOk() {
final Forecast forecast = new Forecast();
forecast.setLocation(Location.forValue(2, "asd"));
Assert.assertNotNull(forecast.getLocation());
}
@Test
public void whenWeatherForecastsAreSet_thenAllIsOk() {
final Forecast forecast = new Forecast();
forecast.setWeatherForecasts(new ArrayList<>());
Assert.assertNotNull(forecast.getWeatherForecasts());
}
@Test
public void whenCalculateHashCode_thenAllIsOk() {
final Forecast one = new Forecast();
final Forecast two = new Forecast();
Assert.assertEquals(one.hashCode(), two.hashCode());
one.setLocation(Location.forValue(22, "444"));
Assert.assertNotEquals(one.hashCode(), two.hashCode());
}
@Test
public void whenCheckEquality_thenAllIsOk() {
final Forecast one = new Forecast();
final Forecast two = new Forecast();
Assert.assertTrue(one.equals(one));
Assert.assertFalse(one.equals(null));
Assert.assertTrue(one.equals(two));
Assert.assertFalse(one.equals(new Object()));
one.setLocation(Location.forValue(22, "234"));
Assert.assertFalse(one.equals(two));
two.setLocation(one.getLocation());
Assert.assertTrue(one.equals(two));
one.setWeatherForecasts(new ArrayList<>());
Assert.assertFalse(one.equals(two));
}
}
@@ -0,0 +1,221 @@
/*
* Copyright (c) 2021 Alexey Zinchenko
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.prominence.openweathermap.api.model.forecast;
import com.github.prominence.openweathermap.api.model.Coordinate;
import org.junit.Assert;
import org.junit.Test;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
public class LocationUnitTest {
@Test
public void whenCreateObjectWithValidArgs_thenObjectIsCreated() {
Location.forValue(33, "test");
}
@Test(expected = IllegalArgumentException.class)
public void whenCreateObjectWithoutName_thenThrowAnException() {
Location.forValue(33, null);
}
@Test
public void whenSetId_thenValueIsSet() {
final Location location = Location.forValue(33, "test");
location.setId(55);
Assert.assertEquals(55, location.getId());
}
@Test
public void whenSetName_thenValueIsSet() {
final Location location = Location.forValue(33, "test");
location.setName("city");
Assert.assertEquals("city", location.getName());
}
@Test
public void whenSetCountryCode_thenValueIsSet() {
final Location location = Location.forValue(33, "test");
location.setCountryCode("by");
Assert.assertEquals("by", location.getCountryCode());
}
@Test
public void whenSetSunrise_thenValueIsSet() {
final Location location = Location.forValue(33, "test");
final LocalDateTime now = LocalDateTime.now();
location.setSunrise(now);
Assert.assertEquals(now, location.getSunrise());
}
@Test
public void whenSetSunset_thenValueIsSet() {
final Location location = Location.forValue(33, "test");
final LocalDateTime now = LocalDateTime.now();
location.setSunset(now);
Assert.assertEquals(now, location.getSunset());
}
@Test
public void whenSetZoneOffset_thenValueIsSet() {
final Location location = Location.forValue(33, "test");
final ZoneOffset offset = ZoneOffset.UTC;
location.setZoneOffset(offset);
Assert.assertEquals(offset, location.getZoneOffset());
}
@Test
public void whenSetCoordinate_thenValueIsSet() {
final Location location = Location.forValue(33, "test");
final Coordinate coordinate = Coordinate.forValues(33.2, 64.2);
location.setCoordinate(coordinate);
Assert.assertEquals(coordinate, location.getCoordinate());
}
@Test
public void whenSetPopulation_thenValueIsSet() {
final Location location = Location.forValue(33, "test");
location.setPopulation(3444L);
Assert.assertEquals(3444L, location.getPopulation().longValue());
}
@Test
public void whenCallToString_thenAllIsFine() {
final Location location = Location.forValue(44, "test");
Assert.assertNotEquals("", location.toString());
location.setCoordinate(Coordinate.forValues(33.2, 56.3));
Assert.assertNotEquals("", location.toString());
location.setCountryCode("TN");
Assert.assertNotEquals("", location.toString());
Assert.assertNotNull(location.toString());
location.setPopulation(34343L);
Assert.assertNotEquals("", location.toString());
Assert.assertNotNull(location.toString());
}
@Test
public void whenCallHashCode_thenAllIsFine() {
final Location one = Location.forValue(44, "test");
final Location two = Location.forValue(44, "test");
Assert.assertEquals(one.hashCode(), two.hashCode());
two.setName("112");
Assert.assertNotEquals(one.hashCode(), two.hashCode());
}
@Test
public void whenCheckEquality_thenAllIsFine() {
final Location one = Location.forValue(44, "test");
final Location two = Location.forValue(44, "test");
Assert.assertTrue(one.equals(one));
Assert.assertFalse(one.equals(new Object()));
Assert.assertTrue(one.equals(two));
two.setId(23);
Assert.assertFalse(one.equals(two));
one.setId(23);
Assert.assertTrue(one.equals(two));
one.setName("23");
Assert.assertFalse(one.equals(two));
two.setName("23");
Assert.assertTrue(one.equals(two));
one.setCountryCode("11");
Assert.assertFalse(one.equals(two));
two.setCountryCode("11");
Assert.assertTrue(one.equals(two));
final LocalDateTime now = LocalDateTime.now();
one.setSunrise(now);
Assert.assertFalse(one.equals(two));
two.setSunrise(now);
Assert.assertTrue(one.equals(two));
one.setSunset(now);
Assert.assertFalse(one.equals(two));
two.setSunset(now);
Assert.assertTrue(one.equals(two));
one.setZoneOffset(ZoneOffset.UTC);
Assert.assertFalse(one.equals(two));
two.setZoneOffset(ZoneOffset.UTC);
Assert.assertTrue(one.equals(two));
final Coordinate coordinate = Coordinate.forValues(33.5, -22.4);
one.setCoordinate(coordinate);
Assert.assertFalse(one.equals(two));
two.setCoordinate(coordinate);
Assert.assertTrue(one.equals(two));
one.setPopulation(20000L);
Assert.assertFalse(one.equals(two));
two.setPopulation(20000L);
Assert.assertTrue(one.equals(two));
}
}
@@ -0,0 +1,96 @@
/*
* Copyright (c) 2021 Alexey Zinchenko
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.prominence.openweathermap.api.model.forecast;
import org.junit.Assert;
import org.junit.Test;
public class RainUnitTest {
@Test
public void whenCreateRainWithValidArgs_thenObjectIsCreated() {
new Rain(2222.3);
new Rain(null);
}
@Test
public void whenSetValues_thenTheyAreSet() {
final Rain rain = new Rain(null);
Assert.assertNull(rain.getThreeHourRainLevel());
rain.setThreeHourRainLevel(55.5);
Assert.assertEquals(55.5, rain.getThreeHourRainLevel(), 0.00001);
}
@Test
public void whenCallToString_thenAllIsFine() {
final Rain rain = new Rain();
Assert.assertNotNull(rain.toString());
Assert.assertEquals("unknown", rain.toString());
rain.setThreeHourRainLevel(33.5);
Assert.assertNotNull(rain.toString());
Assert.assertNotEquals("unknown", rain.toString());
rain.setThreeHourRainLevel(null);
Assert.assertNotNull(rain.toString());
Assert.assertEquals("unknown", rain.toString());
}
@Test
public void whenCallHashCode_thenAllIsFine() {
final Rain first = new Rain();
final Rain second = new Rain();
Assert.assertEquals(first.hashCode(), second.hashCode());
second.setThreeHourRainLevel(11.0);
Assert.assertNotEquals(first.hashCode(), second.hashCode());
first.setThreeHourRainLevel(11.0);
Assert.assertEquals(first.hashCode(), second.hashCode());
}
@Test
public void whenCheckEquality_thenAllIsFine() {
final Rain first = new Rain();
final Rain second = new Rain();
Assert.assertTrue(first.equals(second));
Assert.assertTrue(first.equals(first));
Assert.assertFalse(first.equals(new Object()));
second.setThreeHourRainLevel(66.7);
Assert.assertFalse(first.equals(second));
first.setThreeHourRainLevel(66.7);
Assert.assertTrue(first.equals(second));
}
}
@@ -0,0 +1,96 @@
/*
* Copyright (c) 2021 Alexey Zinchenko
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.prominence.openweathermap.api.model.forecast;
import org.junit.Assert;
import org.junit.Test;
public class SnowUnitTest {
@Test
public void whenCreateSnowWithValidArgs_ObjectIsCreated() {
new Snow(2222.3);
new Snow(null);
}
@Test
public void whenSetValues_thenTheyAreSet() {
final Snow snow = new Snow(null);
Assert.assertNull(snow.getThreeHourSnowLevel());
snow.setThreeHourSnowLevel(55.5);
Assert.assertEquals(55.5, snow.getThreeHourSnowLevel(), 0.00001);
}
@Test
public void whenCallToString_thenAllIsFine() {
final Snow snow = new Snow();
Assert.assertNotNull(snow.toString());
Assert.assertEquals("unknown", snow.toString());
snow.setThreeHourSnowLevel(33.5);
Assert.assertNotNull(snow.toString());
Assert.assertNotEquals("unknown", snow.toString());
snow.setThreeHourSnowLevel(null);
Assert.assertNotNull(snow.toString());
Assert.assertEquals("unknown", snow.toString());
}
@Test
public void whenCallHashCode_thenAllIsFine() {
final Snow first = new Snow();
final Snow second = new Snow();
Assert.assertEquals(first.hashCode(), second.hashCode());
second.setThreeHourSnowLevel(11.0);
Assert.assertNotEquals(first.hashCode(), second.hashCode());
first.setThreeHourSnowLevel(11.0);
Assert.assertEquals(first.hashCode(), second.hashCode());
}
@Test
public void whenCheckEquality_thenAllIsFine() {
final Snow first = new Snow();
final Snow second = new Snow();
Assert.assertTrue(first.equals(second));
Assert.assertTrue(first.equals(first));
Assert.assertFalse(first.equals(new Object()));
second.setThreeHourSnowLevel(66.7);
Assert.assertFalse(first.equals(second));
first.setThreeHourSnowLevel(66.7);
Assert.assertTrue(first.equals(second));
}
}
@@ -0,0 +1,383 @@
/*
* Copyright (c) 2021 Alexey Zinchenko
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/*
* Copyright (c) 2021 Alexey Zinchenko
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.prominence.openweathermap.api.model.forecast;
import com.github.prominence.openweathermap.api.model.*;
import org.junit.Assert;
import org.junit.Test;
import java.time.LocalDateTime;
public class WeatherForecastUnitTest {
@Test
public void whenCreateObjectWithValidArgs_thenObjectIsCreated() {
WeatherForecast.forValue("state", "desc");
}
@Test(expected = IllegalArgumentException.class)
public void whenCreateObjectWithoutState_thenThrowAnException() {
WeatherForecast.forValue(null, "desc");
}
@Test(expected = IllegalArgumentException.class)
public void whenCreateObjectWithoutDescription_thenThrowAnException() {
WeatherForecast.forValue("state", null);
}
@Test
public void whenSetState_thenValueIsSet() {
final WeatherForecast weatherForecast = WeatherForecast.forValue("state", "desc");
weatherForecast.setState("test");
Assert.assertEquals("test", weatherForecast.getState());
}
@Test(expected = IllegalArgumentException.class)
public void whenSetNullState_thenThrowAnException() {
final WeatherForecast weather = WeatherForecast.forValue("state", "desc");
weather.setState(null);
}
@Test
public void whenSetDescription_thenValueIsSet() {
final WeatherForecast weatherForecast = WeatherForecast.forValue("state", "desc");
weatherForecast.setDescription("test");
Assert.assertEquals("test", weatherForecast.getDescription());
}
@Test(expected = IllegalArgumentException.class)
public void whenSetNullDescription_thenThrowAnException() {
final WeatherForecast weatherForecast = WeatherForecast.forValue("state", "desc");
weatherForecast.setDescription(null);
}
@Test
public void whenSetIconUrl_thenValueIsSet() {
final WeatherForecast weatherForecast = WeatherForecast.forValue("state", "desc");
weatherForecast.setWeatherIconUrl("test");
Assert.assertEquals("test", weatherForecast.getWeatherIconUrl());
}
@Test
public void whenSetForecastTime_thenValueIsSet() {
final WeatherForecast weatherForecast = WeatherForecast.forValue("state", "desc");
final LocalDateTime now = LocalDateTime.now();
weatherForecast.setForecastTime(now);
Assert.assertEquals(now, weatherForecast.getForecastTime());
}
@Test
public void whenSetTemperature_thenValueIsSet() {
final WeatherForecast weatherForecast = WeatherForecast.forValue("state", "desc");
final Temperature temperature = Temperature.forValue(22.3, "a");
weatherForecast.setTemperature(temperature);
Assert.assertEquals(temperature, weatherForecast.getTemperature());
}
@Test
public void whenSetPressure_thenValueIsSet() {
final WeatherForecast weatherForecast = WeatherForecast.forValue("state", "desc");
final AtmosphericPressure atmosphericPressure = AtmosphericPressure.forValue(33.2);
weatherForecast.setAtmosphericPressure(atmosphericPressure);
Assert.assertEquals(atmosphericPressure, weatherForecast.getAtmosphericPressure());
}
@Test
public void whenSetHumidity_thenValueIsSet() {
final WeatherForecast weatherForecast = WeatherForecast.forValue("state", "desc");
final Humidity humidity = Humidity.forValue((byte) 44);
weatherForecast.setHumidity(humidity);
Assert.assertEquals(humidity, weatherForecast.getHumidity());
}
@Test
public void whenSetWind_thenValueIsSet() {
final WeatherForecast weatherForecast = WeatherForecast.forValue("state", "desc");
final Wind wind = Wind.forValue(22.2, "a");
weatherForecast.setWind(wind);
Assert.assertEquals(wind, weatherForecast.getWind());
}
@Test
public void whenSetRain_thenValueIsSet() {
final WeatherForecast weatherForecast = WeatherForecast.forValue("state", "desc");
final Rain rain = new Rain();
weatherForecast.setRain(rain);
Assert.assertEquals(rain, weatherForecast.getRain());
}
@Test
public void whenSetSnow_thenValueIsSet() {
final WeatherForecast weatherForecast = WeatherForecast.forValue("state", "desc");
final Snow snow = new Snow();
weatherForecast.setSnow(snow);
Assert.assertEquals(snow, weatherForecast.getSnow());
}
@Test
public void whenSetClouds_thenValueIsSet() {
final WeatherForecast weatherForecast = WeatherForecast.forValue("state", "desc");
final Clouds clouds = Clouds.forValue((byte) 33);
weatherForecast.setClouds(clouds);
Assert.assertEquals(clouds, weatherForecast.getClouds());
}
@Test
public void whenSetForecastTimeISO_thenValueIsSet() {
final WeatherForecast weatherForecast = WeatherForecast.forValue("state", "desc");
Assert.assertNull(weatherForecast.getForecastTimeISO());
weatherForecast.setForecastTimeISO("1994-2-3");
Assert.assertEquals("1994-2-3", weatherForecast.getForecastTimeISO());
}
@Test
public void whenSetDayTime_thenValueIsSet() {
final WeatherForecast weatherForecast = WeatherForecast.forValue("state", "desc");
Assert.assertNull(weatherForecast.getDayTime());
weatherForecast.setDayTime(DayTime.DAY);
Assert.assertEquals(DayTime.DAY, weatherForecast.getDayTime());
}
@Test
public void whenCallToString_thenAllIsFine() {
final WeatherForecast weatherForecast = WeatherForecast.forValue("state", "desc");
final Location location = Location.forValue(12312, "asd");
final Temperature temperature = Temperature.forValue(33.2, "asd");
final AtmosphericPressure atmosphericPressure = AtmosphericPressure.forValue(44.4);
final Clouds clouds = Clouds.forValue((byte) 55);
final Rain rain = new Rain(33.2);
final Snow snow = new Snow(33.1);
Assert.assertNotEquals("", weatherForecast.toString());
Assert.assertNotNull(weatherForecast.toString());
location.setCountryCode("3d");
Assert.assertNotEquals("", weatherForecast.toString());
Assert.assertNotNull(weatherForecast.toString());
weatherForecast.setTemperature(temperature);
Assert.assertNotEquals("", weatherForecast.toString());
Assert.assertNotNull(weatherForecast.toString());
weatherForecast.setAtmosphericPressure(atmosphericPressure);
Assert.assertNotEquals("", weatherForecast.toString());
Assert.assertNotNull(weatherForecast.toString());
weatherForecast.setClouds(clouds);
Assert.assertNotEquals("", weatherForecast.toString());
Assert.assertNotNull(weatherForecast.toString());
weatherForecast.setRain(rain);
Assert.assertNotEquals("", weatherForecast.toString());
Assert.assertNotNull(weatherForecast.toString());
weatherForecast.setSnow(snow);
Assert.assertNotEquals("", weatherForecast.toString());
Assert.assertNotNull(weatherForecast.toString());
weatherForecast.setRain(null);
Assert.assertNotEquals("", weatherForecast.toString());
Assert.assertNotNull(weatherForecast.toString());
weatherForecast.setSnow(null);
Assert.assertNotEquals("", weatherForecast.toString());
Assert.assertNotNull(weatherForecast.toString());
weatherForecast.setRain(new Rain(null));
Assert.assertNotEquals("", weatherForecast.toString());
Assert.assertNotNull(weatherForecast.toString());
weatherForecast.setSnow(new Snow(null));
Assert.assertNotEquals("", weatherForecast.toString());
Assert.assertNotNull(weatherForecast.toString());
}
@Test
public void whenCallHashCode_thenAllIsFine() {
final WeatherForecast one = WeatherForecast.forValue("state", "desc");
final WeatherForecast two = WeatherForecast.forValue("state", "desc");
Assert.assertEquals(one.hashCode(), two.hashCode());
two.setDescription("112");
Assert.assertNotEquals(one.hashCode(), two.hashCode());
}
@Test
public void whenCheckEquality_thenAllIsFine() {
final WeatherForecast one = WeatherForecast.forValue("state", "desc");
final WeatherForecast two = WeatherForecast.forValue("state1", "desc1");
Assert.assertTrue(one.equals(one));
Assert.assertFalse(one.equals(null));
Assert.assertFalse(one.equals(new Object()));
Assert.assertFalse(one.equals(two));
two.setState("state");
Assert.assertFalse(one.equals(two));
two.setDescription("desc");
Assert.assertTrue(one.equals(two));
one.setWeatherIconUrl("1");
Assert.assertFalse(one.equals(two));
two.setWeatherIconUrl("1");
Assert.assertTrue(one.equals(two));
final LocalDateTime now = LocalDateTime.now();
one.setForecastTime(now);
Assert.assertFalse(one.equals(two));
two.setForecastTime(now);
Assert.assertTrue(one.equals(two));
final Temperature temperature = Temperature.forValue(33.2, "as");
one.setTemperature(temperature);
Assert.assertFalse(one.equals(two));
two.setTemperature(temperature);
Assert.assertTrue(one.equals(two));
final AtmosphericPressure atmosphericPressure = AtmosphericPressure.forValue(33.33);
one.setAtmosphericPressure(atmosphericPressure);
Assert.assertFalse(one.equals(two));
two.setAtmosphericPressure(atmosphericPressure);
Assert.assertTrue(one.equals(two));
final Humidity humidity = Humidity.forValue((byte) 33);
one.setHumidity(humidity);
Assert.assertFalse(one.equals(two));
two.setHumidity(humidity);
Assert.assertTrue(one.equals(two));
final Wind wind = Wind.forValue(33.6, "asd");
one.setWind(wind);
Assert.assertFalse(one.equals(two));
two.setWind(wind);
Assert.assertTrue(one.equals(two));
final Rain rain = new Rain();
one.setRain(rain);
Assert.assertFalse(one.equals(two));
two.setRain(rain);
Assert.assertTrue(one.equals(two));
final Snow snow = new Snow();
one.setSnow(snow);
Assert.assertFalse(one.equals(two));
two.setSnow(snow);
Assert.assertTrue(one.equals(two));
final Clouds clouds = Clouds.forValue((byte) 33);
one.setClouds(clouds);
Assert.assertFalse(one.equals(two));
two.setClouds(clouds);
Assert.assertTrue(one.equals(two));
one.setForecastTimeISO("test");
Assert.assertFalse(one.equals(two));
two.setForecastTimeISO("test");
Assert.assertTrue(one.equals(two));
one.setDayTime(DayTime.NIGHT);
Assert.assertFalse(one.equals(two));
two.setDayTime(DayTime.DAY);
Assert.assertFalse(one.equals(two));
one.setDayTime(DayTime.DAY);
Assert.assertTrue(one.equals(two));
}
}
@@ -0,0 +1,179 @@
/*
* Copyright (c) 2021 Alexey Zinchenko
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.prominence.openweathermap.api.model.forecast;
import org.junit.Assert;
import org.junit.Test;
public class WindUnitTest {
@Test
public void whenCreateWindWithValidArgs_thenValueIsSet() {
Assert.assertEquals(44.0, Wind.forValue(44, "ms").getSpeed(), 0.00001);
}
@Test(expected = IllegalArgumentException.class)
public void whenCreateWindWithInvalidSpeedArg_thenThrowAnException() {
Wind.forValue(-21, "a");
}
@Test(expected = IllegalArgumentException.class)
public void whenCreateWindWithInvalidUnitArg_thenThrowAnException() {
Wind.forValue(342, null);
}
@Test
public void whenSetValidSpeed_thenValueIsSet() {
final Wind wind = Wind.forValue(33, "as");
Assert.assertEquals(33, wind.getSpeed(), 0.00001);
wind.setSpeed(0);
Assert.assertEquals(0, wind.getSpeed(), 0.00001);
wind.setSpeed(3656);
Assert.assertEquals(3656, wind.getSpeed(), 0.00001);
}
@Test(expected = IllegalArgumentException.class)
public void whenSetInvalidSpeedBelow0_thenThrowAnException() {
final Wind wind = Wind.forValue(33, "as");
Assert.assertEquals(33, wind.getSpeed(), 0.00001);
wind.setSpeed(-22);
}
@Test
public void whenSetValidDegrees_thenValueIsSet() {
final Wind wind = Wind.forValue(33, "as");
Assert.assertNull(wind.getDegrees());
wind.setDegrees(22);
Assert.assertEquals(22, wind.getDegrees(), 0.00001);
wind.setDegrees(0);
Assert.assertEquals(0, wind.getDegrees(), 0.00001);
wind.setDegrees(360);
Assert.assertEquals(360, wind.getDegrees(), 0.00001);
}
@Test(expected = IllegalArgumentException.class)
public void whenSetInvalidDegreesBelow0_thenThrowAnException() {
final Wind wind = Wind.forValue(33, "as");
wind.setDegrees(-32);
}
@Test(expected = IllegalArgumentException.class)
public void whenSetInvalidDegreesAbove360_thenThrowAnException() {
final Wind wind = Wind.forValue(33, "as");
wind.setDegrees(378);
}
@Test
public void whenSetNonNullUnit_thenValueIsSet() {
final Wind wind = Wind.forValue(33, "as");
Assert.assertEquals(wind.getUnit(), "as");
wind.setUnit("myUnit");
Assert.assertEquals(wind.getUnit(), "myUnit");
}
@Test(expected = IllegalArgumentException.class)
public void whenSetNullUnit_thenThrowAnException() {
final Wind wind = Wind.forValue(33, "as");
wind.setUnit(null);
}
@Test
public void whenCallToString_thenAllIsFine() {
final Wind wind = Wind.forValue(302, "a");
Assert.assertNotNull(wind.toString());
wind.setDegrees(22);
Assert.assertNotNull(wind.toString());
Assert.assertNotEquals("", wind.toString());
}
@Test
public void whenCallHashCode_thenAllIsFine() {
final Wind first = Wind.forValue(22, "a");
final Wind second = Wind.forValue(22, "b");
Assert.assertNotEquals(first.hashCode(), second.hashCode());
second.setUnit("a");
Assert.assertEquals(first.hashCode(), second.hashCode());
second.setSpeed(33);
Assert.assertNotEquals(first.hashCode(), second.hashCode());
first.setSpeed(333);
Assert.assertNotEquals(first.hashCode(), second.hashCode());
first.setSpeed(33);
Assert.assertEquals(first.hashCode(), second.hashCode());
}
@Test
public void whenCheckEquality_thenAllIsFine() {
final Wind first = Wind.forValue(11, "a");
final Wind second = Wind.forValue(11, "a");
Assert.assertTrue(first.equals(second));
Assert.assertTrue(first.equals(first));
Assert.assertFalse(first.equals(new Object()));
first.setDegrees(34);
Assert.assertFalse(first.equals(second));
second.setDegrees(34);
Assert.assertTrue(first.equals(second));
second.setUnit("v");
Assert.assertFalse(first.equals(second));
first.setUnit("v");
first.setSpeed(second.getSpeed() + 4);
Assert.assertFalse(first.equals(second));
}
}
@@ -30,7 +30,6 @@ import java.time.LocalDateTime;
import java.time.ZoneOffset;
public class LocationUnitTest {
@Test
public void whenCreateObjectWithValidArgs_thenObjectIsCreated() {
Location.forValue(33, "test");
@@ -26,7 +26,6 @@ import org.junit.Assert;
import org.junit.Test;
public class RainUnitTest {
@Test
public void whenCreateRainWithValidArgs_thenObjectIsCreated() {
new Rain(2222.3, 324234.3);
@@ -26,7 +26,6 @@ import org.junit.Assert;
import org.junit.Test;
public class SnowUnitTest {
@Test
public void whenCreateSnowWithValidArgs_ObjectIsCreated() {
new Snow(2222.3, 324234.3);
@@ -25,13 +25,13 @@ package com.github.prominence.openweathermap.api.model.weather;
import com.github.prominence.openweathermap.api.model.AtmosphericPressure;
import com.github.prominence.openweathermap.api.model.Clouds;
import com.github.prominence.openweathermap.api.model.Humidity;
import com.github.prominence.openweathermap.api.model.Temperature;
import org.junit.Assert;
import org.junit.Test;
import java.time.LocalDateTime;
public class WeatherUnitTest {
@Test
public void whenCreateObjectWithValidArgs_thenObjectIsCreated() {
Weather.forValue("state", "desc");
@@ -114,6 +114,22 @@ public class WindUnitTest {
wind.setUnit(null);
}
@Test(expected = IllegalArgumentException.class)
public void whenSetInvalidGustValue_thenThrowAnException() {
final Wind wind = Wind.forValue(33, "as");
wind.setGust(-50);
}
@Test
public void whenSetValidGustValue_thenAllIsFine() {
final Wind wind = Wind.forValue(33, "as");
wind.setGust(30);
Assert.assertEquals(30, wind.getGust(), 0.00001);
}
@Test
public void whenCallToString_thenAllIsFine() {
final Wind wind = Wind.forValue(302, "a");
@@ -124,6 +140,10 @@ public class WindUnitTest {
Assert.assertNotNull(wind.toString());
Assert.assertNotEquals("", wind.toString());
wind.setGust(20);
Assert.assertNotNull(wind.toString());
Assert.assertNotEquals("", wind.toString());
}
@Test
@@ -172,8 +192,15 @@ public class WindUnitTest {
Assert.assertFalse(first.equals(second));
first.setUnit("v");
first.setSpeed(second.getSpeed() + 4);
Assert.assertTrue(first.equals(second));
first.setGust(4);
Assert.assertFalse(first.equals(second));
second.setGust(4);
Assert.assertTrue(first.equals(second));
}
}
@@ -61,7 +61,7 @@ public class MultipleResultCurrentWeatherIntegrationTest extends ApiTest {
final List<Weather> weatherList = getClient()
.currentWeather()
.multiple()
.byRectangle(CoordinateRectangle.forValues(12, 32, 15, 37), 10, true)
.byRectangle(CoordinateRectangle.forValues(12, 32, 15, 37), 10)
.language(Language.ROMANIAN)
.unitSystem(UnitSystem.METRIC)
.retrieve()
@@ -73,7 +73,7 @@ public class MultipleResultCurrentWeatherIntegrationTest extends ApiTest {
}
@Test
public void whenGetMultipleCurrentWeatherByCitiesInCycleRequestAsJava_thenReturnNotNull() {
public void whenGetMultipleCurrentWeatherByCitiesInCycleAndCountRequestAsJava_thenReturnNotNull() {
final List<Weather> weatherList = getClient()
.currentWeather()
.multiple()
@@ -89,11 +89,11 @@ public class MultipleResultCurrentWeatherIntegrationTest extends ApiTest {
}
@Test
public void whenGetMultipleCurrentWeatherByCitiesInCycleAndServerClusteringRequestAsJava_thenReturnNotNull() {
public void whenGetMultipleCurrentWeatherByCitiesInCycleRequestAsJava_thenReturnNotNull() {
final List<Weather> weatherList = getClient()
.currentWeather()
.multiple()
.byCitiesInCycle(Coordinate.forValues(55.5, 37.5), 10, true)
.byCitiesInCycle(Coordinate.forValues(55.5, 37.5))
.language(Language.GERMAN)
.unitSystem(UnitSystem.IMPERIAL)
.retrieve()
@@ -154,7 +154,7 @@ public class MultipleResultCurrentWeatherIntegrationTest extends ApiTest {
final CompletableFuture<List<Weather>> weatherListFuture = getClient()
.currentWeather()
.multiple()
.byCitiesInCycle(Coordinate.forValues(55.5, 37.5), 10, true)
.byCitiesInCycle(Coordinate.forValues(55.5, 37.5), 10)
.language(Language.GERMAN)
.unitSystem(UnitSystem.IMPERIAL)
.retrieveAsync()
@@ -171,7 +171,7 @@ public class MultipleResultCurrentWeatherIntegrationTest extends ApiTest {
final CompletableFuture<String> weatherFuture = getClient()
.currentWeather()
.multiple()
.byCitiesInCycle(Coordinate.forValues(55.5, 37.5), 10, true)
.byCitiesInCycle(Coordinate.forValues(55.5, 37.5), 10)
.language(Language.GERMAN)
.unitSystem(UnitSystem.IMPERIAL)
.retrieveAsync()
@@ -186,7 +186,7 @@ public class MultipleResultCurrentWeatherIntegrationTest extends ApiTest {
final CompletableFuture<String> weatherFuture = getClient()
.currentWeather()
.multiple()
.byCitiesInCycle(Coordinate.forValues(55.5, 37.5), 10, true)
.byCitiesInCycle(Coordinate.forValues(55.5, 37.5), 10)
.language(Language.GERMAN)
.unitSystem(UnitSystem.IMPERIAL)
.retrieveAsync()
@@ -201,7 +201,7 @@ public class MultipleResultCurrentWeatherIntegrationTest extends ApiTest {
final CompletableFuture<String> weatherFuture = getClient()
.currentWeather()
.multiple()
.byCitiesInCycle(Coordinate.forValues(55.5, 37.5), 10, true)
.byCitiesInCycle(Coordinate.forValues(55.5, 37.5), 10)
.language(Language.GERMAN)
.unitSystem(UnitSystem.IMPERIAL)
.retrieveAsync()