From 220a3f48ba5c47869595374ea1a247c0a0f39e6b Mon Sep 17 00:00:00 2001 From: utas-raymondng Date: Tue, 10 Sep 2024 11:20:25 +1000 Subject: [PATCH 1/2] Incorrect enum name use, after merge prefer the one with "s" --- .../core/model/enumeration/CQLFields.java | 18 ------------------ .../aodn/ogcapi/server/common/RestApiTest.java | 16 ++++++++-------- 2 files changed, 8 insertions(+), 26 deletions(-) diff --git a/server/src/main/java/au/org/aodn/ogcapi/server/core/model/enumeration/CQLFields.java b/server/src/main/java/au/org/aodn/ogcapi/server/core/model/enumeration/CQLFields.java index 4bb7535a..38cd8bae 100644 --- a/server/src/main/java/au/org/aodn/ogcapi/server/core/model/enumeration/CQLFields.java +++ b/server/src/main/java/au/org/aodn/ogcapi/server/core/model/enumeration/CQLFields.java @@ -111,24 +111,6 @@ public enum CQLFields implements CQLFieldsInterface { null, null ), - parameter_vocab( - StacBasicField.ParameterVocabs.searchField, - StacBasicField.ParameterVocabs.displayField, - null, - null - ), - platform_vocab( - StacBasicField.PlatformVocabs.searchField, - StacBasicField.PlatformVocabs.displayField, - null, - null - ), - organisation_vocab( - StacBasicField.OrganisationVocabs.searchField, - StacBasicField.OrganisationVocabs.displayField, - null, - null - ), providers( StacBasicField.Providers.searchField, StacBasicField.Providers.displayField, diff --git a/server/src/test/java/au/org/aodn/ogcapi/server/common/RestApiTest.java b/server/src/test/java/au/org/aodn/ogcapi/server/common/RestApiTest.java index bfd05301..d3366af6 100644 --- a/server/src/test/java/au/org/aodn/ogcapi/server/common/RestApiTest.java +++ b/server/src/test/java/au/org/aodn/ogcapi/server/common/RestApiTest.java @@ -361,19 +361,19 @@ public void verifyParameterParameterVocabsSearchMatch() throws IOException { "bf287dfe-9ce4-4969-9c59-51c39ea4d011.json" ); - ResponseEntity collections = testRestTemplate.getForEntity(getBasePath() + "/collections?filter=parameter_vocab='wave'", Collections.class); + ResponseEntity collections = testRestTemplate.getForEntity(getBasePath() + "/collections?filter=parameter_vocabs='wave'", Collections.class); assertEquals(1, Objects.requireNonNull(collections.getBody()).getCollections().size(), "hit 1, only one record in wave"); - collections = testRestTemplate.getForEntity(getBasePath() + "/collections?filter=parameter_vocab='alkalinity' AND parameter_vocab='temperature'", Collections.class); + collections = testRestTemplate.getForEntity(getBasePath() + "/collections?filter=parameter_vocabs='alkalinity' AND parameter_vocabs='temperature'", Collections.class); assertEquals(1, Objects.requireNonNull(collections.getBody()).getCollections().size(), "hit 1, 1 record belong to both parameter vocabs"); - collections = testRestTemplate.getForEntity(getBasePath() + "/collections?filter=parameter_vocab='wave' AND parameter_vocab='temperature'", Collections.class); + collections = testRestTemplate.getForEntity(getBasePath() + "/collections?filter=parameter_vocabs='wave' AND parameter_vocabs='temperature'", Collections.class); assertEquals(0, Objects.requireNonNull(collections.getBody()).getCollections().size(), "hit 0, no records belong to both parameter vocabs"); - collections = testRestTemplate.getForEntity(getBasePath() + "/collections?filter=parameter_vocab='wave' OR parameter_vocab='temperature'", Collections.class); + collections = testRestTemplate.getForEntity(getBasePath() + "/collections?filter=parameter_vocabs='wave' OR parameter_vocabs='temperature'", Collections.class); assertEquals(3, Objects.requireNonNull(collections.getBody()).getCollections().size(), "hit 3, 1 in wave and 2 in temperature"); - collections = testRestTemplate.getForEntity(getBasePath() + "/collections?filter=parameter_vocab='this parameter vocab does not exist'", Collections.class); + collections = testRestTemplate.getForEntity(getBasePath() + "/collections?filter=parameter_vocabs='this parameter vocab does not exist'", Collections.class); assertEquals(0, Objects.requireNonNull(collections.getBody()).getCollections().size(), "hit 0, parameter vocab none exist"); } /** @@ -465,11 +465,11 @@ public void verifyCQLPropertyScore() throws IOException { "bf287dfe-9ce4-4969-9c59-51c39ea4d011.json" ); // Make sure AND operation works - ResponseEntity collections = testRestTemplate.getForEntity(getBasePath() + "/collections?filter=score>=2 AND parameter_vocab='wave'", Collections.class); + ResponseEntity collections = testRestTemplate.getForEntity(getBasePath() + "/collections?filter=score>=2 AND parameter_vocabs='wave'", Collections.class); assertEquals(1, Objects.requireNonNull(collections.getBody()).getCollections().size(), "hit 1, only one record"); // Make sure OR not work as it didn't make sense to use or with setting - ResponseEntity error = testRestTemplate.getForEntity(getBasePath() + "/collections?filter=score>=2 OR parameter_vocab='wave'", ErrorResponse.class); + ResponseEntity error = testRestTemplate.getForEntity(getBasePath() + "/collections?filter=score>=2 OR parameter_vocabs='wave'", ErrorResponse.class); assertEquals(error.getStatusCode(), HttpStatus.INTERNAL_SERVER_ERROR); assertEquals(Objects.requireNonNull(error.getBody()).getMessage(), "Or combine with query setting do not make sense", "correct error"); @@ -536,7 +536,7 @@ public void verifySortBy() throws IOException { // Edge case on sort by with 1 item, but typo in argument sortBy, it should be sortby. Hence use API default sort -score // https://docs.ogc.org/DRAFTS/20-004.html#sorting-parameter-sortby - ResponseEntity collections = testRestTemplate.getForEntity(getBasePath() + "/collections?filter=score>=2 AND parameter_vocab='wave'&sortBy=-score,+title", ExtendedCollections.class); + ResponseEntity collections = testRestTemplate.getForEntity(getBasePath() + "/collections?filter=score>=2 AND parameter_vocabs='wave'&sortBy=-score,+title", ExtendedCollections.class); assertEquals(1, Objects.requireNonNull(collections.getBody()).getCollections().size(), "hit 1, only one record"); // Now return result should sort by score then title, since no query here, the score will auto adjust to 1 as all search without query default score is 1 From d2d3cf459e17b9a78d8067b461c3749e227832a0 Mon Sep 17 00:00:00 2001 From: utas-raymondng Date: Tue, 10 Sep 2024 11:24:14 +1000 Subject: [PATCH 2/2] Fix test fail --- .../ogcapi/server/common/RestExtApiTest.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/server/src/test/java/au/org/aodn/ogcapi/server/common/RestExtApiTest.java b/server/src/test/java/au/org/aodn/ogcapi/server/common/RestExtApiTest.java index 8b83f8cf..8061cf98 100644 --- a/server/src/test/java/au/org/aodn/ogcapi/server/common/RestExtApiTest.java +++ b/server/src/test/java/au/org/aodn/ogcapi/server/common/RestExtApiTest.java @@ -214,22 +214,22 @@ public void verifyApiResponseOnPlatformVocabSuggestions() throws IOException { assertNotEquals(List.of("vessel"), objectMapper.convertValue(suggestedVocabs3, objectMapper.getTypeFactory().constructCollectionType(List.class, String.class))); // matching filter - ResponseEntity response4 = testRestTemplate.getForEntity(getExternalBasePath() + "/autocomplete?input=bea&filter=(platform_vocab='wera beam forming hf radar')", String.class); + ResponseEntity response4 = testRestTemplate.getForEntity(getExternalBasePath() + "/autocomplete?input=bea&filter=(platform_vocabs='wera beam forming hf radar')", String.class); JsonNode suggestedVocabs4 = objectMapper.readTree(response4.getBody()).path("suggested_platform_vocabs"); assertEquals(List.of("wera beam forming hf radar"), objectMapper.convertValue(suggestedVocabs4, objectMapper.getTypeFactory().constructCollectionType(List.class, String.class))); // not matching filter - ResponseEntity response5 = testRestTemplate.getForEntity(getExternalBasePath() + "/autocomplete?input=bea&filter=(platform_vocab='vessel')", String.class); + ResponseEntity response5 = testRestTemplate.getForEntity(getExternalBasePath() + "/autocomplete?input=bea&filter=(platform_vocabs='vessel')", String.class); JsonNode suggestedVocabs5 = objectMapper.readTree(response5.getBody()).path("suggested_platform_vocabs"); assertNotEquals(List.of("wera beam forming hf radar"), objectMapper.convertValue(suggestedVocabs5, objectMapper.getTypeFactory().constructCollectionType(List.class, String.class))); // matching filter but not matching input - ResponseEntity response6 = testRestTemplate.getForEntity(getExternalBasePath() + "/autocomplete?input=random&filter=(platform_vocab='wera beam forming hf radar')", String.class); + ResponseEntity response6 = testRestTemplate.getForEntity(getExternalBasePath() + "/autocomplete?input=random&filter=(platform_vocabs='wera beam forming hf radar')", String.class); JsonNode suggestedVocabs6 = objectMapper.readTree(response6.getBody()).path("suggested_platform_vocabs"); assertNotEquals(List.of("wera beam forming hf radar"), objectMapper.convertValue(suggestedVocabs6, objectMapper.getTypeFactory().constructCollectionType(List.class, String.class))); // matching filter and matching input - ResponseEntity response7 = testRestTemplate.getForEntity(getExternalBasePath() + "/autocomplete?input=bea&filter=(platform_vocab='wera beam forming hf radar')", String.class); + ResponseEntity response7 = testRestTemplate.getForEntity(getExternalBasePath() + "/autocomplete?input=bea&filter=(platform_vocabs='wera beam forming hf radar')", String.class); JsonNode suggestedVocabs7 = objectMapper.readTree(response7.getBody()).path("suggested_platform_vocabs"); assertEquals(List.of("wera beam forming hf radar"), objectMapper.convertValue(suggestedVocabs7, objectMapper.getTypeFactory().constructCollectionType(List.class, String.class))); } @@ -260,22 +260,22 @@ public void verifyApiResponseOnOrganisationVocabSuggestions() throws IOException assertNotEquals(List.of("university of tasmania"), objectMapper.convertValue(suggestedVocabs3, objectMapper.getTypeFactory().constructCollectionType(List.class, String.class))); // matching filter - ResponseEntity response4 = testRestTemplate.getForEntity(getExternalBasePath() + "/autocomplete?input=ocean&filter=(organisation_vocab='ocean radar facility, integrated marine observing system (imos)')", String.class); + ResponseEntity response4 = testRestTemplate.getForEntity(getExternalBasePath() + "/autocomplete?input=ocean&filter=(organisation_vocabs='ocean radar facility, integrated marine observing system (imos)')", String.class); JsonNode suggestedVocabs4 = objectMapper.readTree(response4.getBody()).path("suggested_organisation_vocabs"); assertEquals(List.of("ocean radar facility, integrated marine observing system (imos)"), objectMapper.convertValue(suggestedVocabs4, objectMapper.getTypeFactory().constructCollectionType(List.class, String.class))); // not matching filter - ResponseEntity response5 = testRestTemplate.getForEntity(getExternalBasePath() + "/autocomplete?input=ocean&filter=(organisation_vocab='university of tasmania')", String.class); + ResponseEntity response5 = testRestTemplate.getForEntity(getExternalBasePath() + "/autocomplete?input=ocean&filter=(organisation_vocabs='university of tasmania')", String.class); JsonNode suggestedVocabs5 = objectMapper.readTree(response5.getBody()).path("suggested_organisation_vocabs"); assertNotEquals(List.of("ocean radar facility, integrated marine observing system (imos)"), objectMapper.convertValue(suggestedVocabs5, objectMapper.getTypeFactory().constructCollectionType(List.class, String.class))); // matching filter but not matching input - ResponseEntity response6 = testRestTemplate.getForEntity(getExternalBasePath() + "/autocomplete?input=random&filter=(organisation_vocab='ocean radar facility, integrated marine observing system (imos)')", String.class); + ResponseEntity response6 = testRestTemplate.getForEntity(getExternalBasePath() + "/autocomplete?input=random&filter=(organisation_vocabs='ocean radar facility, integrated marine observing system (imos)')", String.class); JsonNode suggestedVocabs6 = objectMapper.readTree(response6.getBody()).path("suggested_organisation_vocabs"); assertNotEquals(List.of("ocean radar facility, integrated marine observing system (imos)"), objectMapper.convertValue(suggestedVocabs6, objectMapper.getTypeFactory().constructCollectionType(List.class, String.class))); // matching filter and matching input - ResponseEntity response7 = testRestTemplate.getForEntity(getExternalBasePath() + "/autocomplete?input=ocean&filter=(organisation_vocab='ocean radar facility, integrated marine observing system (imos)')", String.class); + ResponseEntity response7 = testRestTemplate.getForEntity(getExternalBasePath() + "/autocomplete?input=ocean&filter=(organisation_vocabs='ocean radar facility, integrated marine observing system (imos)')", String.class); JsonNode suggestedVocabs7 = objectMapper.readTree(response7.getBody()).path("suggested_organisation_vocabs"); assertEquals(List.of("ocean radar facility, integrated marine observing system (imos)"), objectMapper.convertValue(suggestedVocabs7, objectMapper.getTypeFactory().constructCollectionType(List.class, String.class))); }