Skip to content

Commit

Permalink
Merge pull request #85 from aodn/bugs/5791-remove-unused-enum
Browse files Browse the repository at this point in the history
Bugs/5791 remove unused enum
  • Loading branch information
HavierD authored Sep 10, 2024
2 parents 0c9f8d2 + d2d3cf4 commit 8cc3ff9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,19 +361,19 @@ public void verifyParameterParameterVocabsSearchMatch() throws IOException {
"bf287dfe-9ce4-4969-9c59-51c39ea4d011.json"
);

ResponseEntity<Collections> collections = testRestTemplate.getForEntity(getBasePath() + "/collections?filter=parameter_vocab='wave'", Collections.class);
ResponseEntity<Collections> 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");
}
/**
Expand Down Expand Up @@ -465,11 +465,11 @@ public void verifyCQLPropertyScore() throws IOException {
"bf287dfe-9ce4-4969-9c59-51c39ea4d011.json"
);
// Make sure AND operation works
ResponseEntity<Collections> collections = testRestTemplate.getForEntity(getBasePath() + "/collections?filter=score>=2 AND parameter_vocab='wave'", Collections.class);
ResponseEntity<Collections> 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<ErrorResponse> error = testRestTemplate.getForEntity(getBasePath() + "/collections?filter=score>=2 OR parameter_vocab='wave'", ErrorResponse.class);
ResponseEntity<ErrorResponse> 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");

Expand Down Expand Up @@ -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<ExtendedCollections> collections = testRestTemplate.getForEntity(getBasePath() + "/collections?filter=score>=2 AND parameter_vocab='wave'&sortBy=-score,+title", ExtendedCollections.class);
ResponseEntity<ExtendedCollections> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> response4 = testRestTemplate.getForEntity(getExternalBasePath() + "/autocomplete?input=bea&filter=(platform_vocab='wera beam forming hf radar')", String.class);
ResponseEntity<String> 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<String> response5 = testRestTemplate.getForEntity(getExternalBasePath() + "/autocomplete?input=bea&filter=(platform_vocab='vessel')", String.class);
ResponseEntity<String> 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<String> response6 = testRestTemplate.getForEntity(getExternalBasePath() + "/autocomplete?input=random&filter=(platform_vocab='wera beam forming hf radar')", String.class);
ResponseEntity<String> 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<String> response7 = testRestTemplate.getForEntity(getExternalBasePath() + "/autocomplete?input=bea&filter=(platform_vocab='wera beam forming hf radar')", String.class);
ResponseEntity<String> 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)));
}
Expand Down Expand Up @@ -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<String> response4 = testRestTemplate.getForEntity(getExternalBasePath() + "/autocomplete?input=ocean&filter=(organisation_vocab='ocean radar facility, integrated marine observing system (imos)')", String.class);
ResponseEntity<String> 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<String> response5 = testRestTemplate.getForEntity(getExternalBasePath() + "/autocomplete?input=ocean&filter=(organisation_vocab='university of tasmania')", String.class);
ResponseEntity<String> 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<String> response6 = testRestTemplate.getForEntity(getExternalBasePath() + "/autocomplete?input=random&filter=(organisation_vocab='ocean radar facility, integrated marine observing system (imos)')", String.class);
ResponseEntity<String> 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<String> response7 = testRestTemplate.getForEntity(getExternalBasePath() + "/autocomplete?input=ocean&filter=(organisation_vocab='ocean radar facility, integrated marine observing system (imos)')", String.class);
ResponseEntity<String> 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)));
}
Expand Down

0 comments on commit 8cc3ff9

Please sign in to comment.