Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ public abstract class OGCApiService {
@Autowired
protected Search search;

// Hard coded dataset to avoid summary query, the AMSA should be skipped
private static final String EMPTY_SUMMARY_COLLECTION_ID = "2a5739e7-0cb8-444a-b83b-b2bc841b0ce8";

/**
* You can find conformance id
* <a href="https://docs.ogc.org/is/19-072/19-072.html#ats_core">here</a>
Expand All @@ -44,6 +47,13 @@ public ResponseEntity<FeatureCollectionGeoJSON> getFeature(String collectionId,
String filter) throws Exception {
switch(fid) {
case summary -> {
if (EMPTY_SUMMARY_COLLECTION_ID.equals(collectionId)) {
var featureCollection = new FeatureCollectionGeoJSON();
featureCollection.setType(FeatureCollectionGeoJSON.TypeEnum.FEATURECOLLECTION);
featureCollection.setFeatures(List.of());
return ResponseEntity.ok().body(featureCollection);
}

var result = search.searchFeatureSummary(collectionId, properties, filter);
var featureCollection = new FeatureCollectionGeoJSON();
featureCollection.setType(FeatureCollectionGeoJSON.TypeEnum.FEATURECOLLECTION);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
import au.org.aodn.ogcapi.server.core.service.DasService;
import au.org.aodn.ogcapi.server.core.service.geoserver.wfs.WfsServer;
import au.org.aodn.ogcapi.server.core.service.geoserver.wms.WmsServer;
import au.org.aodn.ogcapi.features.model.FeatureCollectionGeoJSON;
import au.org.aodn.ogcapi.server.core.model.enumeration.FeatureId;
import au.org.aodn.ogcapi.server.core.service.Search;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand All @@ -23,6 +26,8 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;

public class RestServicesTest {

Expand All @@ -35,6 +40,9 @@ public class RestServicesTest {
@Mock
private WfsServer wfsServer;

@Mock
private Search search;

@InjectMocks
private RestServices restServices;

Expand Down Expand Up @@ -178,4 +186,21 @@ public void testGetWfsTimeFieldWorks() {
assertInstanceOf(Map.class, response.getBody());

}

@Test
public void testGetFeatureSummaryReturnsEmptyCollectionForAmsaWithoutSearching() throws Exception {
ResponseEntity<FeatureCollectionGeoJSON> response = restServices.getFeature(
"2a5739e7-0cb8-444a-b83b-b2bc841b0ce8",
FeatureId.summary,
null,
null
);

assertEquals(HttpStatus.OK, response.getStatusCode());
assertNotNull(response.getBody());
assertEquals(FeatureCollectionGeoJSON.TypeEnum.FEATURECOLLECTION, response.getBody().getType());
assertTrue(response.getBody().getFeatures().isEmpty());

verify(search, never()).searchFeatureSummary(anyString(), any(), any());
}
}
Loading