Skip to content

Commit

Permalink
fixing tests, loading non-geo dataset in memory with the sample-data …
Browse files Browse the repository at this point in the history
…profile

Also adding a application.yml on the test classpath to make test config
easier.
  • Loading branch information
pmauduit committed Sep 14, 2023
1 parent 53554d0 commit c5d3225
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -24,6 +23,7 @@ public class OgcFeaturesAppTest {
private @Autowired CollectionsApiImpl collectionsApi;

private @Autowired NativeWebRequest req;

@Test
public void testCollectionApiInstanciation() {
assertNotNull(collectionsApi);
Expand All @@ -33,31 +33,26 @@ public void testCollectionApiInstanciation() {
public void testGetCollections() {
ResponseEntity<Collections> 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<FeatureCollection> response = collectionsApi.getFeatures("locations", 10,
null, null, null);
ResponseEntity<FeatureCollection> 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<FeatureCollection> response = collectionsApi.getFeatures("locations", -1,
null, null, "number = 140");
ResponseEntity<FeatureCollection> 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);
}
}
6 changes: 6 additions & 0 deletions src/services/ogc-features/src/test/resources/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
debug: false
logging:
level:
root: INFO
com.zaxxer.hikari.pool.HikariPool: OFF
# org.geotools: DEBUG

0 comments on commit c5d3225

Please sign in to comment.