changeset 796:385fab3be7f4

Added test cases for 'status kombi'.
author Raimund Renkert <raimund.renkert@intevation.de>
date Thu, 19 Nov 2015 08:50:33 +0100
parents c20b12007a35
children e15c981fe310 8c336f08e76f
files src/main/java/de/intevation/lada/validation/rules/status/StatusKombination.java src/test/java/de/intevation/lada/LadaValidatorTest.java src/test/java/de/intevation/lada/test/validator/Status.java
diffstat 3 files changed, 73 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/de/intevation/lada/validation/rules/status/StatusKombination.java	Thu Nov 19 08:50:08 2015 +0100
+++ b/src/main/java/de/intevation/lada/validation/rules/status/StatusKombination.java	Thu Nov 19 08:50:33 2015 +0100
@@ -45,7 +45,7 @@
             repository.filterPlain(kombi.getQuery(), "stamm");
         if (result.isEmpty()) {
             Violation violation = new Violation();
-            violation.addError("status", 632);
+            violation.addError("kombi", 632);
             return violation;
         }
         return null;
--- a/src/test/java/de/intevation/lada/LadaValidatorTest.java	Thu Nov 19 08:50:08 2015 +0100
+++ b/src/test/java/de/intevation/lada/LadaValidatorTest.java	Thu Nov 19 08:50:33 2015 +0100
@@ -21,6 +21,7 @@
 
 import de.intevation.lada.test.validator.Messung;
 import de.intevation.lada.test.validator.Probe;
+import de.intevation.lada.test.validator.Status;
 import de.intevation.lada.validation.Validator;
 import de.intevation.lada.validation.annotation.ValidationConfig;
 
@@ -43,9 +44,16 @@
     private Validator messungValidator;
     private Messung messungTest;
 
+    @Inject
+    @ValidationConfig(type="Status")
+    private Validator statusValidator;
+    private Status statusTest;
+
+
     public LadaValidatorTest() {
         probeTest = new Probe();
         messungTest = new Messung();
+        statusTest = new Status();
         testProtocol = new ArrayList<Protocol>();
     }
 
@@ -240,4 +248,10 @@
         messungTest.setValidator(messungValidator);
         messungTest.hasNoMesswert(testProtocol);
     }
+
+    @Test
+    public final void statusKombiNegative() {
+        statusTest.setValidator(statusValidator);
+        statusTest.checkKombiNegative(testProtocol);
+    }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/java/de/intevation/lada/test/validator/Status.java	Thu Nov 19 08:50:33 2015 +0100
@@ -0,0 +1,58 @@
+/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU GPL (v>=3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out
+ * the documentation coming with IMIS-Labordaten-Application for details.
+ */
+package de.intevation.lada.test.validator;
+
+import java.util.List;
+
+import org.junit.Assert;
+
+import de.intevation.lada.Protocol;
+import de.intevation.lada.model.land.LStatusProtokoll;
+import de.intevation.lada.validation.Validator;
+import de.intevation.lada.validation.Violation;
+
+public class Status {
+
+    private Validator validator;
+
+    public void setValidator(Validator validator) {
+        this.validator = validator;
+    }
+
+    public final void checkKombiNegative(List<Protocol> protocol) {
+        Protocol prot = new Protocol();
+        prot.setName("StatusValidator");
+        prot.setType("check status kombi");
+        prot.setPassed(false);
+        protocol.add(prot);
+        LStatusProtokoll status = new LStatusProtokoll();
+        status.setStatusStufe(2);
+        status.setStatusWert(7);
+        Violation violation = validator.validate(status);
+        Assert.assertTrue(violation.hasErrors());
+        Assert.assertTrue(violation.getErrors().containsKey("kombi"));
+        Assert.assertTrue(violation.getErrors().get("kombi").contains(632));
+        prot.setPassed(true);
+    }
+
+    public final void checkKombiPositive(List<Protocol> protocol) {
+        Protocol prot = new Protocol();
+        prot.setName("StatusValidator");
+        prot.setType("check status kombi");
+        prot.setPassed(false);
+        protocol.add(prot);
+        LStatusProtokoll status = new LStatusProtokoll();
+        status.setStatusStufe(1);
+        status.setStatusWert(1);
+        Violation violation = validator.validate(status);
+        if (violation.hasErrors()) {
+            Assert.assertFalse(violation.getErrors().containsKey("kombi"));
+        }
+        prot.setPassed(true);
+    }
+}
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)