[Lada-commits] [PATCH 09 of 10] Added more test cases for probe validator
Wald Commits
scm-commit at wald.intevation.org
Tue Feb 24 14:57:51 CET 2015
# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1424786269 -3600
# Node ID 2cff9c6c4a9ea0ffe2ef66fd9210f825f82cc54d
# Parent 7925f5eda6c43d3b9e75355ebc3e92bca006c495
Added more test cases for probe validator.
diff -r 7925f5eda6c4 -r 2cff9c6c4a9e src/test/java/de/intevation/lada/LadaValidatorTest.java
--- a/src/test/java/de/intevation/lada/LadaValidatorTest.java Tue Feb 24 14:57:24 2015 +0100
+++ b/src/test/java/de/intevation/lada/LadaValidatorTest.java Tue Feb 24 14:57:49 2015 +0100
@@ -93,4 +93,46 @@
probeTest.setValidator(probeValidator);
probeTest.hasNoProbeentnahmeBegin(testProtocol);
}
+
+ @Test
+ public final void probeTimeNoEndProbenahmeBegin() {
+ probeTest.setValidator(probeValidator);
+ probeTest.timeNoEndProbeentnahmeBegin(testProtocol);
+ }
+
+ @Test
+ public final void probeTimeNoBeginProbenahmeBegin() {
+ probeTest.setValidator(probeValidator);
+ probeTest.timeNoBeginProbeentnahmeBegin(testProtocol);
+ }
+
+ @Test
+ public final void probeTimeBeginAfterEndProbenahmeBegin() {
+ probeTest.setValidator(probeValidator);
+ probeTest.timeBeginAfterEndProbeentnahmeBegin(testProtocol);
+ }
+
+ @Test
+ public final void probeTimeBeginFutureProbenahmeBegin() {
+ probeTest.setValidator(probeValidator);
+ probeTest.timeBeginFutureProbeentnahmeBegin(testProtocol);
+ }
+
+ @Test
+ public final void probeHasUmwelt() {
+ probeTest.setValidator(probeValidator);
+ probeTest.hasUmwelt(testProtocol);
+ }
+
+ @Test
+ public final void probeHasNoUmwelt() {
+ probeTest.setValidator(probeValidator);
+ probeTest.hasNoUmwelt(testProtocol);
+ }
+
+ @Test
+ public final void probeHasEmptyUmwelt() {
+ probeTest.setValidator(probeValidator);
+ probeTest.hasEmptyUmwelt(testProtocol);
+ }
}
diff -r 7925f5eda6c4 -r 2cff9c6c4a9e src/test/java/de/intevation/lada/test/validator/Probe.java
--- a/src/test/java/de/intevation/lada/test/validator/Probe.java Tue Feb 24 14:57:24 2015 +0100
+++ b/src/test/java/de/intevation/lada/test/validator/Probe.java Tue Feb 24 14:57:49 2015 +0100
@@ -176,6 +176,104 @@
Assert.assertTrue(violation.getWarnings().get("probeentnahmeBegin").contains(631));
prot.setPassed(true);
}
+
+ public final void timeNoEndProbeentnahmeBegin(List<Protocol> protocol) {
+ Protocol prot = new Protocol();
+ prot.setName("ProbeValidator");
+ prot.setType("time no end probeentnahmeBegin");
+ prot.setPassed(false);
+ protocol.add(prot);
+ LProbe probe = new LProbe();
+ probe.setProbeentnahmeBeginn(new Timestamp(1376287046510l));
+ Violation violation = validator.validate(probe);
+ if (violation.hasWarnings()) {
+ Assert.assertFalse(violation.getWarnings().containsKey("probeentnahmeBegin"));
+ }
+ prot.setPassed(true);
+ }
+
+ public final void timeNoBeginProbeentnahmeBegin(List<Protocol> protocol) {
+ Protocol prot = new Protocol();
+ prot.setName("ProbeValidator");
+ prot.setType("time no begin probeentnahmeBegin");
+ prot.setPassed(false);
+ protocol.add(prot);
+ LProbe probe = new LProbe();
+ probe.setProbeentnahmeEnde(new Timestamp(1376287046510l));
+ Violation violation = validator.validate(probe);
+ Assert.assertTrue(violation.getWarnings().get("probeentnahmeBegin").contains(631));
+ Assert.assertTrue(violation.getWarnings().get("probeentnahmeBegin").contains(662));
+ prot.setPassed(true);
+ }
+
+ public final void timeBeginAfterEndProbeentnahmeBegin(List<Protocol> protocol) {
+ Protocol prot = new Protocol();
+ prot.setName("ProbeValidator");
+ prot.setType("time begin after end probeentnahmeBegin");
+ prot.setPassed(false);
+ protocol.add(prot);
+ LProbe probe = new LProbe();
+ probe.setProbeentnahmeBeginn(new Timestamp(1376287046511l));
+ probe.setProbeentnahmeEnde(new Timestamp(1376287046510l));
+ Violation violation = validator.validate(probe);
+ Assert.assertTrue(violation.getWarnings().get("probeentnahmeBegin").contains(662));
+ prot.setPassed(true);
+ }
+
+ public final void timeBeginFutureProbeentnahmeBegin(List<Protocol> protocol) {
+ Protocol prot = new Protocol();
+ prot.setName("ProbeValidator");
+ prot.setType("time begin in future probeentnahmeBegin");
+ prot.setPassed(false);
+ protocol.add(prot);
+ LProbe probe = new LProbe();
+ probe.setProbeentnahmeBeginn(new Timestamp(2376287046511l));
+ Violation violation = validator.validate(probe);
+ Assert.assertTrue(violation.getWarnings().get("probeentnahmeBegin").contains(661));
+ prot.setPassed(true);
+ }
+
+ public final void hasUmwelt(List<Protocol> protocol) {
+ Protocol prot = new Protocol();
+ prot.setName("ProbeValidator");
+ prot.setType("has Umwelt");
+ prot.setPassed(false);
+ protocol.add(prot);
+ LProbe probe = new LProbe();
+ probe.setUmwId("A4");
+ Violation violation = validator.validate(probe);
+ if (violation.hasWarnings()) {
+ Assert.assertFalse(violation.getWarnings().containsKey("uwb"));
+ }
+ prot.setPassed(true);
+ }
+
+ public final void hasNoUmwelt(List<Protocol> protocol) {
+ Protocol prot = new Protocol();
+ prot.setName("ProbeValidator");
+ prot.setType("has no Umwelt");
+ prot.setPassed(false);
+ protocol.add(prot);
+ LProbe probe = new LProbe();
+ Violation violation = validator.validate(probe);
+ Assert.assertTrue(violation.hasWarnings());
+ Assert.assertTrue(violation.getWarnings().containsKey("uwb"));
+ Assert.assertTrue(violation.getWarnings().get("uwb").contains(631));
+ prot.setPassed(true);
+ }
+
+ public final void hasEmptyUmwelt(List<Protocol> protocol) {
+ Protocol prot = new Protocol();
+ prot.setName("ProbeValidator");
+ prot.setType("has empty Umwelt");
+ prot.setPassed(false);
+ protocol.add(prot);
+ LProbe probe = new LProbe();
+ probe.setUmwId("");
+ Violation violation = validator.validate(probe);
+ Assert.assertTrue(violation.hasWarnings());
+ Assert.assertTrue(violation.getWarnings().containsKey("uwb"));
+ Assert.assertTrue(violation.getWarnings().get("uwb").contains(631));
prot.setPassed(true);
}
}
More information about the Lada-commits
mailing list