From 1847779f873cfc71917687379a1af0d6925745b9 Mon Sep 17 00:00:00 2001 From: Yuxuan HU Date: Fri, 8 May 2026 16:24:35 +1000 Subject: [PATCH 1/2] skip AMSA to call summary query --- .../aodn/ogcapi/server/core/service/OGCApiService.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/server/src/main/java/au/org/aodn/ogcapi/server/core/service/OGCApiService.java b/server/src/main/java/au/org/aodn/ogcapi/server/core/service/OGCApiService.java index 3a9f2d6b..618a694d 100644 --- a/server/src/main/java/au/org/aodn/ogcapi/server/core/service/OGCApiService.java +++ b/server/src/main/java/au/org/aodn/ogcapi/server/core/service/OGCApiService.java @@ -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 * here @@ -44,6 +47,13 @@ public ResponseEntity 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); From 428467f796472e66ce030419a0d12238db84132b Mon Sep 17 00:00:00 2001 From: Yuxuan HU Date: Fri, 8 May 2026 16:29:05 +1000 Subject: [PATCH 2/2] add test --- .../server/features/RestServicesTest.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/server/src/test/java/au/org/aodn/ogcapi/server/features/RestServicesTest.java b/server/src/test/java/au/org/aodn/ogcapi/server/features/RestServicesTest.java index b256e586..4eb3aca8 100644 --- a/server/src/test/java/au/org/aodn/ogcapi/server/features/RestServicesTest.java +++ b/server/src/test/java/au/org/aodn/ogcapi/server/features/RestServicesTest.java @@ -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; @@ -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 { @@ -35,6 +40,9 @@ public class RestServicesTest { @Mock private WfsServer wfsServer; + @Mock + private Search search; + @InjectMocks private RestServices restServices; @@ -178,4 +186,21 @@ public void testGetWfsTimeFieldWorks() { assertInstanceOf(Map.class, response.getBody()); } + + @Test + public void testGetFeatureSummaryReturnsEmptyCollectionForAmsaWithoutSearching() throws Exception { + ResponseEntity 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()); + } }