Tests refactoring. Got rid of 'assert 'statement.

This commit is contained in:
2021-03-23 01:56:08 +03:00
parent 5d6b8c4d97
commit 930776f5c2
38 changed files with 930 additions and 808 deletions
@@ -0,0 +1,128 @@
/*
* Copyright (c) 2021 Alexey Zinchenko
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.prominence.openweathermap.api.model.weather;
import com.github.prominence.openweathermap.api.model.AtmosphericPressure;
import org.junit.Assert;
import org.junit.Test;
public class AtmosphericPressureUnitTest {
@Test
public void whenCreatePressureWithArgs_thenValueIsSet() {
AtmosphericPressure atmosphericPressure = AtmosphericPressure.forValue(100);
Assert.assertEquals(100, atmosphericPressure.getValue(), 0.00001);
Assert.assertEquals(0, AtmosphericPressure.forValue(0).getValue(), 0.00001);
Assert.assertEquals(100, AtmosphericPressure.forValue(100).getValue(), 0.00001);
Assert.assertEquals(55, AtmosphericPressure.forValue(55).getValue(), 0.00001);
}
@Test
public void whenCreateTwoIdenticalInstances_thenWheyAreEquals() {
AtmosphericPressure one = AtmosphericPressure.forValue(22);
AtmosphericPressure two = AtmosphericPressure.forValue(22);
Assert.assertTrue(one.equals(two));
Assert.assertTrue(one.equals(one));
Assert.assertEquals(one.hashCode(), two.hashCode());
one.setSeaLevelValue(333);
one.setGroundLevelValue(555);
two.setSeaLevelValue(333);
two.setGroundLevelValue(555);
Assert.assertTrue(one.equals(two));
Assert.assertTrue(two.equals(one));
Assert.assertEquals(one.hashCode(), two.hashCode());
}
@Test
public void whenCreateTwoDifferentInstances_thenWheyAreNotEquals() {
AtmosphericPressure one = AtmosphericPressure.forValue(5);
AtmosphericPressure two = AtmosphericPressure.forValue(88);
Assert.assertFalse(one.equals(two));
Assert.assertFalse(two.equals(one));
Assert.assertFalse(one.equals(new Object()));
Assert.assertNotEquals(one.hashCode(), two.hashCode());
one = AtmosphericPressure.forValue(44);
one.setSeaLevelValue(44);
two = AtmosphericPressure.forValue(44);
two.setGroundLevelValue(22);
Assert.assertFalse(one.equals(two));
Assert.assertFalse(two.equals(one));
two.setSeaLevelValue(44);
Assert.assertFalse(one.equals(two));
Assert.assertFalse(two.equals(one));
}
@Test
public void whenSetValidValues_thenAllIsFine() {
AtmosphericPressure atmosphericPressure = AtmosphericPressure.forValue(14);
atmosphericPressure.setValue(0);
atmosphericPressure.setValue(15);
atmosphericPressure.setValue(100);
atmosphericPressure.setGroundLevelValue(222);
Assert.assertEquals(222, atmosphericPressure.getGroundLevelValue(), 0.00001);
atmosphericPressure.setSeaLevelValue(4232);
Assert.assertEquals(4232, atmosphericPressure.getSeaLevelValue(), 0.00001);
}
@Test
public void whenCallToString_thenAllIsFine() {
final String pressureString = AtmosphericPressure.forValue(44).toString();
Assert.assertNotNull(pressureString);
Assert.assertNotEquals("", pressureString);
}
@Test(expected = IllegalArgumentException.class)
public void whenCreatePressureByConstructorWithInvalidDataNegative_thenThrowAnException() {
AtmosphericPressure.forValue(-33);
}
@Test(expected = IllegalArgumentException.class)
public void whenCreatePressureAndSetInvalidDataNegative_thenThrowAnException() {
AtmosphericPressure atmosphericPressure = AtmosphericPressure.forValue(88);
atmosphericPressure.setValue(-89);
}
@Test(expected = IllegalArgumentException.class)
public void whenSetInvalidSeaLevelPressure_thenThrowAnException() {
AtmosphericPressure atmosphericPressure = AtmosphericPressure.forValue(88);
atmosphericPressure.setSeaLevelValue(-89);
}
@Test(expected = IllegalArgumentException.class)
public void whenSetInvalidGroundLevelPressure_thenThrowAnException() {
AtmosphericPressure atmosphericPressure = AtmosphericPressure.forValue(88);
atmosphericPressure.setGroundLevelValue(-223);
}
}
@@ -23,75 +23,79 @@
package com.github.prominence.openweathermap.api.model.weather;
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 = new Clouds((byte) 100);
assert clouds.getValue() == 100;
Clouds clouds = Clouds.forValue((byte) 100);
Assert.assertEquals(100, clouds.getValue());
assert new Clouds((byte) 0).getValue() == 0;
assert new Clouds((byte) 100).getValue() == 100;
assert new Clouds((byte) 55).getValue() == 55;
Assert.assertEquals(0, Clouds.forValue((byte) 0).getValue());
Assert.assertEquals(100, Clouds.forValue((byte) 100).getValue());
Assert.assertEquals(55, Clouds.forValue((byte) 55).getValue());
}
@Test(expected = IllegalArgumentException.class)
public void whenCreateCloudsByConstructorWithInvalidDataAboveHundred_thenThrowAnException() {
new Clouds((byte) 110);
Clouds.forValue((byte) 110);
}
@Test(expected = IllegalArgumentException.class)
public void whenCreateCloudsByConstructorWithInvalidDataNegative_thenThrowAnException() {
new Clouds((byte) -33);
Clouds.forValue((byte) -33);
}
@Test
public void whenSetValidValues_thenAllIsFine() {
Clouds clouds = new Clouds((byte) 14);
Clouds clouds = Clouds.forValue((byte) 14);
clouds.setValue((byte) 0);
Assert.assertEquals(0, clouds.getValue());
clouds.setValue((byte) 15);
Assert.assertEquals(15, clouds.getValue());
clouds.setValue((byte) 100);
Assert.assertEquals(100, clouds.getValue());
}
@Test(expected = IllegalArgumentException.class)
public void whenCreateCloudsAndSetInvalidDataAboveHundred_thenThrowAnException() {
Clouds clouds = new Clouds((byte) 12);
Clouds clouds = Clouds.forValue((byte) 12);
clouds.setValue((byte) 112);
}
@Test(expected = IllegalArgumentException.class)
public void whenCreateCloudsAndSetInvalidDataNegative_thenThrowAnException() {
Clouds clouds = new Clouds((byte) 88);
Clouds clouds = Clouds.forValue((byte) 88);
clouds.setValue((byte) -89);
}
@Test
public void whenCreateTwoIdenticalInstances_thenWheyAreEquals() {
Clouds one = new Clouds((byte) 22);
Clouds two = new Clouds((byte) 22);
Clouds one = Clouds.forValue((byte) 22);
Clouds two = Clouds.forValue((byte) 22);
assert one.equals(two);
assert one.equals(one);
assert one.hashCode() == two.hashCode();
Assert.assertTrue(one.equals(two));
Assert.assertTrue(one.equals(one));
Assert.assertEquals(one.hashCode(), two.hashCode());
}
@Test
public void whenCreateTwoDifferentInstances_thenWheyAreNotEquals() {
Clouds one = new Clouds((byte) 5);
Clouds two = new Clouds((byte) 88);
Clouds one = Clouds.forValue((byte) 5);
Clouds two = Clouds.forValue((byte) 88);
assert !one.equals(two);
assert !two.equals(one);
assert !one.equals(new Object());
assert one.hashCode() != two.hashCode();
Assert.assertFalse(one.equals(two));
Assert.assertFalse(two.equals(one));
Assert.assertFalse(one.equals(new Object()));
Assert.assertNotEquals(one.hashCode(), two.hashCode());
}
@Test
public void whenCallToString_thenAllIsFine() {
final String cloudsString = new Clouds((byte) 44).toString();
assert cloudsString != null;
assert !"".equals(cloudsString);
final String cloudsString = Clouds.forValue((byte) 44).toString();
Assert.assertNotNull(cloudsString);
Assert.assertNotEquals("", cloudsString);
}
}
@@ -23,108 +23,109 @@
package com.github.prominence.openweathermap.api.model.weather;
import com.github.prominence.openweathermap.api.model.CoordinateRectangle;
import org.junit.Assert;
import org.junit.Test;
public class CoordinateRectangleUnitTest {
@Test
public void whenCreateObjectWithValidArgs_thenObjectIsCreated() {
new CoordinateRectangle(44.5, 22.4, 54.4, 22.2);
CoordinateRectangle.forValues(44.5, 22.4, 54.4, 22.2);
}
@Test(expected = IllegalArgumentException.class)
public void whenCreateObjectWithLatitudeBottomBelowMinus90_thenThrowAnException() {
new CoordinateRectangle(44.5, -91.2, 54.4, 22.2);
CoordinateRectangle.forValues(44.5, -91.2, 54.4, 22.2);
}
@Test(expected = IllegalArgumentException.class)
public void whenCreateObjectWithLatitudeBottomAbove90_thenThrowAnException() {
new CoordinateRectangle(44.5, 91.2, 54.4, 22.2);
CoordinateRectangle.forValues(44.5, 91.2, 54.4, 22.2);
}
@Test(expected = IllegalArgumentException.class)
public void whenCreateObjectWithLatitudeTopBelowMinus90_thenThrowAnException() {
new CoordinateRectangle(44.5, 22.4, 54.4, -92.3);
CoordinateRectangle.forValues(44.5, 22.4, 54.4, -92.3);
}
@Test(expected = IllegalArgumentException.class)
public void whenCreateObjectWithLatitudeTopAbove90_thenThrowAnException() {
new CoordinateRectangle(44.5, 22.5, 54.4, 94.887);
CoordinateRectangle.forValues(44.5, 22.5, 54.4, 94.887);
}
@Test(expected = IllegalArgumentException.class)
public void whenCreateObjectWithLongitudeLeftBelowMinus180_thenThrowAnException() {
new CoordinateRectangle(-944.5, 22.4, 54.4, 22.2);
CoordinateRectangle.forValues(-944.5, 22.4, 54.4, 22.2);
}
@Test(expected = IllegalArgumentException.class)
public void whenCreateObjectWithLongitudeLeftAbove180_thenThrowAnException() {
new CoordinateRectangle(544.5, 22.4, 54.4, 22.2);
CoordinateRectangle.forValues(544.5, 22.4, 54.4, 22.2);
}
@Test(expected = IllegalArgumentException.class)
public void whenCreateObjectWithLongitudeRightBelowMinus180_thenThrowAnException() {
new CoordinateRectangle(44.5, 22.4, -254.4, 22.2);
CoordinateRectangle.forValues(44.5, 22.4, -254.4, 22.2);
}
@Test(expected = IllegalArgumentException.class)
public void whenCreateObjectWithLongitudeRightAbove180_thenThrowAnException() {
new CoordinateRectangle(44.5, 22.4, 354.4, 22.2);
CoordinateRectangle.forValues(44.5, 22.4, 354.4, 22.2);
}
@Test
public void whenGetAllParameters_thenAllIsFine() {
final CoordinateRectangle rectangle = new CoordinateRectangle(44.5, 22.4, 54.4, 22.2);
assert rectangle.getLongitudeLeft() == 44.5;
assert rectangle.getLatitudeBottom() == 22.4;
assert rectangle.getLongitudeRight() == 54.4;
assert rectangle.getLatitudeTop() == 22.2;
final CoordinateRectangle rectangle = CoordinateRectangle.forValues(44.5, 22.4, 54.4, 22.2);
Assert.assertEquals(44.5, rectangle.getLongitudeLeft(), 0.00001);
Assert.assertEquals(22.4, rectangle.getLatitudeBottom(), 0.00001);
Assert.assertEquals(54.4, rectangle.getLongitudeRight(), 0.00001);
Assert.assertEquals(22.2, rectangle.getLatitudeTop(), 0.00001);
}
@Test
public void whenCallToString_thenAllIsFine() {
final CoordinateRectangle rectangle = new CoordinateRectangle(44.5, 22.4, 54.4, 22.2);
final CoordinateRectangle rectangle = CoordinateRectangle.forValues(44.5, 22.4, 54.4, 22.2);
assert rectangle.toString() != null;
assert !"".equals(rectangle.toString());
Assert.assertNotNull(rectangle.toString());
Assert.assertNotEquals("", rectangle.toString());
}
@Test
public void whenCallHashCode_thenAllIsFine() {
final CoordinateRectangle first = new CoordinateRectangle(44.5, 22.4, 54.4, 22.2);
final CoordinateRectangle second = new CoordinateRectangle(44.5, 22.4, 54.4, 22.2);
final CoordinateRectangle first = CoordinateRectangle.forValues(44.5, 22.4, 54.4, 22.2);
final CoordinateRectangle second = CoordinateRectangle.forValues(44.5, 22.4, 54.4, 22.2);
assert first.hashCode() == second.hashCode();
Assert.assertEquals(first.hashCode(), second.hashCode());
final CoordinateRectangle third = new CoordinateRectangle(44.5, 22.4, 54.4, 23.566);
final CoordinateRectangle third = CoordinateRectangle.forValues(44.5, 22.4, 54.4, 23.566);
assert first.hashCode() != third.hashCode();
assert second.hashCode() != third.hashCode();
Assert.assertNotEquals(first.hashCode(), third.hashCode());
Assert.assertNotEquals(second.hashCode(), third.hashCode());
}
@Test
public void whenCheckEquality_thenAllIsFine() {
CoordinateRectangle first = new CoordinateRectangle(44.5, 22.4, 54.4, 22.2);
CoordinateRectangle second = new CoordinateRectangle(44.5, 22.4, 54.4, 22.2);
CoordinateRectangle first = CoordinateRectangle.forValues(44.5, 22.4, 54.4, 22.2);
CoordinateRectangle second = CoordinateRectangle.forValues(44.5, 22.4, 54.4, 22.2);
assert first.equals(second);
assert first.equals(first);
assert !first.equals(new Object());
Assert.assertTrue(first.equals(second));
Assert.assertTrue(first.equals(first));
Assert.assertFalse(first.equals(new Object()));
first = new CoordinateRectangle(49.5, 22.4, 54.4, 22.2);
first = CoordinateRectangle.forValues(49.5, 22.4, 54.4, 22.2);
assert !first.equals(second);
Assert.assertFalse(first.equals(second));
first = new CoordinateRectangle(44.5, 29.4, 54.4, 22.2);
first = CoordinateRectangle.forValues(44.5, 29.4, 54.4, 22.2);
assert !first.equals(second);
Assert.assertFalse(first.equals(second));
first = new CoordinateRectangle(44.5, 22.4, 24.4, 22.2);
first = CoordinateRectangle.forValues(44.5, 22.4, 24.4, 22.2);
assert !first.equals(second);
Assert.assertFalse(first.equals(second));
first = new CoordinateRectangle(44.5, 22.4, 54.4, -2.2);
first = CoordinateRectangle.forValues(44.5, 22.4, 54.4, -2.2);
assert !first.equals(second);
Assert.assertFalse(first.equals(second));
}
}
@@ -23,142 +23,149 @@
package com.github.prominence.openweathermap.api.model.weather;
import com.github.prominence.openweathermap.api.model.Coordinate;
import org.junit.Assert;
import org.junit.Test;
public class CoordinateUnitTest {
@Test
public void whenCreateCoordinateWithValidValues_thenObjectCreated() {
new Coordinate(44, 53);
Coordinate.forValues(44, 53);
}
@Test(expected = IllegalArgumentException.class)
public void whenCreateCoordinateWithInvalidLatitudeBelowMinus90_thenThrowAnException() {
new Coordinate(-333, 44);
Coordinate.forValues(-333, 44);
}
@Test(expected = IllegalArgumentException.class)
public void whenCreateCoordinateWithInvalidLatitudeAbove90_thenThrowAnException() {
new Coordinate(223, 44);
Coordinate.forValues(223, 44);
}
@Test(expected = IllegalArgumentException.class)
public void whenCreateCoordinateWithInvalidLongitudeBelowMinus180_thenThrowAnException() {
new Coordinate(33, -999);
Coordinate.forValues(33, -999);
}
@Test(expected = IllegalArgumentException.class)
public void whenCreateCoordinateWithInvalidLongitudeAbove180_thenThrowAnException() {
new Coordinate(33, 999);
Coordinate.forValues(33, 999);
}
@Test
public void whenSetValidCoordinates_thenAllIsFine() {
final Coordinate coordinate = new Coordinate(0, 0);
final Coordinate coordinate = Coordinate.forValues(0, 0);
coordinate.setLatitude(-90);
Assert.assertEquals(-90, coordinate.getLatitude(), 0.00001);
coordinate.setLatitude(90);
Assert.assertEquals(90, coordinate.getLatitude(), 0.00001);
coordinate.setLatitude(44);
Assert.assertEquals(44, coordinate.getLatitude(), 0.00001);
coordinate.setLongitude(-180);
Assert.assertEquals(-180, coordinate.getLongitude(), 0.00001);
coordinate.setLongitude(180);
Assert.assertEquals(180, coordinate.getLongitude(), 0.00001);
coordinate.setLongitude(130);
Assert.assertEquals(130, coordinate.getLongitude(), 0.00001);
}
@Test(expected = IllegalArgumentException.class)
public void whenSetInvalidLatitudeBelowMinus90_thenThrowAnException() {
final Coordinate coordinate = new Coordinate(0, 0);
final Coordinate coordinate = Coordinate.forValues(0, 0);
coordinate.setLatitude(-91);
}
@Test(expected = IllegalArgumentException.class)
public void whenSetInvalidLatitudeAbove90_thenThrowAnException() {
final Coordinate coordinate = new Coordinate(0, 0);
final Coordinate coordinate = Coordinate.forValues(0, 0);
coordinate.setLatitude(92);
}
@Test(expected = IllegalArgumentException.class)
public void whenSetInvalidLongitudeBelowMinus180_thenThrowAnException() {
final Coordinate coordinate = new Coordinate(0, 0);
final Coordinate coordinate = Coordinate.forValues(0, 0);
coordinate.setLongitude(-194);
}
@Test(expected = IllegalArgumentException.class)
public void whenSetInvalidLongitudeAbove180_thenThrowAnException() {
final Coordinate coordinate = new Coordinate(0, 0);
final Coordinate coordinate = Coordinate.forValues(0, 0);
coordinate.setLongitude(444);
}
@Test
public void whenGetLatitude_thenAllIsFine() {
final Coordinate coordinate = new Coordinate(0, 0);
assert coordinate.getLatitude() == 0;
final Coordinate coordinate = Coordinate.forValues(0, 0);
Assert.assertEquals(0, coordinate.getLatitude(), 0.00001);
coordinate.setLatitude(45);
assert coordinate.getLatitude() == 45;
Assert.assertEquals(45, coordinate.getLatitude(), 0.00001);
}
@Test
public void whenGetLongitude_thenAllIsFine() {
final Coordinate coordinate = new Coordinate(0, 0);
assert coordinate.getLongitude() == 0;
final Coordinate coordinate = Coordinate.forValues(0, 0);
Assert.assertEquals(0, coordinate.getLongitude(), 0.00001);
coordinate.setLongitude(33);
assert coordinate.getLongitude() == 33;
Assert.assertEquals(33, coordinate.getLongitude(), 0.00001);
}
@Test
public void whenCallToString_thenAllIsFine() {
final Coordinate coordinate = new Coordinate(0, 0);
assert coordinate.toString() != null;
assert !"".equals(coordinate.toString());
final Coordinate coordinate = Coordinate.forValues(0, 0);
Assert.assertNotNull(coordinate.toString());
Assert.assertNotEquals("", coordinate.toString());
}
@Test
public void RainwhenCallHashCode_thenAllIsFine() {
final Coordinate first = new Coordinate(22, 66);
final Coordinate second = new Coordinate(22, 44);
public void whenCallHashCode_thenAllIsFine() {
final Coordinate first = Coordinate.forValues(22, 66);
final Coordinate second = Coordinate.forValues(22, 44);
assert first.hashCode() != second.hashCode();
Assert.assertNotEquals(first.hashCode(), second.hashCode());
second.setLongitude(66);
assert first.hashCode() == second.hashCode();
Assert.assertEquals(first.hashCode(), second.hashCode());
second.setLatitude(89);
assert first.hashCode() != second.hashCode();
Assert.assertNotEquals(first.hashCode(), second.hashCode());
first.setLatitude(89);
assert first.hashCode() == second.hashCode();
Assert.assertEquals(first.hashCode(), second.hashCode());
}
@Test
public void whenCheckEquality_thenAllIsFine() {
final Coordinate first = new Coordinate(11, 99);
final Coordinate second = new Coordinate(11, 99);
final Coordinate first = Coordinate.forValues(11, 99);
final Coordinate second = Coordinate.forValues(11, 99);
assert first.equals(second);
assert first.equals(first);
assert !first.equals(new Object());
Assert.assertTrue(first.equals(second));
Assert.assertTrue(first.equals(first));
Assert.assertFalse(first.equals(new Object()));
first.setLatitude(34);
assert !first.equals(second);
Assert.assertFalse(first.equals(second));
second.setLatitude(34);
assert first.equals(second);
Assert.assertTrue(first.equals(second));
second.setLongitude(74);
assert !first.equals(second);
Assert.assertFalse(first.equals(second));
first.setLongitude(74);
assert first.equals(second);
Assert.assertTrue(first.equals(second));
}
}
@@ -23,75 +23,79 @@
package com.github.prominence.openweathermap.api.model.weather;
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 = new Humidity((byte) 100);
assert humidity.getValue() == 100;
Humidity humidity = Humidity.forValue((byte) 100);
Assert.assertEquals(100, humidity.getValue());
assert new Humidity((byte) 0).getValue() == 0;
assert new Humidity((byte) 100).getValue() == 100;
assert new Humidity((byte) 55).getValue() == 55;
Assert.assertEquals(0, Humidity.forValue((byte) 0).getValue());
Assert.assertEquals(55, Humidity.forValue((byte) 55).getValue());
}
@Test(expected = IllegalArgumentException.class)
public void whenCreateHumidityByConstructorWithInvalidDataAboveHundred_thenThrowAnException() {
new Humidity((byte) 112);
Humidity.forValue((byte) 112);
}
@Test(expected = IllegalArgumentException.class)
public void whenCreateHumidityByConstructorWithInvalidDataNegative_thenThrowAnException() {
new Humidity((byte) -33);
Humidity.forValue((byte) -33);
}
@Test
public void whenSetValidValues_thenAllIsFine() {
Humidity humidity = new Humidity((byte) 14);
Humidity humidity = Humidity.forValue((byte) 14);
Assert.assertEquals(14, humidity.getValue());
humidity.setValue((byte) 0);
Assert.assertEquals(0, humidity.getValue());
humidity.setValue((byte) 15);
Assert.assertEquals(15, humidity.getValue());
humidity.setValue((byte) 100);
Assert.assertEquals(100, humidity.getValue());
}
@Test(expected = IllegalArgumentException.class)
public void whenCreateHumidityAndSetInvalidDataAboveHundred_thenThrowAnException() {
Humidity humidity = new Humidity((byte) 12);
Humidity humidity = Humidity.forValue((byte) 12);
humidity.setValue((byte) 112);
}
@Test(expected = IllegalArgumentException.class)
public void whenCreateHumidityAndSetInvalidDataNegative_thenThrowAnException() {
Humidity humidity = new Humidity((byte) 88);
Humidity humidity = Humidity.forValue((byte) 88);
humidity.setValue((byte) -89);
}
@Test
public void whenCreateTwoIdenticalInstances_thenWheyAreEquals() {
Humidity one = new Humidity((byte) 22);
Humidity two = new Humidity((byte) 22);
Humidity one = Humidity.forValue((byte) 22);
Humidity two = Humidity.forValue((byte) 22);
assert one.equals(two);
assert one.equals(one);
assert one.hashCode() == two.hashCode();
Assert.assertTrue(one.equals(two));
Assert.assertTrue(one.equals(one));
Assert.assertEquals(one.hashCode(), two.hashCode());
}
@Test
public void whenCreateTwoDifferentInstances_thenWheyAreNotEquals() {
Humidity one = new Humidity((byte) 5);
Humidity two = new Humidity((byte) 88);
Humidity one = Humidity.forValue((byte) 5);
Humidity two = Humidity.forValue((byte) 88);
assert !one.equals(two);
assert !two.equals(one);
assert !one.equals(new Object());
assert one.hashCode() != two.hashCode();
Assert.assertFalse(one.equals(two));
Assert.assertFalse(two.equals(one));
Assert.assertFalse(one.equals(new Object()));
Assert.assertNotEquals(one.hashCode(), two.hashCode());
}
@Test
public void whenCallToString_thenAllIsFine() {
final String humidityString = new Humidity((byte) 44).toString();
assert humidityString != null;
assert !"".equals(humidityString);
final String humidityString = Humidity.forValue((byte) 44).toString();
Assert.assertNotNull(humidityString);
Assert.assertNotEquals("", humidityString);
}
}
@@ -23,7 +23,7 @@
package com.github.prominence.openweathermap.api.model.weather;
import com.github.prominence.openweathermap.api.model.Coordinate;
import com.github.prominence.openweathermap.api.model.Location;
import org.junit.Assert;
import org.junit.Test;
import java.time.LocalDateTime;
@@ -33,169 +33,170 @@ public class LocationUnitTest {
@Test
public void whenCreateObjectWithValidArgs_thenObjectIsCreated() {
new Location(33, "test");
Location.forValue(33, "test");
}
@Test(expected = IllegalArgumentException.class)
public void whenCreateObjectWithoutName_thenThrowAnException() {
new Location(33, null);
Location.forValue(33, null);
}
@Test
public void whenSetId_thenValueIsSet() {
final Location location = new Location(33, "test");
final Location location = Location.forValue(33, "test");
location.setId(55);
assert location.getId() == 55;
Assert.assertEquals(55, location.getId());
}
@Test
public void whenSetName_thenValueIsSet() {
final Location location = new Location(33, "test");
final Location location = Location.forValue(33, "test");
location.setName("city");
assert "city".equals(location.getName());
Assert.assertEquals("city", location.getName());
}
@Test
public void whenSetCountryCode_thenValueIsSet() {
final Location location = new Location(33, "test");
final Location location = Location.forValue(33, "test");
location.setCountryCode("by");
assert "by".equals(location.getCountryCode());
Assert.assertEquals("by", location.getCountryCode());
}
@Test
public void whenSetSunrise_thenValueIsSet() {
final Location location = new Location(33, "test");
final Location location = Location.forValue(33, "test");
final LocalDateTime now = LocalDateTime.now();
location.setSunrise(now);
assert now.equals(location.getSunrise());
Assert.assertEquals(now, location.getSunrise());
}
@Test
public void whenSetSunset_thenValueIsSet() {
final Location location = new Location(33, "test");
final Location location = Location.forValue(33, "test");
final LocalDateTime now = LocalDateTime.now();
location.setSunset(now);
assert now.equals(location.getSunset());
Assert.assertEquals(now, location.getSunset());
}
@Test
public void whenSetZoneOffset_thenValueIsSet() {
final Location location = new Location(33, "test");
final Location location = Location.forValue(33, "test");
final ZoneOffset offset = ZoneOffset.UTC;
location.setZoneOffset(offset);
assert offset.equals(location.getZoneOffset());
Assert.assertEquals(offset, location.getZoneOffset());
}
@Test
public void whenSetCoordinate_thenValueIsSet() {
final Location location = new Location(33, "test");
final Coordinate coordinate = new Coordinate(33.2, 64.2);
final Location location = Location.forValue(33, "test");
final Coordinate coordinate = Coordinate.forValues(33.2, 64.2);
location.setCoordinate(coordinate);
assert coordinate.equals(location.getCoordinate());
Assert.assertEquals(coordinate, location.getCoordinate());
}
@Test
public void whenCallToString_thenAllIsFine() {
final Location location = new Location(44, "test");
final Location location = Location.forValue(44, "test");
assert !"".equals(location.toString());
Assert.assertNotEquals("", location.toString());
location.setCoordinate(new Coordinate(33.2, 56.3));
location.setCoordinate(Coordinate.forValues(33.2, 56.3));
assert !"".equals(location.toString());
Assert.assertNotEquals("", location.toString());
location.setCountryCode("TN");
assert !"".equals(location.toString());
Assert.assertNotEquals("", location.toString());
Assert.assertNotNull(location.toString());
}
@Test
public void whenCallHashCode_thenAllIsFine() {
final Location one = new Location(44, "test");
final Location two = new Location(44, "test");
final Location one = Location.forValue(44, "test");
final Location two = Location.forValue(44, "test");
assert one.hashCode() == two.hashCode();
Assert.assertEquals(one.hashCode(), two.hashCode());
two.setName("112");
assert one.hashCode() != two.hashCode();
Assert.assertNotEquals(one.hashCode(), two.hashCode());
}
@Test
public void whenCheckEquality_thenAllIsFine() {
final Location one = new Location(44, "test");
final Location two = new Location(44, "test");
final Location one = Location.forValue(44, "test");
final Location two = Location.forValue(44, "test");
assert one.equals(one);
assert !one.equals(new Object());
Assert.assertTrue(one.equals(one));
Assert.assertFalse(one.equals(new Object()));
assert one.equals(two);
Assert.assertTrue(one.equals(two));
two.setId(23);
assert !one.equals(two);
Assert.assertFalse(one.equals(two));
one.setId(23);
assert one.equals(two);
Assert.assertTrue(one.equals(two));
one.setName("23");
assert !one.equals(two);
Assert.assertFalse(one.equals(two));
two.setName("23");
assert one.equals(two);
Assert.assertTrue(one.equals(two));
one.setCountryCode("11");
assert !one.equals(two);
Assert.assertFalse(one.equals(two));
two.setCountryCode("11");
assert one.equals(two);
Assert.assertTrue(one.equals(two));
final LocalDateTime now = LocalDateTime.now();
one.setSunrise(now);
assert !one.equals(two);
Assert.assertFalse(one.equals(two));
two.setSunrise(now);
assert one.equals(two);
Assert.assertTrue(one.equals(two));
one.setSunset(now);
assert !one.equals(two);
Assert.assertFalse(one.equals(two));
two.setSunset(now);
assert one.equals(two);
Assert.assertTrue(one.equals(two));
one.setZoneOffset(ZoneOffset.UTC);
assert !one.equals(two);
Assert.assertFalse(one.equals(two));
two.setZoneOffset(ZoneOffset.UTC);
assert one.equals(two);
Assert.assertTrue(one.equals(two));
final Coordinate coordinate = new Coordinate(33.5, -22.4);
final Coordinate coordinate = Coordinate.forValues(33.5, -22.4);
one.setCoordinate(coordinate);
assert !one.equals(two);
Assert.assertFalse(one.equals(two));
two.setCoordinate(coordinate);
assert one.equals(two);
Assert.assertTrue(one.equals(two));
}
}
@@ -1,127 +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.model.weather;
import com.github.prominence.openweathermap.api.model.Pressure;
import org.junit.Test;
public class PressureUnitTest {
@Test
public void whenCreatePressureWithArgs_thenValueIsSet() {
Pressure pressure = new Pressure(100);
assert pressure.getValue() == 100;
assert new Pressure(0).getValue() == 0;
assert new Pressure(100).getValue() == 100;
assert new Pressure(55).getValue() == 55;
}
@Test
public void whenCreateTwoIdenticalInstances_thenWheyAreEquals() {
Pressure one = new Pressure(22);
Pressure two = new Pressure(22);
assert one.equals(two);
assert one.equals(one);
assert one.hashCode() == two.hashCode();
one.setSeaLevelValue(333);
one.setGroundLevelValue(555);
two.setSeaLevelValue(333);
two.setGroundLevelValue(555);
assert one.equals(two);
assert two.equals(one);
assert one.hashCode() == two.hashCode();
}
@Test
public void whenCreateTwoDifferentInstances_thenWheyAreNotEquals() {
Pressure one = new Pressure(5);
Pressure two = new Pressure(88);
assert !one.equals(two);
assert !two.equals(one);
assert !one.equals(new Object());
assert one.hashCode() != two.hashCode();
one = new Pressure(44);
one.setSeaLevelValue(44);
two = new Pressure(44);
two.setGroundLevelValue(22);
assert !one.equals(two);
assert !two.equals(one);
two.setSeaLevelValue(44);
assert !one.equals(two);
assert !two.equals(one);
}
@Test
public void whenSetValidValues_thenAllIsFine() {
Pressure pressure = new Pressure(14);
pressure.setValue(0);
pressure.setValue(15);
pressure.setValue(100);
pressure.setGroundLevelValue(222);
assert pressure.getGroundLevelValue() == 222;
pressure.setSeaLevelValue(4232);
assert pressure.getSeaLevelValue() == 4232;
}
@Test
public void whenCallToString_thenAllIsFine() {
final String pressureString = new Pressure(44).toString();
assert pressureString != null;
assert !"".equals(pressureString);
}
@Test(expected = IllegalArgumentException.class)
public void whenCreatePressureByConstructorWithInvalidDataNegative_thenThrowAnException() {
new Pressure(-33);
}
@Test(expected = IllegalArgumentException.class)
public void whenCreatePressureAndSetInvalidDataNegative_thenThrowAnException() {
Pressure pressure = new Pressure(88);
pressure.setValue(-89);
}
@Test(expected = IllegalArgumentException.class)
public void whenSetInvalidSeaLevelPressure_thenThrowAnException() {
Pressure pressure = new Pressure(88);
pressure.setSeaLevelValue(-89);
}
@Test(expected = IllegalArgumentException.class)
public void whenSetInvalidGroundLevelPressure_thenThrowAnException() {
Pressure pressure = new Pressure(88);
pressure.setGroundLevelValue(-223);
}
}
@@ -22,7 +22,7 @@
package com.github.prominence.openweathermap.api.model.weather;
import com.github.prominence.openweathermap.api.model.weather.Rain;
import org.junit.Assert;
import org.junit.Test;
public class RainUnitTest {
@@ -37,39 +37,39 @@ public class RainUnitTest {
@Test
public void whenSetValues_thenTheyAreSet() {
final Rain snow = new Rain(null, null);
final Rain rain = new Rain(null, null);
assert snow.getOneHourRainLevel() == null;
assert snow.getThreeHourRainLevel() == null;
Assert.assertNull(rain.getOneHourRainLevel());
Assert.assertNull(rain.getThreeHourRainLevel());
snow.setOneHourRainLevel(33.3);
assert snow.getOneHourRainLevel() == 33.3;
rain.setOneHourRainLevel(33.3);
Assert.assertEquals(33.3, rain.getOneHourRainLevel(), 0.00001);
snow.setThreeHourRainLevel(55.5);
assert snow.getThreeHourRainLevel() == 55.5;
rain.setThreeHourRainLevel(55.5);
Assert.assertEquals(55.5, rain.getThreeHourRainLevel(), 0.00001);
}
@Test
public void whenCallToString_thenAllIsFine() {
final Rain snow = new Rain();
final Rain rain = new Rain();
assert snow.toString() != null;
assert "unknown".equals(snow.toString());
Assert.assertNotNull(rain.toString());
Assert.assertEquals("unknown", rain.toString());
snow.setThreeHourRainLevel(33.5);
rain.setThreeHourRainLevel(33.5);
assert snow.toString() != null;
assert !"unknown".equals(snow.toString());
Assert.assertNotNull(rain.toString());
Assert.assertEquals("unknown", rain.toString());
snow.setOneHourRainLevel(22.2);
rain.setOneHourRainLevel(22.2);
assert snow.toString() != null;
assert !"unknown".equals(snow.toString());
Assert.assertNotNull(rain.toString());
Assert.assertEquals("unknown", rain.toString());
snow.setThreeHourRainLevel(null);
rain.setThreeHourRainLevel(null);
assert snow.toString() != null;
assert !"unknown".equals(snow.toString());
Assert.assertNotNull(rain.toString());
Assert.assertEquals("unknown", rain.toString());
}
@Test
@@ -77,23 +77,23 @@ public class RainUnitTest {
final Rain first = new Rain();
final Rain second = new Rain();
assert first.hashCode() == second.hashCode();
Assert.assertEquals(first.hashCode(), second.hashCode());
second.setThreeHourRainLevel(11.0);
assert first.hashCode() != second.hashCode();
Assert.assertNotEquals(first.hashCode(), second.hashCode());
first.setThreeHourRainLevel(11.0);
assert first.hashCode() == second.hashCode();
Assert.assertEquals(first.hashCode(), second.hashCode());
first.setOneHourRainLevel(333.2);
assert first.hashCode() != second.hashCode();
Assert.assertNotEquals(first.hashCode(), second.hashCode());
second.setOneHourRainLevel(333.2);
assert first.hashCode() == second.hashCode();
Assert.assertEquals(first.hashCode(), second.hashCode());
}
@Test
@@ -101,24 +101,24 @@ public class RainUnitTest {
final Rain first = new Rain();
final Rain second = new Rain();
assert first.equals(second);
assert first.equals(first);
assert !first.equals(new Object());
Assert.assertTrue(first.equals(second));
Assert.assertTrue(first.equals(first));
Assert.assertFalse(first.equals(new Object()));
first.setOneHourRainLevel(0.34);
assert !first.equals(second);
Assert.assertFalse(first.equals(second));
second.setOneHourRainLevel(0.34);
assert first.equals(second);
Assert.assertTrue(first.equals(second));
second.setThreeHourRainLevel(66.7);
assert !first.equals(second);
Assert.assertFalse(first.equals(second));
first.setThreeHourRainLevel(66.7);
assert first.equals(second);
Assert.assertTrue(first.equals(second));
}
}
@@ -22,7 +22,7 @@
package com.github.prominence.openweathermap.api.model.weather;
import com.github.prominence.openweathermap.api.model.weather.Snow;
import org.junit.Assert;
import org.junit.Test;
public class SnowUnitTest {
@@ -39,61 +39,61 @@ public class SnowUnitTest {
public void whenSetValues_thenTheyAreSet() {
final Snow snow = new Snow(null, null);
assert snow.getOneHourSnowLevel() == null;
assert snow.getThreeHourSnowLevel() == null;
Assert.assertNull(snow.getOneHourSnowLevel());
Assert.assertNull(snow.getThreeHourSnowLevel());
snow.setOneHourSnowLevel(33.3);
assert snow.getOneHourSnowLevel() == 33.3;
Assert.assertEquals(33.3, snow.getOneHourSnowLevel(), 0.00001);
snow.setThreeHourSnowLevel(55.5);
assert snow.getThreeHourSnowLevel() == 55.5;
Assert.assertEquals(55.5, snow.getThreeHourSnowLevel(), 0.00001);
}
@Test
public void whenCallToString_thenAllIsFine() {
final Snow snow = new Snow();
assert snow.toString() != null;
assert "unknown".equals(snow.toString());
Assert.assertNotNull(snow.toString());
Assert.assertEquals("unknown", snow.toString());
snow.setThreeHourSnowLevel(33.5);
assert snow.toString() != null;
assert !"unknown".equals(snow.toString());
Assert.assertNotNull(snow.toString());
Assert.assertEquals("unknown", snow.toString());
snow.setOneHourSnowLevel(22.2);
assert snow.toString() != null;
assert !"unknown".equals(snow.toString());
Assert.assertNotNull(snow.toString());
Assert.assertEquals("unknown", snow.toString());
snow.setThreeHourSnowLevel(null);
assert snow.toString() != null;
assert !"unknown".equals(snow.toString());
Assert.assertNotNull(snow.toString());
Assert.assertEquals("unknown", snow.toString());
}
@Test
public void RainwhenCallHashCode_thenAllIsFine() {
public void whenCallHashCode_thenAllIsFine() {
final Snow first = new Snow();
final Snow second = new Snow();
assert first.hashCode() == second.hashCode();
Assert.assertEquals(first.hashCode(), second.hashCode());
second.setThreeHourSnowLevel(11.0);
assert first.hashCode() != second.hashCode();
Assert.assertNotEquals(first.hashCode(), second.hashCode());
first.setThreeHourSnowLevel(11.0);
assert first.hashCode() == second.hashCode();
Assert.assertEquals(first.hashCode(), second.hashCode());
first.setOneHourSnowLevel(333.2);
assert first.hashCode() != second.hashCode();
Assert.assertNotEquals(first.hashCode(), second.hashCode());
second.setOneHourSnowLevel(333.2);
assert first.hashCode() == second.hashCode();
Assert.assertEquals(first.hashCode(), second.hashCode());
}
@Test
@@ -101,24 +101,24 @@ public class SnowUnitTest {
final Snow first = new Snow();
final Snow second = new Snow();
assert first.equals(second);
assert first.equals(first);
assert !first.equals(new Object());
Assert.assertTrue(first.equals(second));
Assert.assertTrue(first.equals(first));
Assert.assertFalse(first.equals(new Object()));
first.setOneHourSnowLevel(0.34);
assert !first.equals(second);
Assert.assertFalse(first.equals(second));
second.setOneHourSnowLevel(0.34);
assert first.equals(second);
Assert.assertTrue(first.equals(second));
second.setThreeHourSnowLevel(66.7);
assert !first.equals(second);
Assert.assertFalse(first.equals(second));
first.setThreeHourSnowLevel(66.7);
assert first.equals(second);
Assert.assertTrue(first.equals(second));
}
}
@@ -22,122 +22,122 @@
package com.github.prominence.openweathermap.api.model.weather;
import org.junit.Assert;
import org.junit.Test;
public class TemperatureUnitTest {
@Test
public void whenCreateObjectWithValidArgs_thenObjectIsCreated() {
new Temperature(22.2, "K");
Temperature.forValue(22.2, "K");
}
@Test(expected = IllegalArgumentException.class)
public void whenCreateObjectWithEmptyUnit_thenThrowAnException() {
new Temperature(22.2, null);
Temperature.forValue(22.2, null);
}
@Test
public void whenSetValue_thenAllIsFine() {
final Temperature temperature = new Temperature(22.2, "K");
final Temperature temperature = Temperature.forValue(22.2, "K");
temperature.setValue(55.44);
assert temperature.getValue() == 55.44;
Assert.assertEquals(55.44, temperature.getValue(), 0.00001);
}
@Test
public void whenSetMaximumTemperature_thenAllIsOk() {
final Temperature temperature = new Temperature(22.2, "K");
final Temperature temperature = Temperature.forValue(22.2, "K");
temperature.setMaxTemperature(44.4);
assert temperature.getMaxTemperature() == 44.4;
Assert.assertEquals(44.4, temperature.getMaxTemperature(), 0.00001);
temperature.setMaxTemperature(null);
assert temperature.getMaxTemperature() == null;
Assert.assertNull(temperature.getMaxTemperature());
}
@Test
public void whenSetMinimumTemperature_thenAllIsOk() {
final Temperature temperature = new Temperature(22.2, "K");
final Temperature temperature = Temperature.forValue(22.2, "K");
temperature.setMinTemperature(33.2);
assert temperature.getMinTemperature() == 33.2;
Assert.assertEquals(33.2, temperature.getMinTemperature(), 0.00001);
temperature.setMinTemperature(null);
assert temperature.getMinTemperature() == null;
Assert.assertNull(temperature.getMinTemperature());
}
@Test
public void whenSetNonNullUnit_thenAllIsOk() {
final Temperature temperature = new Temperature(22.2, "K");
final Temperature temperature = Temperature.forValue(22.2, "K");
temperature.setUnit("test");
assert "test".equals(temperature.getUnit());
Assert.assertTrue("test".equals(temperature.getUnit()));
}
@Test(expected = IllegalArgumentException.class)
public void whenSetNullUnit_thenThrowAnException() {
final Temperature temperature = new Temperature(22.2, "K");
final Temperature temperature = Temperature.forValue(22.2, "K");
temperature.setUnit(null);
}
@Test
public void whenCallToString_thenAllIsFine() {
final Temperature temperature = new Temperature(22.2, "K");
final Temperature temperature = Temperature.forValue(22.2, "K");
assert !"".equals(temperature.toString());
Assert.assertNotEquals("", temperature.toString());
temperature.setMinTemperature(11.2);
assert !"".equals(temperature.toString());
Assert.assertNotEquals("", temperature.toString());
temperature.setMaxTemperature(44.3);
assert !"".equals(temperature.toString());
Assert.assertNotEquals("", temperature.toString());
}
@Test
public void whenCallHashCode_thenAllIsFine() {
final Temperature one = new Temperature(22.2, "K");
final Temperature two = new Temperature(22.2, "K");
final Temperature one = Temperature.forValue(22.2, "K");
final Temperature two = Temperature.forValue(22.2, "K");
assert one.hashCode() == two.hashCode();
Assert.assertEquals(one.hashCode(), two.hashCode());
}
@Test
public void whenCheckEquality_thenAllIsFine() {
final Temperature one = new Temperature(22.2, "K");
final Temperature two = new Temperature(21.2, "K");
final Temperature one = Temperature.forValue(22.2, "K");
final Temperature two = Temperature.forValue(21.2, "K");
assert one.equals(one);
assert !one.equals(new Object());
assert !one.equals(two);
Assert.assertTrue(one.equals(one));
Assert.assertFalse(one.equals(new Object()));
Assert.assertFalse(one.equals(two));
one.setValue(21.2);
assert one.equals(two);
Assert.assertTrue(one.equals(two));
one.setMaxTemperature(33.56);
assert !one.equals(two);
Assert.assertFalse(one.equals(two));
two.setMaxTemperature(33.56);
assert one.equals(two);
Assert.assertTrue(one.equals(two));
one.setMinTemperature(11.54);
assert !one.equals(two);
Assert.assertFalse(one.equals(two));
two.setMinTemperature(11.54);
assert one.equals(two);
Assert.assertTrue(one.equals(two));
two.setUnit("U");
assert !one.equals(two);
Assert.assertFalse(one.equals(two));
}
}
@@ -22,12 +22,10 @@
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.Location;
import com.github.prominence.openweathermap.api.model.Pressure;
import com.github.prominence.openweathermap.api.model.weather.*;
import com.github.prominence.openweathermap.api.model.weather.Temperature;
import org.junit.Assert;
import org.junit.Test;
import java.time.LocalDateTime;
@@ -36,280 +34,294 @@ public class WeatherUnitTest {
@Test
public void whenCreateObjectWithValidArgs_thenObjectIsCreated() {
new Weather("state", "desc");
Weather.forValue("state", "desc");
}
@Test(expected = IllegalArgumentException.class)
public void whenCreateObjectWithoutState_thenThrowAnException() {
new Weather(null, "desc");
Weather.forValue(null, "desc");
}
@Test(expected = IllegalArgumentException.class)
public void whenCreateObjectWithoutDescription_thenThrowAnException() {
new Weather("state", null);
Weather.forValue("state", null);
}
@Test
public void whenSetState_thenValueIsSet() {
final Weather weather = new Weather("state", "desc");
final Weather weather = Weather.forValue("state", "desc");
weather.setState("test");
assert "test".equals(weather.getState());
Assert.assertEquals("test", weather.getState());
}
@Test(expected = IllegalArgumentException.class)
public void whenSetNullState_thenThrowAnException() {
final Weather weather = new Weather("state", "desc");
final Weather weather = Weather.forValue("state", "desc");
weather.setState(null);
}
@Test
public void whenSetDescription_thenValueIsSet() {
final Weather weather = new Weather("state", "desc");
final Weather weather = Weather.forValue("state", "desc");
weather.setDescription("test");
assert "test".equals(weather.getDescription());
Assert.assertEquals("test", weather.getDescription());
}
@Test(expected = IllegalArgumentException.class)
public void whenSetNullDescription_thenThrowAnException() {
final Weather weather = new Weather("state", "desc");
final Weather weather = Weather.forValue("state", "desc");
weather.setDescription(null);
}
@Test
public void whenSetIconUrl_thenValueIsSet() {
final Weather weather = new Weather("state", "desc");
final Weather weather = Weather.forValue("state", "desc");
weather.setWeatherIconUrl("test");
assert "test".equals(weather.getWeatherIconUrl());
Assert.assertEquals("test", weather.getWeatherIconUrl());
}
@Test
public void whenSetRequestedOn_thenValueIsSet() {
final Weather weather = new Weather("state", "desc");
final Weather weather = Weather.forValue("state", "desc");
final LocalDateTime now = LocalDateTime.now();
weather.setRequestedOn(now);
assert now.equals(weather.getRequestedOn());
Assert.assertEquals(now, weather.getRequestedOn());
}
@Test
public void whenSetTemperature_thenValueIsSet() {
final Weather weather = new Weather("state", "desc");
final Temperature temperature = new Temperature(22.3, "a");
final Weather weather = Weather.forValue("state", "desc");
final Temperature temperature = Temperature.forValue(22.3, "a");
weather.setTemperature(temperature);
assert temperature.equals(weather.getTemperature());
Assert.assertEquals(temperature, weather.getTemperature());
}
@Test
public void whenSetPressure_thenValueIsSet() {
final Weather weather = new Weather("state", "desc");
final Pressure pressure = new Pressure(33.2);
weather.setPressure(pressure);
final Weather weather = Weather.forValue("state", "desc");
final AtmosphericPressure atmosphericPressure = AtmosphericPressure.forValue(33.2);
weather.setAtmosphericPressure(atmosphericPressure);
assert pressure.equals(weather.getPressure());
Assert.assertEquals(atmosphericPressure, weather.getAtmosphericPressure());
}
@Test
public void whenSetHumidity_thenValueIsSet() {
final Weather weather = new Weather("state", "desc");
final Humidity humidity = new Humidity((byte) 44);
final Weather weather = Weather.forValue("state", "desc");
final Humidity humidity = Humidity.forValue((byte) 44);
weather.setHumidity(humidity);
assert humidity.equals(weather.getHumidity());
Assert.assertEquals(humidity, weather.getHumidity());
}
@Test
public void whenSetWind_thenValueIsSet() {
final Weather weather = new Weather("state", "desc");
final Wind wind = new Wind(22.2, "a");
final Weather weather = Weather.forValue("state", "desc");
final Wind wind = Wind.forValue(22.2, "a");
weather.setWind(wind);
assert wind.equals(weather.getWind());
Assert.assertEquals(wind, weather.getWind());
}
@Test
public void whenSetRain_thenValueIsSet() {
final Weather weather = new Weather("state", "desc");
final Weather weather = Weather.forValue("state", "desc");
final Rain rain = new Rain();
weather.setRain(rain);
assert rain.equals(weather.getRain());
Assert.assertEquals(rain, weather.getRain());
}
@Test
public void whenSetSnow_thenValueIsSet() {
final Weather weather = new Weather("state", "desc");
final Weather weather = Weather.forValue("state", "desc");
final Snow snow = new Snow();
weather.setSnow(snow);
assert snow.equals(weather.getSnow());
Assert.assertEquals(snow, weather.getSnow());
}
@Test
public void whenSetClouds_thenValueIsSet() {
final Weather weather = new Weather("state", "desc");
final Clouds clouds = new Clouds((byte) 33);
final Weather weather = Weather.forValue("state", "desc");
final Clouds clouds = Clouds.forValue((byte) 33);
weather.setClouds(clouds);
assert clouds.equals(weather.getClouds());
Assert.assertEquals(clouds, weather.getClouds());
}
@Test
public void whenSetLocation_thenValueIsSet() {
final Weather weather = new Weather("state", "desc");
final Location location = new Location(22, "asd");
final Weather weather = Weather.forValue("state", "desc");
final Location location = Location.forValue(22, "asd");
weather.setLocation(location);
assert location.equals(weather.getLocation());
Assert.assertEquals(location, weather.getLocation());
}
@Test
public void whenCallToString_thenAllIsFine() {
final Weather weather = new Weather("state", "desc");
final Location location = new Location(12312, "asd");
final Temperature temperature = new Temperature(33.2, "asd");
final Pressure pressure = new Pressure(44.4);
final Clouds clouds = new Clouds((byte) 55);
final Weather weather = Weather.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, null);
final Snow snow = new Snow(33.1, null);
assert !"".equals(weather.toString());
Assert.assertNotEquals("", weather.toString());
Assert.assertNotNull(weather.toString());
weather.setLocation(location);
assert !"".equals(weather.toString());
Assert.assertNotEquals("", weather.toString());
Assert.assertNotNull(weather.toString());
location.setCountryCode("3d");
assert !"".equals(weather.toString());
Assert.assertNotEquals("", weather.toString());
Assert.assertNotNull(weather.toString());
weather.setTemperature(temperature);
assert !"".equals(weather.toString());
weather.setPressure(pressure);
assert !"".equals(weather.toString());
Assert.assertNotEquals("", weather.toString());
Assert.assertNotNull(weather.toString());
weather.setAtmosphericPressure(atmosphericPressure);
Assert.assertNotEquals("", weather.toString());
Assert.assertNotNull(weather.toString());
weather.setClouds(clouds);
assert !"".equals(weather.toString());
Assert.assertNotEquals("", weather.toString());
Assert.assertNotNull(weather.toString());
weather.setRain(rain);
assert !"".equals(weather.toString());
Assert.assertNotEquals("", weather.toString());
Assert.assertNotNull(weather.toString());
weather.setSnow(snow);
assert !"".equals(weather.toString());
Assert.assertNotEquals("", weather.toString());
Assert.assertNotNull(weather.toString());
}
@Test
public void whenCallHashCode_thenAllIsFine() {
final Weather one = new Weather("state", "desc");
final Weather two = new Weather("state", "desc");
final Weather one = Weather.forValue("state", "desc");
final Weather two = Weather.forValue("state", "desc");
assert one.hashCode() == two.hashCode();
Assert.assertEquals(one.hashCode(), two.hashCode());
two.setDescription("112");
assert one.hashCode() != two.hashCode();
Assert.assertEquals(one.hashCode(), two.hashCode());
}
@Test
public void whenCheckEquality_thenAllIsFine() {
final Weather one = new Weather("state", "desc");
final Weather two = new Weather("state1", "desc1");
final Weather one = Weather.forValue("state", "desc");
final Weather two = Weather.forValue("state1", "desc1");
assert one.equals(one);
assert !one.equals(new Object());
assert !one.equals(two);
Assert.assertTrue(one.equals(one));
Assert.assertFalse(one.equals(new Object()));
Assert.assertFalse(one.equals(two));
two.setState("state");
assert !one.equals(two);
Assert.assertFalse(one.equals(two));
two.setDescription("desc");
assert one.equals(two);
Assert.assertTrue(one.equals(two));
one.setWeatherIconUrl("1");
assert !one.equals(two);
Assert.assertFalse(one.equals(two));
two.setWeatherIconUrl("1");
assert one.equals(two);
Assert.assertTrue(one.equals(two));
final LocalDateTime now = LocalDateTime.now();
one.setRequestedOn(now);
assert !one.equals(two);
Assert.assertFalse(one.equals(two));
two.setRequestedOn(now);
assert one.equals(two);
Assert.assertTrue(one.equals(two));
final Temperature temperature = new Temperature(33.2, "as");
final Temperature temperature = Temperature.forValue(33.2, "as");
one.setTemperature(temperature);
assert !one.equals(two);
Assert.assertFalse(one.equals(two));
two.setTemperature(temperature);
assert one.equals(two);
Assert.assertTrue(one.equals(two));
final Pressure pressure = new Pressure(33.33);
one.setPressure(pressure);
final AtmosphericPressure atmosphericPressure = AtmosphericPressure.forValue(33.33);
one.setAtmosphericPressure(atmosphericPressure);
assert !one.equals(two);
Assert.assertFalse(one.equals(two));
two.setPressure(pressure);
two.setAtmosphericPressure(atmosphericPressure);
assert one.equals(two);
Assert.assertTrue(one.equals(two));
final Humidity humidity = new Humidity((byte) 33);
final Humidity humidity = Humidity.forValue((byte) 33);
one.setHumidity(humidity);
assert !one.equals(two);
Assert.assertFalse(one.equals(two));
two.setHumidity(humidity);
assert one.equals(two);
Assert.assertTrue(one.equals(two));
final Wind wind = new Wind(33.6, "asd");
final Wind wind = Wind.forValue(33.6, "asd");
one.setWind(wind);
assert !one.equals(two);
Assert.assertFalse(one.equals(two));
two.setWind(wind);
assert one.equals(two);
Assert.assertTrue(one.equals(two));
final Rain rain = new Rain();
one.setRain(rain);
assert !one.equals(two);
Assert.assertFalse(one.equals(two));
two.setRain(rain);
assert one.equals(two);
Assert.assertTrue(one.equals(two));
final Snow snow = new Snow();
one.setSnow(snow);
assert !one.equals(two);
Assert.assertFalse(one.equals(two));
two.setSnow(snow);
assert one.equals(two);
Assert.assertTrue(one.equals(two));
final Clouds clouds = new Clouds((byte) 33);
final Clouds clouds = Clouds.forValue((byte) 33);
one.setClouds(clouds);
assert !one.equals(two);
Assert.assertFalse(one.equals(two));
two.setClouds(clouds);
assert one.equals(two);
Assert.assertTrue(one.equals(two));
final Location location = new Location(231, "asda");
final Location location = Location.forValue(231, "asda");
one.setLocation(location);
assert !one.equals(two);
Assert.assertFalse(one.equals(two));
two.setLocation(location);
assert one.equals(two);
Assert.assertTrue(one.equals(two));
}
}
@@ -22,159 +22,158 @@
package com.github.prominence.openweathermap.api.model.weather;
import com.github.prominence.openweathermap.api.model.forecast.Wind;
import org.junit.Assert;
import org.junit.Test;
public class WindUnitTest {
@Test
public void whenCreateWindWithValidArgs_thenValueIsSet() {
assert new Wind(44, "ms").getSpeed() == 44.0;
Assert.assertEquals(44.0, Wind.forValue(44, "ms").getSpeed(), 0.00001);
}
@Test(expected = IllegalArgumentException.class)
public void whenCreateWindWithInvalidSpeedArg_thenThrowAnException() {
new Wind(-21, "a");
Wind.forValue(-21, "a");
}
@Test(expected = IllegalArgumentException.class)
public void whenCreateWindWithInvalidUnitArg_thenThrowAnException() {
new Wind(342, null);
Wind.forValue(342, null);
}
@Test
public void whenSetValidSpeed_thenValueIsSet() {
final Wind wind = new Wind(33, "as");
final Wind wind = Wind.forValue(33, "as");
assert wind.getSpeed() == 33;
Assert.assertEquals(33, wind.getSpeed(), 0.00001);
wind.setSpeed(0);
assert wind.getSpeed() == 0;
Assert.assertEquals(0, wind.getSpeed(), 0.00001);
wind.setSpeed(3656);
assert wind.getSpeed() == 3656;
Assert.assertEquals(3656, wind.getSpeed(), 0.00001);
}
@Test(expected = IllegalArgumentException.class)
public void whenSetInvalidSpeedBelow0_thenThrowAnException() {
final Wind wind = new Wind(33, "as");
final Wind wind = Wind.forValue(33, "as");
assert wind.getSpeed() == 33;
Assert.assertEquals(33, wind.getSpeed(), 0.00001);
wind.setSpeed(-22);
assert false;
}
@Test
public void whenSetValidDegrees_thenValueIsSet() {
final Wind wind = new Wind(33, "as");
final Wind wind = Wind.forValue(33, "as");
assert wind.getDegrees() == null;
Assert.assertNull(wind.getDegrees());
wind.setDegrees(22);
assert wind.getDegrees() == 22;
Assert.assertEquals(22, wind.getDegrees(), 0.00001);
wind.setDegrees(0);
assert wind.getDegrees() == 0;
Assert.assertEquals(0, wind.getDegrees(), 0.00001);
wind.setDegrees(360);
assert wind.getDegrees() == 360;
Assert.assertEquals(360, wind.getDegrees(), 0.00001);
}
@Test(expected = IllegalArgumentException.class)
public void whenSetInvalidDegreesBelow0_thenThrowAnException() {
final Wind wind = new Wind(33, "as");
final Wind wind = Wind.forValue(33, "as");
wind.setDegrees(-32);
}
@Test(expected = IllegalArgumentException.class)
public void whenSetInvalidDegreesAbove360_thenThrowAnException() {
final Wind wind = new Wind(33, "as");
final Wind wind = Wind.forValue(33, "as");
wind.setDegrees(378);
}
@Test
public void whenSetNonNullUnit_thenValueIsSet() {
final Wind wind = new Wind(33, "as");
final Wind wind = Wind.forValue(33, "as");
assert "as".equals(wind.getUnit());
Assert.assertEquals(wind.getUnit(), "as");
wind.setUnit("myUnit");
assert "myUnit".equals(wind.getUnit());
Assert.assertEquals(wind.getUnit(), "myUnit");
}
@Test(expected = IllegalArgumentException.class)
public void whenSetNullUnit_thenThrowAnException() {
final Wind wind = new Wind(33, "as");
final Wind wind = Wind.forValue(33, "as");
wind.setUnit(null);
}
@Test
public void whenCallToString_thenAllIsFine() {
final Wind wind = new Wind(302, "a");
final Wind wind = Wind.forValue(302, "a");
assert wind.toString() != null;
Assert.assertNotNull(wind.toString());
wind.setDegrees(22);
assert wind.toString() != null && !"".equals(wind.toString());
Assert.assertNotNull(wind.toString());
Assert.assertNotEquals("", wind.toString());
}
@Test
public void RainwhenCallHashCode_thenAllIsFine() {
final Wind first = new Wind(22, "a");
final Wind second = new Wind(22, "b");
public void whenCallHashCode_thenAllIsFine() {
final Wind first = Wind.forValue(22, "a");
final Wind second = Wind.forValue(22, "b");
assert first.hashCode() != second.hashCode();
Assert.assertNotEquals(first.hashCode(), second.hashCode());
second.setUnit("a");
assert first.hashCode() == second.hashCode();
Assert.assertEquals(first.hashCode(), second.hashCode());
second.setSpeed(33);
assert first.hashCode() != second.hashCode();
Assert.assertNotEquals(first.hashCode(), second.hashCode());
first.setSpeed(333);
assert first.hashCode() != second.hashCode();
Assert.assertNotEquals(first.hashCode(), second.hashCode());
first.setSpeed(33);
assert first.hashCode() == second.hashCode();
Assert.assertEquals(first.hashCode(), second.hashCode());
}
@Test
public void whenCheckEquality_thenAllIsFine() {
final Wind first = new Wind(11, "a");
final Wind second = new Wind(11, "a");
final Wind first = Wind.forValue(11, "a");
final Wind second = Wind.forValue(11, "a");
assert first.equals(second);
assert first.equals(first);
assert !first.equals(new Object());
Assert.assertTrue(first.equals(second));
Assert.assertTrue(first.equals(first));
Assert.assertFalse(first.equals(new Object()));
first.setDegrees(34);
assert !first.equals(second);
Assert.assertFalse(first.equals(second));
second.setDegrees(34);
assert first.equals(second);
Assert.assertTrue(first.equals(second));
second.setUnit("v");
assert !first.equals(second);
Assert.assertFalse(first.equals(second));
first.setUnit("v");
first.setSpeed(second.getSpeed() + 4);
assert !first.equals(second);
Assert.assertFalse(first.equals(second));
}
}
@@ -26,12 +26,13 @@ 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.model.forecast.Forecast;
import org.junit.Assert;
import org.junit.Test;
public class FiveDayThreeHourStepForecastIntegrationTest extends ApiTest {
@Test
public void whenGetTest_thenReturnNotNull() {
public void whenGetJavaObject_thenReturnNotNull() {
final Forecast forecast = getClient()
.forecast5Day3HourStep()
.byCityName("Minsk")
@@ -41,7 +42,20 @@ public class FiveDayThreeHourStepForecastIntegrationTest extends ApiTest {
.retrieve()
.asJava();
assert forecast != null;
Assert.assertNotNull(forecast);
System.out.println(forecast);
}
@Test
public void whenGetJavaObject_thenFieldsAreFilled() {
final Forecast forecast = getClient()
.forecast5Day3HourStep()
.byCityName("London")
.language(Language.ENGLISH)
.retrieve()
.asJava();
Assert.assertNotNull(forecast);
System.out.println(forecast);
}
}
@@ -31,6 +31,7 @@ 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.Assert;
import org.junit.Test;
import java.util.List;
@@ -44,14 +45,14 @@ public class MultipleResultCurrentWeatherIntegrationTest extends ApiTest {
final List<Weather> weatherList = getClient()
.currentWeather()
.multiple()
.byRectangle(new CoordinateRectangle(12, 32, 15, 37), 10)
.byRectangle(CoordinateRectangle.forValues(12, 32, 15, 37), 10)
.language(Language.ROMANIAN)
.unitSystem(UnitSystem.METRIC)
.retrieve()
.asJava();
assert weatherList != null;
assert weatherList.size() > 0;
Assert.assertNotNull(weatherList);
Assert.assertTrue(weatherList.size() > 0);
System.out.println(weatherList);
}
@@ -60,14 +61,14 @@ public class MultipleResultCurrentWeatherIntegrationTest extends ApiTest {
final List<Weather> weatherList = getClient()
.currentWeather()
.multiple()
.byRectangle(new CoordinateRectangle(12, 32, 15, 37), 10, true)
.byRectangle(CoordinateRectangle.forValues(12, 32, 15, 37), 10, true)
.language(Language.ROMANIAN)
.unitSystem(UnitSystem.METRIC)
.retrieve()
.asJava();
assert weatherList != null;
assert weatherList.size() > 0;
Assert.assertNotNull(weatherList);
Assert.assertTrue(weatherList.size() > 0);
System.out.println(weatherList);
}
@@ -76,14 +77,14 @@ public class MultipleResultCurrentWeatherIntegrationTest extends ApiTest {
final List<Weather> weatherList = getClient()
.currentWeather()
.multiple()
.byCitiesInCycle(new Coordinate(55.5, 37.5), 10)
.byCitiesInCycle(Coordinate.forValues(55.5, 37.5), 10)
.language(Language.GERMAN)
.unitSystem(UnitSystem.IMPERIAL)
.retrieve()
.asJava();
assert weatherList != null;
assert weatherList.size() > 0;
Assert.assertNotNull(weatherList);
Assert.assertTrue(weatherList.size() > 0);
System.out.println(weatherList);
}
@@ -92,14 +93,14 @@ public class MultipleResultCurrentWeatherIntegrationTest extends ApiTest {
final List<Weather> weatherList = getClient()
.currentWeather()
.multiple()
.byCitiesInCycle(new Coordinate(55.5, 37.5), 10, true)
.byCitiesInCycle(Coordinate.forValues(55.5, 37.5), 10, true)
.language(Language.GERMAN)
.unitSystem(UnitSystem.IMPERIAL)
.retrieve()
.asJava();
assert weatherList != null;
assert weatherList.size() > 0;
Assert.assertNotNull(weatherList);
Assert.assertTrue(weatherList.size() > 0);
System.out.println(weatherList);
}
@@ -108,13 +109,13 @@ public class MultipleResultCurrentWeatherIntegrationTest extends ApiTest {
final String weather = getClient()
.currentWeather()
.multiple()
.byCitiesInCycle(new Coordinate(55.5, 37.5), 10)
.byCitiesInCycle(Coordinate.forValues(55.5, 37.5), 10)
.language(Language.GERMAN)
.unitSystem(UnitSystem.IMPERIAL)
.retrieve()
.asJSON();
assert weather != null;
Assert.assertNotNull(weather);
System.out.println(weather);
}
@@ -123,13 +124,13 @@ public class MultipleResultCurrentWeatherIntegrationTest extends ApiTest {
final String weather = getClient()
.currentWeather()
.multiple()
.byCitiesInCycle(new Coordinate(55.5, 37.5), 10)
.byCitiesInCycle(Coordinate.forValues(55.5, 37.5), 10)
.language(Language.GERMAN)
.unitSystem(UnitSystem.IMPERIAL)
.retrieve()
.asXML();
assert weather != null;
Assert.assertNotNull(weather);
System.out.println(weather);
}
@@ -138,13 +139,13 @@ public class MultipleResultCurrentWeatherIntegrationTest extends ApiTest {
final String weather = getClient()
.currentWeather()
.multiple()
.byCitiesInCycle(new Coordinate(55.5, 37.5), 10)
.byCitiesInCycle(Coordinate.forValues(55.5, 37.5), 10)
.language(Language.GERMAN)
.unitSystem(UnitSystem.IMPERIAL)
.retrieve()
.asHTML();
assert weather != null;
Assert.assertNotNull(weather);
System.out.println(weather);
}
@@ -153,15 +154,15 @@ public class MultipleResultCurrentWeatherIntegrationTest extends ApiTest {
final CompletableFuture<List<Weather>> weatherListFuture = getClient()
.currentWeather()
.multiple()
.byCitiesInCycle(new Coordinate(55.5, 37.5), 10, true)
.byCitiesInCycle(Coordinate.forValues(55.5, 37.5), 10, true)
.language(Language.GERMAN)
.unitSystem(UnitSystem.IMPERIAL)
.retrieveAsync()
.asJava();
assert weatherListFuture != null;
Assert.assertNotNull(weatherListFuture);
List<Weather> weatherList = weatherListFuture.get();
assert weatherList.size() > 0;
Assert.assertTrue(weatherList.size() > 0);
System.out.println(weatherList);
}
@@ -170,13 +171,13 @@ public class MultipleResultCurrentWeatherIntegrationTest extends ApiTest {
final CompletableFuture<String> weatherFuture = getClient()
.currentWeather()
.multiple()
.byCitiesInCycle(new Coordinate(55.5, 37.5), 10, true)
.byCitiesInCycle(Coordinate.forValues(55.5, 37.5), 10, true)
.language(Language.GERMAN)
.unitSystem(UnitSystem.IMPERIAL)
.retrieveAsync()
.asXML();
assert weatherFuture != null;
Assert.assertNotNull(weatherFuture);
System.out.println(weatherFuture.get());
}
@@ -185,13 +186,13 @@ public class MultipleResultCurrentWeatherIntegrationTest extends ApiTest {
final CompletableFuture<String> weatherFuture = getClient()
.currentWeather()
.multiple()
.byCitiesInCycle(new Coordinate(55.5, 37.5), 10, true)
.byCitiesInCycle(Coordinate.forValues(55.5, 37.5), 10, true)
.language(Language.GERMAN)
.unitSystem(UnitSystem.IMPERIAL)
.retrieveAsync()
.asJSON();
assert weatherFuture != null;
Assert.assertNotNull(weatherFuture);
System.out.println(weatherFuture.get());
}
@@ -200,13 +201,13 @@ public class MultipleResultCurrentWeatherIntegrationTest extends ApiTest {
final CompletableFuture<String> weatherFuture = getClient()
.currentWeather()
.multiple()
.byCitiesInCycle(new Coordinate(55.5, 37.5), 10, true)
.byCitiesInCycle(Coordinate.forValues(55.5, 37.5), 10, true)
.language(Language.GERMAN)
.unitSystem(UnitSystem.IMPERIAL)
.retrieveAsync()
.asHTML();
assert weatherFuture != null;
Assert.assertNotNull(weatherFuture);
System.out.println(weatherFuture.get());
}
@@ -30,6 +30,7 @@ import com.github.prominence.openweathermap.api.exception.NoDataFoundException;
import com.github.prominence.openweathermap.api.model.Coordinate;
import com.github.prominence.openweathermap.api.model.weather.Weather;
import com.github.prominence.openweathermap.api.OpenWeatherMapClient;
import org.junit.Assert;
import org.junit.Test;
import java.util.concurrent.CompletableFuture;
@@ -42,12 +43,12 @@ public class SingleResultCurrentWeatherIntegrationTest extends ApiTest {
final Weather weather = getClient()
.currentWeather()
.single()
.byCoordinate(new Coordinate(5, 5))
.byCoordinate(Coordinate.forValues(5, 5))
.unitSystem(UnitSystem.METRIC)
.retrieve()
.asJava();
assert weather != null;
Assert.assertNotNull(weather);
System.out.println(weather);
}
@@ -61,7 +62,7 @@ public class SingleResultCurrentWeatherIntegrationTest extends ApiTest {
.retrieve()
.asJava();
assert weather != null;
Assert.assertNotNull(weather);
System.out.println(weather);
}
@@ -76,7 +77,7 @@ public class SingleResultCurrentWeatherIntegrationTest extends ApiTest {
.retrieve()
.asJava();
assert weather != null;
Assert.assertNotNull(weather);
System.out.println(weather);
}
@@ -91,7 +92,7 @@ public class SingleResultCurrentWeatherIntegrationTest extends ApiTest {
.retrieve()
.asJava();
assert weather != null;
Assert.assertNotNull(weather);
System.out.println(weather);
}
@@ -106,7 +107,7 @@ public class SingleResultCurrentWeatherIntegrationTest extends ApiTest {
.retrieve()
.asJava();
assert weather != null;
Assert.assertNotNull(weather);
System.out.println(weather);
}
@@ -121,7 +122,7 @@ public class SingleResultCurrentWeatherIntegrationTest extends ApiTest {
.retrieve()
.asJSON();
assert weatherJson != null;
Assert.assertNotNull(weatherJson);
System.out.println(weatherJson);
}
@@ -136,7 +137,7 @@ public class SingleResultCurrentWeatherIntegrationTest extends ApiTest {
.retrieve()
.asXML();
assert weatherXml != null;
Assert.assertNotNull(weatherXml);
System.out.println(weatherXml);
}
@@ -151,7 +152,7 @@ public class SingleResultCurrentWeatherIntegrationTest extends ApiTest {
.retrieve()
.asHTML();
assert weatherHtml != null;
Assert.assertNotNull(weatherHtml);
System.out.println(weatherHtml);
}
@@ -166,7 +167,7 @@ public class SingleResultCurrentWeatherIntegrationTest extends ApiTest {
.retrieveAsync()
.asXML();
assert weatherXmlFuture != null;
Assert.assertNotNull(weatherXmlFuture);
System.out.println(weatherXmlFuture.get());
}
@@ -181,7 +182,7 @@ public class SingleResultCurrentWeatherIntegrationTest extends ApiTest {
.retrieveAsync()
.asJava();
assert weatherFuture != null;
Assert.assertNotNull(weatherFuture);
System.out.println(weatherFuture.get());
}
@@ -196,7 +197,7 @@ public class SingleResultCurrentWeatherIntegrationTest extends ApiTest {
.retrieveAsync()
.asJSON();
assert weatherFuture != null;
Assert.assertNotNull(weatherFuture);
System.out.println(weatherFuture.get());
}
@@ -211,7 +212,7 @@ public class SingleResultCurrentWeatherIntegrationTest extends ApiTest {
.retrieveAsync()
.asHTML();
assert weatherFuture != null;
Assert.assertNotNull(weatherFuture);
System.out.println(weatherFuture.get());
}
@@ -221,7 +222,7 @@ public class SingleResultCurrentWeatherIntegrationTest extends ApiTest {
client
.currentWeather()
.multiple()
.byCitiesInCycle(new Coordinate(34.53, 66.74), 10)
.byCitiesInCycle(Coordinate.forValues(34.53, 66.74), 10)
.retrieve()
.asJSON();
}
@@ -231,7 +232,7 @@ public class SingleResultCurrentWeatherIntegrationTest extends ApiTest {
getClient()
.currentWeather()
.multiple()
.byCitiesInCycle(new Coordinate(90.00, 66.74), 10)
.byCitiesInCycle(Coordinate.forValues(90.00, 66.74), 10)
.retrieve()
.asJava();
}