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
5 changes: 5 additions & 0 deletions src/main/resources/config/json-paths-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,8 @@ products:
description: "EAC Mooring Array SST products" # for Brisbane only
paths:
- /EAC_array_figures/EACMooringArray.json

- product: "SWOT GSLA"
description: "SWOT Global Sea Level Anomaly SSH products"
paths:
- /DR_SWOT/SSH/SSH.json
9 changes: 9 additions & 0 deletions src/main/resources/config/products.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,12 @@ ocean-current:
id: "sealCtdTags-timeseries"
- title: "SeaCTD Tags TS Plot"
id: "sealCtdTags-ts"

- title: "SWOT GSLA"
id: "swotGsla"
type: "ProductGroup"
children:
- title: "SSH"
id: "swotGsla-ssh"
- title: "MDT"
id: "swotGsla-mdt"
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package au.org.aodn.oceancurrent.configuration;

import au.org.aodn.oceancurrent.configuration.remoteJson.JsonPath;
import au.org.aodn.oceancurrent.configuration.remoteJson.JsonPathsRoot;
import au.org.aodn.oceancurrent.constant.ConfigConstants;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.springframework.core.io.ClassPathResource;

import java.io.IOException;
import java.util.Optional;

import static org.assertj.core.api.Assertions.assertThat;

class JsonPathsConfigTest {

private static JsonPathsRoot config;

@BeforeAll
static void loadConfig() throws IOException {
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
config = mapper.readValue(
new ClassPathResource(ConfigConstants.CONFIG_FILE_PATH).getInputStream(),
JsonPathsRoot.class
);
}

@Test
void swotGslaShouldHaveSshJsonPath() {
Optional<JsonPath> entry = config.getProducts().stream()
.filter(p -> p.getProduct().equals("SWOT GSLA"))
.findFirst();
assertThat(entry).isPresent();
assertThat(entry.get().getPaths()).containsExactly("/DR_SWOT/SSH/SSH.json");
}

@Test
void swotGslaShouldNotIndexMdt() {
Optional<JsonPath> entry = config.getProducts().stream()
.filter(p -> p.getProduct().equals("SWOT GSLA"))
.findFirst();
assertThat(entry).isPresent();
assertThat(entry.get().getPaths()).noneMatch(p -> p.contains("MDT") || p.contains("MDTCMEMS"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,20 @@ void sealCtdGroupShouldContainAllExpectedChildren() {
"sealCtdTags-ts"
);
}

@Test
void swotGslaGroupShouldContainSshAndMdtChildren() {
Product swotGsla = productGroupMap.get("swotGsla");
assertThat(swotGsla).isNotNull();
assertThat(swotGsla.getTitle()).isEqualTo("SWOT GSLA");

List<String> childIds = swotGsla.getChildren().stream().map(Product::getId).collect(Collectors.toList());
assertThat(childIds).containsExactlyInAnyOrder("swotGsla-ssh", "swotGsla-mdt");

swotGsla.getChildren().forEach(child -> {
assertThat(child.getParentId()).isEqualTo("swotGsla");
assertThat(child.getParentTitle()).isEqualTo("SWOT GSLA");
assertThat(productMap).containsKey(child.getId());
});
}
}