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
@@ -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();
}