Mercurial > lada > lada-server
view 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 |
line wrap: on
line source
/* 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.Messung; import de.intevation.lada.validation.Validator; import de.intevation.lada.validation.Violation; public class MessungTest { private Validator validator; public void setValidator(Validator validator) { this.validator = validator; } public final void hasNebenprobenNr(List<Protocol> protocol) { Protocol prot = new Protocol(); prot.setName("MessungValidator"); prot.setType("has nebenprobenNr"); prot.setPassed(false); protocol.add(prot); Messung messung = new Messung(); messung.setNebenprobenNr("10R1"); messung.setProbeId(4); Violation violation = validator.validate(messung); if (violation.hasWarnings()) { Assert.assertFalse(violation.getWarnings().containsKey("nebenprobenNr")); } prot.setPassed(true); } public final void hasNoNebenprobenNr(List<Protocol> protocol) { Protocol prot = new Protocol(); prot.setName("MessungValidator"); prot.setType("has no nebenprobenNr"); prot.setPassed(false); protocol.add(prot); Messung messung = new Messung(); messung.setProbeId(4); Violation violation = validator.validate(messung); Assert.assertTrue(violation.hasWarnings()); Assert.assertTrue(violation.getWarnings().containsKey("nebenprobenNr")); Assert.assertTrue(violation.getWarnings().get("nebenprobenNr").contains(631)); prot.setPassed(true); } public final void hasEmptyNebenprobenNr(List<Protocol> protocol) { Protocol prot = new Protocol(); prot.setName("MessungValidator"); prot.setType("has empty nebenprobenNr"); prot.setPassed(false); protocol.add(prot); Messung messung = new Messung(); messung.setNebenprobenNr(""); messung.setProbeId(4); Violation violation = validator.validate(messung); Assert.assertTrue(violation.hasWarnings()); Assert.assertTrue(violation.getWarnings().containsKey("nebenprobenNr")); Assert.assertTrue(violation.getWarnings().get("nebenprobenNr").contains(631)); prot.setPassed(true); } public final void existingNebenprobenNrNew(List<Protocol> protocol) { Protocol prot = new Protocol(); prot.setName("MessungValidator"); prot.setType("existing nebenprobenNr (new)"); prot.setPassed(false); protocol.add(prot); Messung messung = new Messung(); messung.setNebenprobenNr("00G1"); messung.setProbeId(4); Violation violation = validator.validate(messung); Assert.assertTrue(violation.hasErrors()); Assert.assertTrue(violation.getErrors().containsKey("nebenprobenNr")); Assert.assertTrue(violation.getErrors().get("nebenprobenNr").contains(611)); prot.setPassed(true); } public final void uniqueNebenprobenNrNew(List<Protocol> protocol) { Protocol prot = new Protocol(); prot.setName("MessungValidator"); prot.setType("unique nebenprobenNr (new)"); prot.setPassed(false); protocol.add(prot); Messung messung = new Messung(); messung.setNebenprobenNr("00G2"); messung.setProbeId(4); Violation violation = validator.validate(messung); if (violation.hasErrors()) { Assert.assertFalse(violation.getErrors().containsKey("nebenprobenNr")); } prot.setPassed(true); } public final void uniqueNebenprobenNrUpdate(List<Protocol> protocol) { Protocol prot = new Protocol(); prot.setName("MessungValidator"); prot.setType("unique nebenprobenNr (update)"); prot.setPassed(false); protocol.add(prot); Messung messung = new Messung(); messung.setId(45); messung.setProbeId(4); messung.setNebenprobenNr("00G2"); Violation violation = validator.validate(messung); if (violation.hasErrors()) { Assert.assertFalse(violation.getErrors().containsKey("hauptprobenNr")); return; } prot.setPassed(true); } public final void existingHauptprobenNrUpdate(List<Protocol> protocol) { Protocol prot = new Protocol(); prot.setName("MessungValidator"); prot.setType("existing nebenprobenNr (update)"); prot.setPassed(false); protocol.add(prot); Messung messung = new Messung(); messung.setId(776); messung.setProbeId(1); messung.setNebenprobenNr("0003"); Violation violation = validator.validate(messung); Assert.assertTrue(violation.hasErrors()); Assert.assertTrue(violation.getErrors().containsKey("nebenprobenNr")); Assert.assertTrue(violation.getErrors().get("nebenprobenNr").contains(611)); prot.setPassed(true); } public final void hasMesswert(List<Protocol> protocol) { Protocol prot = new Protocol(); prot.setName("MessungValidator"); prot.setType("has messwert"); prot.setPassed(false); protocol.add(prot); Messung messung = new Messung(); messung.setId(1); messung.setProbeId(4); Violation violation = validator.validate(messung); if (violation.hasWarnings()) { Assert.assertFalse(violation.getWarnings().containsKey("messwert")); } prot.setPassed(true); } public final void hasNoMesswert(List<Protocol> protocol) { Protocol prot = new Protocol(); prot.setName("MessungValidator"); prot.setType("has no messwert"); prot.setPassed(false); protocol.add(prot); Messung messung = new Messung(); messung.setId(990); messung.setProbeId(4); Violation violation = validator.validate(messung); Assert.assertTrue(violation.hasWarnings()); Assert.assertTrue(violation.getWarnings().containsKey("messwert")); Assert.assertTrue(violation.getWarnings().get("messwert").contains(631)); prot.setPassed(true); } }