diff --git a/src/main/java/gov/usgs/earthquake/nshmp/www/ServletUtil.java b/src/main/java/gov/usgs/earthquake/nshmp/www/ServletUtil.java index 23f3917b59051fbab8711522e2a0a4213ffebd8d..d9bf18cf717f5d7ed45f6041d650d8a4e468d496 100644 --- a/src/main/java/gov/usgs/earthquake/nshmp/www/ServletUtil.java +++ b/src/main/java/gov/usgs/earthquake/nshmp/www/ServletUtil.java @@ -15,6 +15,7 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.google.common.base.Stopwatch; import com.google.common.util.concurrent.ListeningExecutorService; diff --git a/src/test/java/gov/usgs/earthquake/nshmp/model/NshmTestUtils.java b/src/test/java/gov/usgs/earthquake/nshmp/model/NshmTestUtils.java index 0b4ddb123793be2454ae4d07d3207a553ac8fd4a..f64c4cae91ed14ebdfafaeef3615f227122556a0 100644 --- a/src/test/java/gov/usgs/earthquake/nshmp/model/NshmTestUtils.java +++ b/src/test/java/gov/usgs/earthquake/nshmp/model/NshmTestUtils.java @@ -93,6 +93,15 @@ class NshmTestUtils { static void testNshm(Nshm nshm, Optional<Path> dataPath) throws InterruptedException, ExecutionException { NshmModel nshmModel = loadModel(nshm); + + for (NamedLocation location : nshm.locations()) { + LOGGER.info("Location: " + location.toString()); + compareCurves(nshmModel, location, dataPath); + } + + nshmModel.exec.shutdown(); + + var context = Micronaut .build("--model=nshms/" + String.format("%s-%s", nshm.nshmInfo.repo, nshm.nshmInfo.year)) .mainClass(Application.class) @@ -100,10 +109,9 @@ class NshmTestUtils { for (NamedLocation location : nshm.locations()) { LOGGER.info("Location: " + location.toString()); - compareCurves(nshmModel, location, dataPath); + compareWebCurves(nshm, location, dataPath); } - nshmModel.exec.shutdown(); context.close(); } @@ -152,16 +160,27 @@ class NshmTestUtils { private static void compareCurves( NshmModel nshmModel, NamedLocation location, - Optional<Path> dataPath) throws InterruptedException, ExecutionException { + Optional<Path> dataPath + ) throws ExecutionException { Map<String, XySequence> actual = dataPath.isPresent() - ? readExpected(nshmModel, location, dataPath) : generateActual(nshmModel, location); - Map<String, XySequence> webActual = - HazardServiceUtils.generateActual(location, nshmModel.nshm.imts()); - Map<String, XySequence> expected = readExpected(nshmModel, location, Optional.empty()); + ? readExpected(nshmModel.nshm, location, dataPath) : generateActual(nshmModel, location); + Map<String, XySequence> expected = readExpected(nshmModel.nshm, location, Optional.empty()); + + for (String key : actual.keySet()) { + assertCurveEquals(expected.get(key), actual.get(key), TOLERANCE); + } + } + + private static void compareWebCurves( + Nshm nshm, + NamedLocation location, + Optional<Path> dataPath) throws InterruptedException, ExecutionException { + Map<String, XySequence> actual = + HazardServiceUtils.generateActual(location, nshm.imts()); + Map<String, XySequence> expected = readExpected(nshm, location, Optional.empty()); for (String key : actual.keySet()) { assertCurveEquals(expected.get(key), actual.get(key), TOLERANCE); - assertCurveEquals(expected.get(key), webActual.get(key), TOLERANCE); } } @@ -193,11 +212,11 @@ class NshmTestUtils { return xyMap; } - private static Map<String, XySequence> readExpected(NshmModel nshmModel, NamedLocation loc, + private static Map<String, XySequence> readExpected(Nshm nshm, NamedLocation loc, Optional<Path> dataPath) { Path resultPath = dataPath.orElse(DATA_PATH) - .resolve(nshmModel.nshm.modelName()) - .resolve(nshmModel.nshm.resultFilename(loc)); + .resolve(nshm.modelName()) + .resolve(nshm.resultFilename(loc)); JsonObject obj = null; try (BufferedReader br = Files.newBufferedReader(resultPath)) {