[Lada-commits] [PATCH 4 of 4] Added test cases for 'status kombi'

Wald Commits scm-commit at wald.intevation.org
Thu Nov 19 08:50:44 CET 2015


# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1447919433 -3600
# Node ID 385fab3be7f47d44d8593a2af1c8359dc114d5d8
# Parent  c20b12007a3573f648553544189bd748978c9c1f
Added test cases for 'status kombi'.

diff -r c20b12007a35 -r 385fab3be7f4 src/main/java/de/intevation/lada/validation/rules/status/StatusKombination.java
--- 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;
diff -r c20b12007a35 -r 385fab3be7f4 src/test/java/de/intevation/lada/LadaValidatorTest.java
--- 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);
+    }
 }
diff -r c20b12007a35 -r 385fab3be7f4 src/test/java/de/intevation/lada/test/validator/Status.java
--- /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);
+    }
+}


More information about the Lada-commits mailing list