Skip to content
Snippets Groups Projects

NSHM Unit tests

1 file
+ 2
1
Compare changes
  • Side-by-side
  • Inline
package gov.usgs.earthquake.nshmp.model;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import org.junit.jupiter.api.Test;
@@ -21,6 +25,8 @@ import gov.usgs.earthquake.nshmp.site.NshmpSite;
* Test NSHMs.
*/
class NshmTests {
static Path DATA_PATH = Paths.get("src/test/resources/e2e/actual");
/* Alaska test sites */
private static final List<NamedLocation> ALASKA_LOCATIONS = List.of(
NshmpSite.ANCHORAGE_AK,
@@ -50,7 +56,7 @@ class NshmTests {
private static final Set<Imt> IMTS = EnumSet.of(Imt.PGA, Imt.SA0P2, Imt.SA1P0, Imt.SA5P0);
private static final Set<Imt> AK_2007_IMTS = EnumSet.of(Imt.PGA, Imt.SA0P2, Imt.SA1P0);
private static final Map<String, Nshm> NSHMS;
static final Map<String, Nshm> NSHMS;
static {
Map<String, Nshm> nshms = new HashMap<>();
@@ -97,7 +103,7 @@ class NshmTests {
NshmModel nshmModel =
NshmTestUtils.loadModel(NSHMS.get("nshm-conus-2023"));
NshmTestUtils.writeExpecteds(nshmModel);
NshmTestUtils.writeExpecteds(nshmModel, Optional.empty());
nshmModel.exec.shutdown();
// run all models
@@ -115,7 +121,8 @@ class NshmTests {
*/
@Test
final void testAlaska2007() throws IOException {
NshmTestUtils.testNshm(NSHMS.get("nshm-alaska-2007"));
Nshm nshm = NSHMS.get("nshm-alaska-2007");
NshmTestUtils.testNshm(nshm, getDataPath(nshm));
}
/**
@@ -125,7 +132,8 @@ class NshmTests {
*/
@Test
final void testAlaska2023() throws IOException {
NshmTestUtils.testNshm(NSHMS.get("nshm-alaska-2023"));
Nshm nshm = NSHMS.get("nshm-alaska-2023");
NshmTestUtils.testNshm(nshm, getDataPath(nshm));
}
/**
@@ -135,7 +143,8 @@ class NshmTests {
*/
@Test
final void testConus2018() throws IOException {
NshmTestUtils.testNshm(NSHMS.get("nshm-conus-2018"));
Nshm nshm = NSHMS.get("nshm-conus-2018");
NshmTestUtils.testNshm(nshm, getDataPath(nshm));
}
/**
@@ -145,7 +154,8 @@ class NshmTests {
*/
@Test
final void testConus2023() throws IOException {
NshmTestUtils.testNshm(NSHMS.get("nshm-conus-2023"));
Nshm nshm = NSHMS.get("nshm-conus-2023");
NshmTestUtils.testNshm(nshm, getDataPath(nshm));
}
/**
@@ -155,6 +165,12 @@ class NshmTests {
*/
@Test
final void testHawaii2021() throws IOException {
NshmTestUtils.testNshm(NSHMS.get("nshm-hawaii-2021"));
Nshm nshm = NSHMS.get("nshm-hawaii-2021");
NshmTestUtils.testNshm(nshm, getDataPath(nshm));
}
private static Optional<Path> getDataPath(Nshm nshm) {
return Files.exists(DATA_PATH.resolve(nshm.modelName())) ? Optional.of(DATA_PATH)
: Optional.empty();
}
}
Loading