Migrate MongoDB to JUnit 5 (except for ClassRule).

See #583.
This commit is contained in:
Mark Paluch
2021-04-28 15:37:28 +02:00
parent e565f33872
commit ead318ce8d
29 changed files with 366 additions and 455 deletions

View File

@@ -16,10 +16,10 @@
package example.springdata.mongodb.geojson;
import org.bson.Document;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.autoconfigure.data.mongo.DataMongoTest;
import org.springframework.data.geo.Point;
import org.springframework.data.geo.Polygon;
import org.springframework.data.mongodb.core.MongoOperations;
@@ -28,7 +28,6 @@ import org.springframework.data.mongodb.core.geo.GeoJson;
import org.springframework.data.mongodb.core.geo.GeoJsonPolygon;
import org.springframework.data.mongodb.core.query.BasicQuery;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.test.context.junit4.SpringRunner;
/**
* Integration tests for {@link StoreRepository}.
@@ -36,9 +35,8 @@ import org.springframework.test.context.junit4.SpringRunner;
* @author Christoph Strobl
* @author Oliver Gierke
*/
@RunWith(SpringRunner.class)
@SpringBootTest
public class StoreRepositoryTests {
@DataMongoTest
class StoreRepositoryTests {
private static final GeoJsonPolygon GEO_JSON_POLYGON = new GeoJsonPolygon(new Point(-73.992514, 40.758934),
new Point(-73.961138, 40.760348), new Point(-73.991658, 40.730006), new Point(-73.992514, 40.758934));
@@ -81,7 +79,7 @@ public class StoreRepositoryTests {
* <pre>
*/
@Test
public void findWithinGeoJsonPolygon() {
void findWithinGeoJsonPolygon() {
repository.findByLocationWithin(GEO_JSON_POLYGON).forEach(System.out::println);
}
@@ -102,7 +100,7 @@ public class StoreRepositoryTests {
* <pre>
*/
@Test
public void findWithinLegacyPolygon() {
void findWithinLegacyPolygon() {
repository.findByLocationWithin(new Polygon(new Point(-73.992514, 40.758934), new Point(-73.961138, 40.760348),
new Point(-73.991658, 40.730006))).forEach(System.out::println);
}
@@ -112,7 +110,7 @@ public class StoreRepositoryTests {
* creation of the query using the registered {@link MongoConverter} for {@link GeoJson} conversion.
*/
@Test
public void findStoresThatIntersectGivenPolygon() {
void findStoresThatIntersectGivenPolygon() {
var geoJsonDbo = new Document();