DATACMNS-1554 - Polishing.

Replace AtTest(expected = …) and ExpectedException with the corresponding AssertJ assertThatExceptionOfType(…) and assertThatIllegalArgumentException().isThrownBy(…).
This commit is contained in:
Mark Paluch
2019-07-10 11:47:46 +02:00
parent 660006b8c9
commit 704913c866
79 changed files with 457 additions and 474 deletions

View File

@@ -28,14 +28,14 @@ import org.springframework.util.SerializationUtils;
*/
public class CircleUnitTests {
@Test(expected = IllegalArgumentException.class) // DATACMNS-437
@Test // DATACMNS-437
public void rejectsNullOrigin() {
new Circle(null, new Distance(0));
assertThatIllegalArgumentException().isThrownBy(() -> new Circle(null, new Distance(0)));
}
@Test(expected = IllegalArgumentException.class) // DATACMNS-437
@Test // DATACMNS-437
public void rejectsNegativeRadius() {
new Circle(1, 1, -1);
assertThatIllegalArgumentException().isThrownBy(() -> new Circle(1, 1, -1));
}
@Test // DATACMNS-437

View File

@@ -50,10 +50,11 @@ public class GeoResultUnitTests {
assertThat(fourth.equals(first)).isFalse();
}
@Test
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test(expected = IllegalArgumentException.class) // DATACMNS-437
// DATACMNS-437
public void rejectsNullContent() {
new GeoResult(null, new Distance(2.5));
assertThatIllegalArgumentException().isThrownBy(() -> new GeoResult(null, new Distance(2.5)));
}
@Test // DATACMNS-482

View File

@@ -28,9 +28,9 @@ import org.springframework.util.SerializationUtils;
*/
public class PointUnitTests {
@Test(expected = IllegalArgumentException.class) // DATACMNS-437
@Test // DATACMNS-437
public void rejectsNullforCopyConstructor() {
new Point(null);
assertThatIllegalArgumentException().isThrownBy(() -> new Point(null));
}
@Test // DATACMNS-437

View File

@@ -32,9 +32,9 @@ public class PolygonUnitTests {
Point second = new Point(2, 2);
Point third = new Point(3, 3);
@Test(expected = IllegalArgumentException.class) // DATACMNS-437
@Test // DATACMNS-437
public void rejectsNullPoints() {
new Polygon(null, null, null);
assertThatIllegalArgumentException().isThrownBy(() -> new Polygon(null, null, null));
}
@Test // DATACMNS-437

View File

@@ -49,14 +49,14 @@ public class DistanceFormatterUnitTests {
public static class UnparameterizedTests {
@Test(expected = IllegalArgumentException.class) // DATAREST-279, DATACMNS-626
@Test // DATAREST-279, DATACMNS-626
public void rejectsArbitraryNonsense() {
INSTANCE.convert("foo");
assertThatIllegalArgumentException().isThrownBy(() -> INSTANCE.convert("foo"));
}
@Test(expected = IllegalArgumentException.class) // DATAREST-279, DATACMNS-626
@Test // DATAREST-279, DATACMNS-626
public void rejectsUnsupportedMetric() {
INSTANCE.convert("10.8cm");
assertThatIllegalArgumentException().isThrownBy(() -> INSTANCE.convert("10.8cm"));
}
@Test // DATAREST-279, DATACMNS-626

View File

@@ -23,14 +23,13 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.Locale;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.runners.Enclosed;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameter;
import org.junit.runners.Parameterized.Parameters;
import org.springframework.data.geo.Point;
/**
@@ -50,25 +49,19 @@ public class PointFormatterUnitTests {
public static class UnparameterizedTests {
public @Rule ExpectedException exception = ExpectedException.none();
@Test // DATAREST-279, DATACMNS-626
public void rejectsArbitraryNonsense() {
exception.expect(IllegalArgumentException.class);
exception.expectMessage("comma");
INSTANCE.convert("foo");
assertThatIllegalArgumentException().isThrownBy(() -> INSTANCE.convert("foo")).withMessageContaining("comma");
}
@Test(expected = IllegalArgumentException.class) // DATAREST-279, DATACMNS-626
@Test // DATAREST-279, DATACMNS-626
public void rejectsMoreThanTwoCoordinates() {
INSTANCE.convert("10.8,20.9,30.10");
assertThatIllegalArgumentException().isThrownBy(() -> INSTANCE.convert("10.8,20.9,30.10"));
}
@Test(expected = IllegalArgumentException.class) // DATAREST-279, DATACMNS-626
@Test // DATAREST-279, DATACMNS-626
public void rejectsInvalidCoordinate() {
INSTANCE.convert("10.8,foo");
assertThatIllegalArgumentException().isThrownBy(() -> INSTANCE.convert("10.8,foo"));
}
}