annotate src/test/java/de/intevation/lada/test/validator/StatusTest.java @ 1097:186d602e031a

Merged branch schema-update into default.
author Tom Gottfried <tom@intevation.de>
date Fri, 14 Oct 2016 18:17:42 +0200
parents
children
rev   line source
1097
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
2 * Software engineering by Intevation GmbH
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
3 *
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
4 * This file is Free Software under the GNU GPL (v>=3)
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
6 * the documentation coming with IMIS-Labordaten-Application for details.
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
7 */
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
8 package de.intevation.lada.test.validator;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
9
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
10 import java.util.List;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
11
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
12 import org.junit.Assert;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
13
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
14 import de.intevation.lada.Protocol;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
15 import de.intevation.lada.model.land.StatusProtokoll;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
16 import de.intevation.lada.validation.Validator;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
17 import de.intevation.lada.validation.Violation;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
18
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
19 public class StatusTest {
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
20
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
21 private Validator validator;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
22
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
23 public void setValidator(Validator validator) {
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
24 this.validator = validator;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
25 }
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
26
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
27 public final void checkKombiNegative(List<Protocol> protocol) {
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
28 Protocol prot = new Protocol();
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
29 prot.setName("StatusValidator");
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
30 prot.setType("check status kombi");
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
31 prot.setPassed(false);
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
32 protocol.add(prot);
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
33 StatusProtokoll status = new StatusProtokoll();
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
34 status.setStatusStufe(2);
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
35 status.setStatusWert(7);
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
36 Violation violation = validator.validate(status);
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
37 Assert.assertTrue(violation.hasErrors());
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
38 Assert.assertTrue(violation.getErrors().containsKey("kombi"));
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
39 Assert.assertTrue(violation.getErrors().get("kombi").contains(632));
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
40 prot.setPassed(true);
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
41 }
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
42
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
43 public final void checkKombiPositive(List<Protocol> protocol) {
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
44 Protocol prot = new Protocol();
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
45 prot.setName("StatusValidator");
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
46 prot.setType("check status kombi");
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
47 prot.setPassed(false);
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
48 protocol.add(prot);
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
49 StatusProtokoll status = new StatusProtokoll();
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
50 status.setStatusStufe(1);
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
51 status.setStatusWert(1);
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
52 Violation violation = validator.validate(status);
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
53 if (violation.hasErrors()) {
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
54 Assert.assertFalse(violation.getErrors().containsKey("kombi"));
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
55 }
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
56 prot.setPassed(true);
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
57 }
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
58 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)