mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 08:44:50 +00:00
Gate hydrology probes
- Count roof breaches as sea inlet check failures - Count raised berms over the fill cap as hydrology probe failures - Exit the sea inlet gate with 1 on failed checks, order mismatches, inlets off sea level or leaks the inlets add - Exit sea inlet inventory with 1 when a window fails to plan - Exit the cave pool probe with 1 on containment failures or order mismatches - Print a gate status line for both probes - Cover the failure counting in the probe unit tests
This commit is contained in:
1 parent
30c7492679
commit
bb6f3ca40b
6 files changed
+127
-22
No files matched your search
@@ -6,6 +6,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class CavePoolChecksTest {
|
||||
@Test
|
||||
@@ -16,6 +17,24 @@ public class CavePoolChecksTest {
|
||||
assertEquals(0L, counts(0, 0, 0, 0, 0, 0, 0, 0).failures());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void theGateFailsOnContainmentAndOrderMismatches() {
|
||||
CavePoolProbe.Gate passing = new CavePoolProbe.Gate(counts(0, 0, 0, 0, 0, 0, 0, 0), 0);
|
||||
assertEquals(0L, passing.failures());
|
||||
assertTrue(passing.line(), passing.line().startsWith("CAVE_POOL_GATE status=PASS failures=0 "));
|
||||
assertEquals(2L, new CavePoolProbe.Gate(counts(0, 0, 0, 0, 0, 0, 0, 0), 2).failures());
|
||||
CavePoolProbe.Gate failing = new CavePoolProbe.Gate(counts(1, 2, 3, 4, 5, 6, 7, 8), 1);
|
||||
assertEquals(37L, failing.failures());
|
||||
assertTrue(failing.line(), failing.line().startsWith("CAVE_POOL_GATE status=FAIL failures=37 "));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void orderMismatchesCountChunksWhoseHashesDiffer() {
|
||||
assertEquals(0, CavePoolProbe.compare(Map.of(1L, 10L, 2L, 20L), Map.of(2L, 20L, 1L, 10L)));
|
||||
assertEquals(1, CavePoolProbe.compare(Map.of(1L, 10L, 2L, 20L), Map.of(1L, 10L, 2L, 21L)));
|
||||
assertEquals("a chunk missing from the shuffled run is a mismatch", 1, CavePoolProbe.compare(Map.of(1L, 10L, 2L, 20L), Map.of(1L, 10L)));
|
||||
}
|
||||
|
||||
private static CavePoolProbe.Counts counts(int air, int open, int sky, int foreign, int waterlogged, int gravity, int fluidAbove,
|
||||
int gravityCeilings) {
|
||||
return new CavePoolProbe.Counts(1, 1, 1, 1, Map.of(), List.of(), List.of(), Map.of(), air, open, sky, foreign, waterlogged, gravity,
|
||||
|
||||
@@ -8,9 +8,11 @@ import org.junit.Test;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@@ -188,6 +190,24 @@ public class HydrologyProbeTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bermOverCapFailsTheProbe() {
|
||||
HydrologyReport.Result clean = result(0L);
|
||||
assertTrue(clean.lines().toString(), clean.passes());
|
||||
HydrologyReport.Result raised = result(3L);
|
||||
assertFalse(raised.passes());
|
||||
Map<String, String> total = fields(line(raised.lines(), "IRIS_HYDROLOGY_TOTAL"));
|
||||
assertEquals("3", total.get("bermOverCap"));
|
||||
assertEquals("FAIL", total.get("status"));
|
||||
assertTrue(total.get("missedTargets"), total.get("missedTargets").contains("bermOverCap"));
|
||||
}
|
||||
|
||||
private static HydrologyReport.Result result(long bermOverCap) {
|
||||
HydrologyReport.WindowMetrics window = new HydrologyReport.WindowMetrics(new WindowKey(4, 4), 1D, 0L, 0L, 1D, 1D, 0, 1D, 1, 1D, 1,
|
||||
Set.of(64), 0, 0L, 0L, 0L, 0L, 0L, bermOverCap, 0, 0L, 0, 0L, 1L, "digest");
|
||||
return new HydrologyReport.Result(List.of(window), 1D, 1, 1, 0L, 0L, 1D, 0L, "digest", List.of(), List.of());
|
||||
}
|
||||
|
||||
private static int[] bankBesideWater(SyntheticHydrology fixture) {
|
||||
int[][] offsets = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
|
||||
int min = LAND.minX() * HydrologyWindows.CHUNKS;
|
||||
|
||||
@@ -7,16 +7,39 @@ import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class SeaInletChecksTest {
|
||||
@Test
|
||||
public void roofBreachesAndLooseBedsAreReportedButOnlyContainmentAndSealChecksFail() {
|
||||
SeaInletProbe.Checks reported = new SeaInletProbe.Checks(3, 0L, 0L, 0L, 0L, 1939L, 0L, 0L, 0L, 0L, 952L, List.of());
|
||||
public void roofBreachesFailWithTheContainmentSealAndRoofChecks() {
|
||||
SeaInletProbe.Checks breached = new SeaInletProbe.Checks(3, 0L, 0L, 0L, 0L, 1939L, 0L, 0L, 0L, 0L, 0L, List.of());
|
||||
assertEquals(1939L, breached.failures());
|
||||
SeaInletProbe.Checks failing = new SeaInletProbe.Checks(3, 1L, 2L, 3L, 4L, 9L, 5L, 6L, 7L, 8L, 0L, List.of());
|
||||
assertEquals(45L, failing.failures());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void looseBedsAreReportedButDoNotFail() {
|
||||
SeaInletProbe.Checks reported = new SeaInletProbe.Checks(3, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 952L, List.of());
|
||||
assertEquals(0L, reported.failures());
|
||||
SeaInletProbe.Checks failing = new SeaInletProbe.Checks(3, 1L, 2L, 3L, 4L, 0L, 5L, 6L, 7L, 8L, 0L, List.of());
|
||||
assertEquals(36L, failing.failures());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void theGateFailsOnEveryCheckIncludingOrderSeaLevelAndAddedLeaks() {
|
||||
SeaInletProbe.Checks clean = new SeaInletProbe.Checks(3, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 952L, List.of());
|
||||
SeaInletProbe.Gate passing = new SeaInletProbe.Gate(clean, 0, 0, 7, 7);
|
||||
assertEquals(0L, passing.failures());
|
||||
assertTrue(passing.line(), passing.line().startsWith("SEA_INLET_GATE status=PASS failures=0 "));
|
||||
assertEquals("inlets that remove natural leaks do not fail", 0L, new SeaInletProbe.Gate(clean, 0, 0, 5, 7).failures());
|
||||
assertEquals(2L, new SeaInletProbe.Gate(clean, 0, 0, 9, 7).failures());
|
||||
assertEquals(1L, new SeaInletProbe.Gate(clean, 1, 0, 7, 7).failures());
|
||||
assertEquals(1L, new SeaInletProbe.Gate(clean, 0, 1, 7, 7).failures());
|
||||
SeaInletProbe.Checks breached = new SeaInletProbe.Checks(3, 0L, 0L, 0L, 0L, 4L, 0L, 0L, 0L, 0L, 0L, List.of());
|
||||
SeaInletProbe.Gate failing = new SeaInletProbe.Gate(breached, 0, 0, 0, 0);
|
||||
assertEquals(4L, failing.failures());
|
||||
assertTrue(failing.line(), failing.line().startsWith("SEA_INLET_GATE status=FAIL failures=4 "));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in new issue
Block a user