Mercurial > lada > lada-server
changeset 541:2cff9c6c4a9e
Added more test cases for probe validator.
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Tue, 24 Feb 2015 14:57:49 +0100 |
parents | 7925f5eda6c4 |
children | 8215619b208e |
files | src/test/java/de/intevation/lada/LadaValidatorTest.java src/test/java/de/intevation/lada/test/validator/Probe.java |
diffstat | 2 files changed, 140 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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); + } }
--- 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); } }