DATACMNS-1718 - Migrate tests to JUnit 5.
This commit is contained in:
@@ -17,7 +17,7 @@ package org.springframework.data.geo;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.util.SerializationUtils;
|
||||
|
||||
/**
|
||||
@@ -26,14 +26,14 @@ import org.springframework.util.SerializationUtils;
|
||||
* @author Oliver Gierke
|
||||
* @author Thomas Darimont
|
||||
*/
|
||||
public class BoxUnitTests {
|
||||
class BoxUnitTests {
|
||||
|
||||
Box first = new Box(new Point(1d, 1d), new Point(2d, 2d));
|
||||
Box second = new Box(new Point(1d, 1d), new Point(2d, 2d));
|
||||
Box third = new Box(new Point(3d, 3d), new Point(1d, 1d));
|
||||
|
||||
@Test // DATACMNS-437
|
||||
public void equalsWorksCorrectly() {
|
||||
void equalsWorksCorrectly() {
|
||||
|
||||
assertThat(first.equals(second)).isTrue();
|
||||
assertThat(second.equals(first)).isTrue();
|
||||
@@ -41,20 +41,20 @@ public class BoxUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-437
|
||||
public void hashCodeWorksCorrectly() {
|
||||
void hashCodeWorksCorrectly() {
|
||||
|
||||
assertThat(first.hashCode()).isEqualTo(second.hashCode());
|
||||
assertThat(first.hashCode()).isNotEqualTo(third.hashCode());
|
||||
}
|
||||
|
||||
@Test // DATACMNS-437
|
||||
public void testToString() {
|
||||
void testToString() {
|
||||
|
||||
assertThat(first.toString()).isEqualTo("Box [Point [x=1.000000, y=1.000000], Point [x=2.000000, y=2.000000]]");
|
||||
}
|
||||
|
||||
@Test // DATACMNS-482
|
||||
public void testSerialization() {
|
||||
void testSerialization() {
|
||||
|
||||
Box serialized = (Box) SerializationUtils.deserialize(SerializationUtils.serialize(first));
|
||||
assertThat(serialized).isEqualTo(first);
|
||||
|
||||
@@ -17,7 +17,7 @@ package org.springframework.data.geo;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.util.SerializationUtils;
|
||||
|
||||
/**
|
||||
@@ -26,20 +26,20 @@ import org.springframework.util.SerializationUtils;
|
||||
* @author Oliver Gierke
|
||||
* @author Thomas Darimont
|
||||
*/
|
||||
public class CircleUnitTests {
|
||||
class CircleUnitTests {
|
||||
|
||||
@Test // DATACMNS-437
|
||||
public void rejectsNullOrigin() {
|
||||
void rejectsNullOrigin() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new Circle(null, new Distance(0)));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-437
|
||||
public void rejectsNegativeRadius() {
|
||||
void rejectsNegativeRadius() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new Circle(1, 1, -1));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-437
|
||||
public void considersTwoCirclesEqualCorrectly() {
|
||||
void considersTwoCirclesEqualCorrectly() {
|
||||
|
||||
Circle left = new Circle(1, 1, 1);
|
||||
Circle right = new Circle(1, 1, 1);
|
||||
@@ -54,13 +54,13 @@ public class CircleUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-437
|
||||
public void testToString() {
|
||||
void testToString() {
|
||||
|
||||
assertThat(new Circle(1, 1, 1).toString()).isEqualTo("Circle: [center=Point [x=1.000000, y=1.000000], radius=1.0]");
|
||||
}
|
||||
|
||||
@Test // DATACMNS-482
|
||||
public void testSerialization() {
|
||||
void testSerialization() {
|
||||
|
||||
Circle circle = new Circle(1, 1, 1);
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.geo.Metrics.*;
|
||||
|
||||
import org.assertj.core.data.Offset;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.data.domain.Range;
|
||||
import org.springframework.data.domain.Range.Bound;
|
||||
import org.springframework.util.SerializationUtils;
|
||||
@@ -31,19 +31,19 @@ import org.springframework.util.SerializationUtils;
|
||||
* @author Thomas Darimont
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class DistanceUnitTests {
|
||||
class DistanceUnitTests {
|
||||
|
||||
private static final Offset<Double> EPS = Offset.offset(0.000000001);
|
||||
private static final double TEN_MILES_NORMALIZED = 0.002523219294755161;
|
||||
private static final double TEN_KM_NORMALIZED = 0.001567855942887398;
|
||||
|
||||
@Test // DATACMNS-437
|
||||
public void defaultsMetricToNeutralOne() {
|
||||
void defaultsMetricToNeutralOne() {
|
||||
assertThat(new Distance(2.5).getMetric()).isEqualTo((Metric) Metrics.NEUTRAL);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-437
|
||||
public void addsDistancesWithoutExplicitMetric() {
|
||||
void addsDistancesWithoutExplicitMetric() {
|
||||
|
||||
Distance left = new Distance(2.5, KILOMETERS);
|
||||
Distance right = new Distance(2.5, KILOMETERS);
|
||||
@@ -52,7 +52,7 @@ public class DistanceUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-437
|
||||
public void addsDistancesWithExplicitMetric() {
|
||||
void addsDistancesWithExplicitMetric() {
|
||||
|
||||
Distance left = new Distance(2.5, KILOMETERS);
|
||||
Distance right = new Distance(2.5, KILOMETERS);
|
||||
@@ -61,7 +61,7 @@ public class DistanceUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-474
|
||||
public void distanceWithSameMetricShoudEqualAfterConversion() {
|
||||
void distanceWithSameMetricShoudEqualAfterConversion() {
|
||||
|
||||
assertThat(new Distance(1).in(NEUTRAL)).isEqualTo(new Distance(1));
|
||||
assertThat(new Distance(TEN_KM_NORMALIZED).in(KILOMETERS)).isEqualTo(new Distance(10, KILOMETERS));
|
||||
@@ -69,14 +69,14 @@ public class DistanceUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-474
|
||||
public void distanceWithDifferentMetricShoudEqualAfterConversion() {
|
||||
void distanceWithDifferentMetricShoudEqualAfterConversion() {
|
||||
|
||||
assertThat(new Distance(10, MILES)).isEqualTo(new Distance(TEN_MILES_NORMALIZED).in(MILES));
|
||||
assertThat(new Distance(10, KILOMETERS)).isEqualTo(new Distance(TEN_KM_NORMALIZED).in(KILOMETERS));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-474
|
||||
public void conversionShouldProduceCorrectNormalizedValue() {
|
||||
void conversionShouldProduceCorrectNormalizedValue() {
|
||||
|
||||
assertThat(new Distance(TEN_KM_NORMALIZED, NEUTRAL).in(KILOMETERS).getNormalizedValue())
|
||||
.isCloseTo(new Distance(10, KILOMETERS).getNormalizedValue(), EPS);
|
||||
@@ -98,7 +98,7 @@ public class DistanceUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-474
|
||||
public void toStringAfterConversion() {
|
||||
void toStringAfterConversion() {
|
||||
|
||||
assertThat(new Distance(10, KILOMETERS).in(MILES).toString())
|
||||
.isEqualTo(new Distance(6.21371256214785, MILES).toString());
|
||||
@@ -107,7 +107,7 @@ public class DistanceUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-482
|
||||
public void testSerialization() {
|
||||
void testSerialization() {
|
||||
|
||||
Distance dist = new Distance(10, KILOMETERS);
|
||||
|
||||
@@ -116,12 +116,12 @@ public class DistanceUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-626
|
||||
public void returnsMetricsAbbreviationAsUnit() {
|
||||
void returnsMetricsAbbreviationAsUnit() {
|
||||
assertThat(new Distance(10, KILOMETERS).getUnit()).isEqualTo("km");
|
||||
}
|
||||
|
||||
@Test // DATACMNS-651
|
||||
public void createsARangeCorrectly() {
|
||||
void createsARangeCorrectly() {
|
||||
|
||||
Distance twoKilometers = new Distance(2, KILOMETERS);
|
||||
Distance tenKilometers = new Distance(10, KILOMETERS);
|
||||
@@ -134,7 +134,7 @@ public class DistanceUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-651
|
||||
public void createsARangeFromPiecesCorrectly() {
|
||||
void createsARangeFromPiecesCorrectly() {
|
||||
|
||||
Distance twoKilometers = new Distance(2, KILOMETERS);
|
||||
Distance tenKilometers = new Distance(10, KILOMETERS);
|
||||
@@ -147,7 +147,7 @@ public class DistanceUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-651
|
||||
public void implementsComparableCorrectly() {
|
||||
void implementsComparableCorrectly() {
|
||||
|
||||
Distance twoKilometers = new Distance(2, KILOMETERS);
|
||||
Distance tenKilometers = new Distance(10, KILOMETERS);
|
||||
|
||||
@@ -17,8 +17,8 @@ package org.springframework.data.geo;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
@@ -27,19 +27,19 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
public class GeoModuleIntegrationTests {
|
||||
class GeoModuleIntegrationTests {
|
||||
|
||||
ObjectMapper mapper;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
|
||||
this.mapper = new ObjectMapper();
|
||||
this.mapper.registerModule(new GeoModule());
|
||||
}
|
||||
|
||||
@Test // DATACMNS-475
|
||||
public void deserializesDistance() throws Exception {
|
||||
void deserializesDistance() throws Exception {
|
||||
|
||||
String json = "{\"value\":10.0,\"metric\":\"KILOMETERS\"}";
|
||||
Distance reference = new Distance(10.0, Metrics.KILOMETERS);
|
||||
@@ -49,7 +49,7 @@ public class GeoModuleIntegrationTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-475
|
||||
public void deserializesPoint() throws Exception {
|
||||
void deserializesPoint() throws Exception {
|
||||
|
||||
String json = "{\"x\":10.0,\"y\":20.0}";
|
||||
Point reference = new Point(10.0, 20.0);
|
||||
@@ -59,7 +59,7 @@ public class GeoModuleIntegrationTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-475
|
||||
public void deserializesCircle() throws Exception {
|
||||
void deserializesCircle() throws Exception {
|
||||
|
||||
String json = "{\"center\":{\"x\":10.0,\"y\":20.0},\"radius\":{\"value\":10.0,\"metric\":\"KILOMETERS\"}}";
|
||||
Circle reference = new Circle(new Point(10.0, 20.0), new Distance(10, Metrics.KILOMETERS));
|
||||
@@ -69,7 +69,7 @@ public class GeoModuleIntegrationTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-475
|
||||
public void deserializesBox() throws Exception {
|
||||
void deserializesBox() throws Exception {
|
||||
|
||||
String json = "{\"first\":{\"x\":1.0,\"y\":2.0},\"second\":{\"x\":2.0,\"y\":3.0}}";
|
||||
Box reference = new Box(new Point(1, 2), new Point(2, 3));
|
||||
@@ -79,7 +79,7 @@ public class GeoModuleIntegrationTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-475
|
||||
public void deserializesPolygon() throws Exception {
|
||||
void deserializesPolygon() throws Exception {
|
||||
|
||||
String json = "{\"points\":[{\"x\":1.0,\"y\":2.0},{\"x\":2.0,\"y\":3.0},{\"x\":3.0,\"y\":4.0}]}";
|
||||
Polygon reference = new Polygon(new Point(1, 2), new Point(2, 3), new Point(3, 4));
|
||||
|
||||
@@ -17,7 +17,7 @@ package org.springframework.data.geo;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.util.SerializationUtils;
|
||||
|
||||
/**
|
||||
@@ -26,7 +26,7 @@ import org.springframework.util.SerializationUtils;
|
||||
* @author Oliver Gierke
|
||||
* @author Thomas Darimont
|
||||
*/
|
||||
public class GeoResultUnitTests {
|
||||
class GeoResultUnitTests {
|
||||
|
||||
GeoResult<String> first = new GeoResult<>("Foo", new Distance(2.5));
|
||||
GeoResult<String> second = new GeoResult<>("Foo", new Distance(2.5));
|
||||
@@ -34,13 +34,13 @@ public class GeoResultUnitTests {
|
||||
GeoResult<String> fourth = new GeoResult<>("Foo", new Distance(5.2));
|
||||
|
||||
@Test // DATACMNS-437
|
||||
public void considersSameInstanceEqual() {
|
||||
void considersSameInstanceEqual() {
|
||||
|
||||
assertThat(first.equals(first)).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-437
|
||||
public void considersSameValuesAsEqual() {
|
||||
void considersSameValuesAsEqual() {
|
||||
|
||||
assertThat(first.equals(second)).isTrue();
|
||||
assertThat(second.equals(first)).isTrue();
|
||||
@@ -53,12 +53,12 @@ public class GeoResultUnitTests {
|
||||
@Test
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
// DATACMNS-437
|
||||
public void rejectsNullContent() {
|
||||
void rejectsNullContent() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new GeoResult(null, new Distance(2.5)));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-482
|
||||
public void testSerialization() {
|
||||
void testSerialization() {
|
||||
|
||||
GeoResult<String> result = new GeoResult<>("test", new Distance(2));
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import static org.assertj.core.api.Assertions.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.util.SerializationUtils;
|
||||
|
||||
/**
|
||||
@@ -29,11 +29,11 @@ import org.springframework.util.SerializationUtils;
|
||||
* @author Oliver Gierke
|
||||
* @author Thomas Darimont
|
||||
*/
|
||||
public class GeoResultsUnitTests {
|
||||
class GeoResultsUnitTests {
|
||||
|
||||
@Test // DATACMNS-437
|
||||
@SuppressWarnings("unchecked")
|
||||
public void calculatesAverageForGivenGeoResults() {
|
||||
void calculatesAverageForGivenGeoResults() {
|
||||
|
||||
GeoResult<Object> first = new GeoResult<>(new Object(), new Distance(2));
|
||||
GeoResult<Object> second = new GeoResult<>(new Object(), new Distance(5));
|
||||
@@ -43,7 +43,7 @@ public class GeoResultsUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-482
|
||||
public void testSerialization() {
|
||||
void testSerialization() {
|
||||
|
||||
GeoResult<String> result = new GeoResult<>("test", new Distance(2));
|
||||
GeoResults<String> geoResults = new GeoResults<>(Collections.singletonList(result));
|
||||
|
||||
@@ -17,7 +17,7 @@ package org.springframework.data.geo;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.util.SerializationUtils;
|
||||
|
||||
/**
|
||||
@@ -26,15 +26,15 @@ import org.springframework.util.SerializationUtils;
|
||||
* @author Oliver Gierke
|
||||
* @author Thomas Darimont
|
||||
*/
|
||||
public class PointUnitTests {
|
||||
class PointUnitTests {
|
||||
|
||||
@Test // DATACMNS-437
|
||||
public void rejectsNullforCopyConstructor() {
|
||||
void rejectsNullforCopyConstructor() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new Point(null));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-437
|
||||
public void equalsIsImplementedCorrectly() {
|
||||
void equalsIsImplementedCorrectly() {
|
||||
|
||||
assertThat(new Point(1.5, 1.5)).isEqualTo(new Point(1.5, 1.5));
|
||||
assertThat(new Point(1.5, 1.5)).isNotEqualTo(new Point(2.0, 2.0));
|
||||
@@ -42,12 +42,12 @@ public class PointUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-437
|
||||
public void invokingToStringWorksCorrectly() {
|
||||
void invokingToStringWorksCorrectly() {
|
||||
assertThat(new Point(1.5, 1.5).toString()).isEqualTo("Point [x=1.500000, y=1.500000]");
|
||||
}
|
||||
|
||||
@Test // DATACMNS-482
|
||||
public void testSerialization() {
|
||||
void testSerialization() {
|
||||
|
||||
Point point = new Point(1.5, 1.5);
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ package org.springframework.data.geo;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.util.SerializationUtils;
|
||||
|
||||
/**
|
||||
@@ -26,19 +26,19 @@ import org.springframework.util.SerializationUtils;
|
||||
* @author Oliver Gierke
|
||||
* @author Thomas Darimont
|
||||
*/
|
||||
public class PolygonUnitTests {
|
||||
class PolygonUnitTests {
|
||||
|
||||
Point first = new Point(1, 1);
|
||||
Point second = new Point(2, 2);
|
||||
Point third = new Point(3, 3);
|
||||
|
||||
@Test // DATACMNS-437
|
||||
public void rejectsNullPoints() {
|
||||
void rejectsNullPoints() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new Polygon(null, null, null));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-437
|
||||
public void createsSimplePolygon() {
|
||||
void createsSimplePolygon() {
|
||||
|
||||
Polygon polygon = new Polygon(third, second, first);
|
||||
|
||||
@@ -46,7 +46,7 @@ public class PolygonUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-437
|
||||
public void isEqualForSamePoints() {
|
||||
void isEqualForSamePoints() {
|
||||
|
||||
Polygon left = new Polygon(third, second, first);
|
||||
Polygon right = new Polygon(third, second, first);
|
||||
@@ -56,14 +56,14 @@ public class PolygonUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-437
|
||||
public void testToString() {
|
||||
void testToString() {
|
||||
|
||||
assertThat(new Polygon(third, second, first).toString()).isEqualTo(
|
||||
"Polygon: [Point [x=3.000000, y=3.000000],Point [x=2.000000, y=2.000000],Point [x=1.000000, y=1.000000]]");
|
||||
}
|
||||
|
||||
@Test // DATACMNS-482
|
||||
public void testSerialization() {
|
||||
void testSerialization() {
|
||||
|
||||
Polygon polygon = new Polygon(third, second, first);
|
||||
|
||||
|
||||
@@ -23,12 +23,10 @@ import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.runners.Enclosed;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.runners.Parameterized.Parameter;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
import org.springframework.data.geo.Distance;
|
||||
import org.springframework.data.geo.Metrics;
|
||||
|
||||
@@ -37,54 +35,40 @@ import org.springframework.data.geo.Metrics;
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@RunWith(Enclosed.class)
|
||||
public class DistanceFormatterUnitTests {
|
||||
class DistanceFormatterUnitTests {
|
||||
|
||||
static Distance REFERENCE = new Distance(10.8, Metrics.KILOMETERS);
|
||||
|
||||
@Test
|
||||
public void testname() {
|
||||
// To make sure Maven picks up the tests
|
||||
@Test // DATAREST-279, DATACMNS-626
|
||||
void rejectsArbitraryNonsense() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> INSTANCE.convert("foo"));
|
||||
}
|
||||
|
||||
public static class UnparameterizedTests {
|
||||
|
||||
@Test // DATAREST-279, DATACMNS-626
|
||||
public void rejectsArbitraryNonsense() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> INSTANCE.convert("foo"));
|
||||
}
|
||||
|
||||
@Test // DATAREST-279, DATACMNS-626
|
||||
public void rejectsUnsupportedMetric() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> INSTANCE.convert("10.8cm"));
|
||||
}
|
||||
|
||||
@Test // DATAREST-279, DATACMNS-626
|
||||
public void printsDistance() {
|
||||
assertThat(INSTANCE.print(REFERENCE, Locale.US)).isEqualTo("10.8km");
|
||||
}
|
||||
@Test // DATAREST-279, DATACMNS-626
|
||||
void rejectsUnsupportedMetric() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> INSTANCE.convert("10.8cm"));
|
||||
}
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
public static class ParameterizedTests {
|
||||
@Test // DATAREST-279, DATACMNS-626
|
||||
void printsDistance() {
|
||||
assertThat(INSTANCE.print(REFERENCE, Locale.US)).isEqualTo("10.8km");
|
||||
}
|
||||
|
||||
@Parameters
|
||||
public static Collection<String[]> parameters() {
|
||||
return Arrays.asList(new String[] { "10.8km" }, new String[] { " 10.8km" }, new String[] { " 10.8 km" },
|
||||
new String[] { " 10.8 km " }, new String[] { " 10.8 KM" }, new String[] { " 10.8 kilometers" },
|
||||
new String[] { " 10.8 KILOMETERS" }, new String[] { " 10.8 KILOMETERS " });
|
||||
}
|
||||
static Collection<String[]> parameters() {
|
||||
return Arrays.asList(new String[] { "10.8km" }, new String[] { " 10.8km" }, new String[] { " 10.8 km" },
|
||||
new String[] { " 10.8 km " }, new String[] { " 10.8 KM" }, new String[] { " 10.8 kilometers" },
|
||||
new String[] { " 10.8 KILOMETERS" }, new String[] { " 10.8 KILOMETERS " });
|
||||
}
|
||||
|
||||
public @Parameter String source;
|
||||
@ParameterizedTest // DATAREST-279, DATACMNS-626
|
||||
@MethodSource("parameters")
|
||||
void parsesDistanceFromString(String source) {
|
||||
assertThat(INSTANCE.convert(source)).isEqualTo(REFERENCE);
|
||||
}
|
||||
|
||||
@Test // DATAREST-279, DATACMNS-626
|
||||
public void parsesDistanceFromString() {
|
||||
assertThat(INSTANCE.convert(source)).isEqualTo(REFERENCE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parsesDistances() throws ParseException {
|
||||
assertThat(INSTANCE.parse(source, Locale.US)).isEqualTo(REFERENCE);
|
||||
}
|
||||
@ParameterizedTest
|
||||
@MethodSource("parameters")
|
||||
void parsesDistances(String source) throws ParseException {
|
||||
assertThat(INSTANCE.parse(source, Locale.US)).isEqualTo(REFERENCE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,12 +23,9 @@ import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.runners.Enclosed;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.runners.Parameterized.Parameter;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
import org.springframework.data.geo.Point;
|
||||
|
||||
@@ -37,53 +34,47 @@ import org.springframework.data.geo.Point;
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@RunWith(Enclosed.class)
|
||||
public class PointFormatterUnitTests {
|
||||
class PointFormatterUnitTests {
|
||||
|
||||
static Point REFERENCE = new Point(20.9, 10.8);
|
||||
|
||||
@Test
|
||||
public void testname() {
|
||||
void testname() {
|
||||
// To make sure Maven picks up the tests
|
||||
}
|
||||
|
||||
public static class UnparameterizedTests {
|
||||
|
||||
@Test // DATAREST-279, DATACMNS-626
|
||||
public void rejectsArbitraryNonsense() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> INSTANCE.convert("foo")).withMessageContaining("comma");
|
||||
}
|
||||
|
||||
@Test // DATAREST-279, DATACMNS-626
|
||||
public void rejectsMoreThanTwoCoordinates() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> INSTANCE.convert("10.8,20.9,30.10"));
|
||||
}
|
||||
|
||||
@Test // DATAREST-279, DATACMNS-626
|
||||
public void rejectsInvalidCoordinate() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> INSTANCE.convert("10.8,foo"));
|
||||
}
|
||||
@Test
|
||||
// DATAREST-279, DATACMNS-626
|
||||
void rejectsArbitraryNonsense() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> INSTANCE.convert("foo")).withMessageContaining("comma");
|
||||
}
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
public static class ParameterizedTests {
|
||||
@Test
|
||||
// DATAREST-279, DATACMNS-626
|
||||
void rejectsMoreThanTwoCoordinates() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> INSTANCE.convert("10.8,20.9,30.10"));
|
||||
}
|
||||
|
||||
@Parameters
|
||||
public static Collection<String[]> parameters() {
|
||||
return Arrays.asList(new String[] { "10.8,20.9" }, new String[] { " 10.8,20.9 " }, new String[] { " 10.8 ,20.9" },
|
||||
new String[] { " 10.8, 20.9 " });
|
||||
}
|
||||
@Test
|
||||
// DATAREST-279, DATACMNS-626
|
||||
void rejectsInvalidCoordinate() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> INSTANCE.convert("10.8,foo"));
|
||||
}
|
||||
|
||||
public @Parameter String source;
|
||||
static Collection<String[]> parameters() {
|
||||
return Arrays.asList(new String[] { "10.8,20.9" }, new String[] { " 10.8,20.9 " }, new String[] { " 10.8 ,20.9" },
|
||||
new String[] { " 10.8, 20.9 " });
|
||||
}
|
||||
|
||||
@Test // DATAREST-279, DATACMNS-626
|
||||
public void convertsPointFromString() {
|
||||
assertThat(INSTANCE.convert(source)).isEqualTo(REFERENCE);
|
||||
}
|
||||
@ParameterizedTest // DATAREST-279, DATACMNS-626
|
||||
@MethodSource("parameters")
|
||||
void convertsPointFromString(String source) {
|
||||
assertThat(INSTANCE.convert(source)).isEqualTo(REFERENCE);
|
||||
}
|
||||
|
||||
@Test // DATAREST-279, DATACMNS-626
|
||||
public void parsesPoint() throws ParseException {
|
||||
assertThat(INSTANCE.parse(source, Locale.US)).isEqualTo(REFERENCE);
|
||||
}
|
||||
@ParameterizedTest // DATAREST-279, DATACMNS-626
|
||||
@MethodSource("parameters")
|
||||
void parsesPoint(String source) throws ParseException {
|
||||
assertThat(INSTANCE.parse(source, Locale.US)).isEqualTo(REFERENCE);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user