Mercurial > lada > lada-server
comparison src/test/java/de/intevation/lada/test/validator/MessungTest.java @ 1028:1c41c7b8f7c2 schema-update
Updated server application to new database model. THIS IS STILL WIP!!!
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Fri, 08 Jul 2016 15:32:36 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1027:9971471d562c | 1028:1c41c7b8f7c2 |
---|---|
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz | |
2 * Software engineering by Intevation GmbH | |
3 * | |
4 * This file is Free Software under the GNU GPL (v>=3) | |
5 * and comes with ABSOLUTELY NO WARRANTY! Check out | |
6 * the documentation coming with IMIS-Labordaten-Application for details. | |
7 */ | |
8 package de.intevation.lada.test.validator; | |
9 | |
10 import java.util.List; | |
11 | |
12 import org.junit.Assert; | |
13 | |
14 import de.intevation.lada.Protocol; | |
15 import de.intevation.lada.model.land.Messung; | |
16 import de.intevation.lada.validation.Validator; | |
17 import de.intevation.lada.validation.Violation; | |
18 | |
19 public class MessungTest { | |
20 | |
21 private Validator validator; | |
22 | |
23 public void setValidator(Validator validator) { | |
24 this.validator = validator; | |
25 } | |
26 | |
27 public final void hasNebenprobenNr(List<Protocol> protocol) { | |
28 Protocol prot = new Protocol(); | |
29 prot.setName("MessungValidator"); | |
30 prot.setType("has nebenprobenNr"); | |
31 prot.setPassed(false); | |
32 protocol.add(prot); | |
33 Messung messung = new Messung(); | |
34 messung.setNebenprobenNr("10R1"); | |
35 messung.setProbeId(4); | |
36 Violation violation = validator.validate(messung); | |
37 if (violation.hasWarnings()) { | |
38 Assert.assertFalse(violation.getWarnings().containsKey("nebenprobenNr")); | |
39 } | |
40 prot.setPassed(true); | |
41 } | |
42 | |
43 public final void hasNoNebenprobenNr(List<Protocol> protocol) { | |
44 Protocol prot = new Protocol(); | |
45 prot.setName("MessungValidator"); | |
46 prot.setType("has no nebenprobenNr"); | |
47 prot.setPassed(false); | |
48 protocol.add(prot); | |
49 Messung messung = new Messung(); | |
50 messung.setProbeId(4); | |
51 Violation violation = validator.validate(messung); | |
52 Assert.assertTrue(violation.hasWarnings()); | |
53 Assert.assertTrue(violation.getWarnings().containsKey("nebenprobenNr")); | |
54 Assert.assertTrue(violation.getWarnings().get("nebenprobenNr").contains(631)); | |
55 prot.setPassed(true); | |
56 } | |
57 | |
58 public final void hasEmptyNebenprobenNr(List<Protocol> protocol) { | |
59 Protocol prot = new Protocol(); | |
60 prot.setName("MessungValidator"); | |
61 prot.setType("has empty nebenprobenNr"); | |
62 prot.setPassed(false); | |
63 protocol.add(prot); | |
64 Messung messung = new Messung(); | |
65 messung.setNebenprobenNr(""); | |
66 messung.setProbeId(4); | |
67 Violation violation = validator.validate(messung); | |
68 Assert.assertTrue(violation.hasWarnings()); | |
69 Assert.assertTrue(violation.getWarnings().containsKey("nebenprobenNr")); | |
70 Assert.assertTrue(violation.getWarnings().get("nebenprobenNr").contains(631)); | |
71 prot.setPassed(true); | |
72 } | |
73 | |
74 public final void existingNebenprobenNrNew(List<Protocol> protocol) { | |
75 Protocol prot = new Protocol(); | |
76 prot.setName("MessungValidator"); | |
77 prot.setType("existing nebenprobenNr (new)"); | |
78 prot.setPassed(false); | |
79 protocol.add(prot); | |
80 Messung messung = new Messung(); | |
81 messung.setNebenprobenNr("00G1"); | |
82 messung.setProbeId(4); | |
83 Violation violation = validator.validate(messung); | |
84 Assert.assertTrue(violation.hasErrors()); | |
85 Assert.assertTrue(violation.getErrors().containsKey("nebenprobenNr")); | |
86 Assert.assertTrue(violation.getErrors().get("nebenprobenNr").contains(611)); | |
87 prot.setPassed(true); | |
88 } | |
89 | |
90 public final void uniqueNebenprobenNrNew(List<Protocol> protocol) { | |
91 Protocol prot = new Protocol(); | |
92 prot.setName("MessungValidator"); | |
93 prot.setType("unique nebenprobenNr (new)"); | |
94 prot.setPassed(false); | |
95 protocol.add(prot); | |
96 Messung messung = new Messung(); | |
97 messung.setNebenprobenNr("00G2"); | |
98 messung.setProbeId(4); | |
99 Violation violation = validator.validate(messung); | |
100 if (violation.hasErrors()) { | |
101 Assert.assertFalse(violation.getErrors().containsKey("nebenprobenNr")); | |
102 } | |
103 prot.setPassed(true); | |
104 } | |
105 | |
106 public final void uniqueNebenprobenNrUpdate(List<Protocol> protocol) { | |
107 Protocol prot = new Protocol(); | |
108 prot.setName("MessungValidator"); | |
109 prot.setType("unique nebenprobenNr (update)"); | |
110 prot.setPassed(false); | |
111 protocol.add(prot); | |
112 Messung messung = new Messung(); | |
113 messung.setId(45); | |
114 messung.setProbeId(4); | |
115 messung.setNebenprobenNr("00G2"); | |
116 Violation violation = validator.validate(messung); | |
117 if (violation.hasErrors()) { | |
118 Assert.assertFalse(violation.getErrors().containsKey("hauptprobenNr")); | |
119 return; | |
120 } | |
121 prot.setPassed(true); | |
122 } | |
123 | |
124 public final void existingHauptprobenNrUpdate(List<Protocol> protocol) { | |
125 Protocol prot = new Protocol(); | |
126 prot.setName("MessungValidator"); | |
127 prot.setType("existing nebenprobenNr (update)"); | |
128 prot.setPassed(false); | |
129 protocol.add(prot); | |
130 Messung messung = new Messung(); | |
131 messung.setId(776); | |
132 messung.setProbeId(1); | |
133 messung.setNebenprobenNr("0003"); | |
134 Violation violation = validator.validate(messung); | |
135 Assert.assertTrue(violation.hasErrors()); | |
136 Assert.assertTrue(violation.getErrors().containsKey("nebenprobenNr")); | |
137 Assert.assertTrue(violation.getErrors().get("nebenprobenNr").contains(611)); | |
138 prot.setPassed(true); | |
139 } | |
140 | |
141 public final void hasMesswert(List<Protocol> protocol) { | |
142 Protocol prot = new Protocol(); | |
143 prot.setName("MessungValidator"); | |
144 prot.setType("has messwert"); | |
145 prot.setPassed(false); | |
146 protocol.add(prot); | |
147 Messung messung = new Messung(); | |
148 messung.setId(1); | |
149 messung.setProbeId(4); | |
150 Violation violation = validator.validate(messung); | |
151 if (violation.hasWarnings()) { | |
152 Assert.assertFalse(violation.getWarnings().containsKey("messwert")); | |
153 } | |
154 prot.setPassed(true); | |
155 } | |
156 | |
157 public final void hasNoMesswert(List<Protocol> protocol) { | |
158 Protocol prot = new Protocol(); | |
159 prot.setName("MessungValidator"); | |
160 prot.setType("has no messwert"); | |
161 prot.setPassed(false); | |
162 protocol.add(prot); | |
163 Messung messung = new Messung(); | |
164 messung.setId(990); | |
165 messung.setProbeId(4); | |
166 Violation violation = validator.validate(messung); | |
167 Assert.assertTrue(violation.hasWarnings()); | |
168 Assert.assertTrue(violation.getWarnings().containsKey("messwert")); | |
169 Assert.assertTrue(violation.getWarnings().get("messwert").contains(631)); | |
170 prot.setPassed(true); | |
171 } | |
172 } |