From c5d3225138a05154304371ffb24bf8549726cbda Mon Sep 17 00:00:00 2001 From: Pierre Mauduit Date: Thu, 14 Sep 2023 18:03:44 +0200 Subject: [PATCH] fixing tests, loading non-geo dataset in memory with the sample-data profile Also adding a application.yml on the test classpath to make test config easier. --- .../SampleDataBackendAutoConfiguration.java | 3 ++- .../ogc/features/app/OgcFeaturesAppTest.java | 21 +++++++------------ .../src/test/resources/application.yml | 6 ++++++ 3 files changed, 16 insertions(+), 14 deletions(-) create mode 100644 src/services/ogc-features/src/test/resources/application.yml diff --git a/src/services/ogc-features/src/main/java/com/camptocamp/opendata/ogc/features/autoconfigure/SampleDataBackendAutoConfiguration.java b/src/services/ogc-features/src/main/java/com/camptocamp/opendata/ogc/features/autoconfigure/SampleDataBackendAutoConfiguration.java index 2330f66..63b67d0 100644 --- a/src/services/ogc-features/src/main/java/com/camptocamp/opendata/ogc/features/autoconfigure/SampleDataBackendAutoConfiguration.java +++ b/src/services/ogc-features/src/main/java/com/camptocamp/opendata/ogc/features/autoconfigure/SampleDataBackendAutoConfiguration.java @@ -75,7 +75,8 @@ private static class SampleData implements DisposableBean { JDBCDataStore sdds = factory.createDataStore(params); try { - String[] sampleDatasources = { "locations", "base-sirene-v3", "comptages-velo" }; + String[] sampleDatasources = { "locations", "base-sirene-v3", "comptages-velo", + "ouvrages-acquis-par-les-mediatheques" }; for (int i = 0; i < sampleDatasources.length; ++i) { ((MemoryDataStore) dataStore) diff --git a/src/services/ogc-features/src/test/java/com/camptocamp/opendata/ogc/features/app/OgcFeaturesAppTest.java b/src/services/ogc-features/src/test/java/com/camptocamp/opendata/ogc/features/app/OgcFeaturesAppTest.java index 11d3946..105c21a 100644 --- a/src/services/ogc-features/src/test/java/com/camptocamp/opendata/ogc/features/app/OgcFeaturesAppTest.java +++ b/src/services/ogc-features/src/test/java/com/camptocamp/opendata/ogc/features/app/OgcFeaturesAppTest.java @@ -15,7 +15,6 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertNotNull; - @SpringBootTest @EnableAutoConfiguration @ActiveProfiles("sample-data") @@ -24,6 +23,7 @@ public class OgcFeaturesAppTest { private @Autowired CollectionsApiImpl collectionsApi; private @Autowired NativeWebRequest req; + @Test public void testCollectionApiInstanciation() { assertNotNull(collectionsApi); @@ -33,31 +33,26 @@ public void testCollectionApiInstanciation() { public void testGetCollections() { ResponseEntity response = collectionsApi.getCollections(); - assertThat(response.getStatusCode().value()) - .isEqualTo(200); - assertThat(response.getBody().getCollections().size()) - .isEqualTo(3); + assertThat(response.getStatusCode().value()).isEqualTo(200); + assertThat(response.getBody().getCollections().size()).isEqualTo(4); } @Test public void testGetItems() { MockHttpServletRequest actualRequest = (MockHttpServletRequest) req.getNativeRequest(); actualRequest.addHeader("Accept", "application/json"); - ResponseEntity response = collectionsApi.getFeatures("locations", 10, - null, null, null); + ResponseEntity response = collectionsApi.getFeatures("locations", 10, null, null, null); - assertThat(response.getBody().getFeatures().toList().size()) - .isEqualTo(10); + assertThat(response.getBody().getFeatures().toList().size()).isEqualTo(10); } @Test public void testGetItemsWithFilter() { MockHttpServletRequest actualRequest = (MockHttpServletRequest) req.getNativeRequest(); actualRequest.addHeader("Accept", "application/json"); - ResponseEntity response = collectionsApi.getFeatures("locations", -1, - null, null, "number = 140"); + ResponseEntity response = collectionsApi.getFeatures("locations", -1, null, null, + "number = 140"); - assertThat(response.getBody().getFeatures().toList().size()) - .isEqualTo(1); + assertThat(response.getBody().getFeatures().toList().size()).isEqualTo(1); } } diff --git a/src/services/ogc-features/src/test/resources/application.yml b/src/services/ogc-features/src/test/resources/application.yml new file mode 100644 index 0000000..cb95f7c --- /dev/null +++ b/src/services/ogc-features/src/test/resources/application.yml @@ -0,0 +1,6 @@ +debug: false +logging: + level: + root: INFO + com.zaxxer.hikari.pool.HikariPool: OFF + # org.geotools: DEBUG