[Lada-commits] [PATCH 9 of 9] Refactored test environment
Wald Commits
scm-commit at wald.intevation.org
Fri Dec 18 18:01:42 CET 2015
# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1450458060 -3600
# Node ID 59c51da59b30ba0f0cd47769e6aeafeeef4ffe76
# Parent 3d76d476894f3b7a2b93a1786a9e7825f8e6c257
Refactored test environment.
Land tests are using arquillian persistence extension (built on DBUnit).
diff -r 3d76d476894f -r 59c51da59b30 src/test/java/de/intevation/lada/LadaLandTest.java
--- a/src/test/java/de/intevation/lada/LadaLandTest.java Fri Dec 18 17:55:20 2015 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,520 +0,0 @@
-/* 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;
-
-import java.net.URL;
-import java.util.ArrayList;
-
-import org.apache.log4j.Logger;
-import org.jboss.arquillian.container.test.api.RunAsClient;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.arquillian.test.api.ArquillianResource;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.FixMethodOrder;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.MethodSorters;
-
-import de.intevation.lada.test.land.KommentarM;
-import de.intevation.lada.test.land.KommentarP;
-import de.intevation.lada.test.land.Messprogramm;
-import de.intevation.lada.test.land.Messung;
-import de.intevation.lada.test.land.Messwert;
-import de.intevation.lada.test.land.Ort;
-import de.intevation.lada.test.land.Probe;
-import de.intevation.lada.test.land.Query;
-import de.intevation.lada.test.land.Status;
-import de.intevation.lada.test.land.Zusatzwert;
-
-
-/**
- * Class to test the Lada server 'land' services.
- *
- * @author <a href="mailto:rrenkert at intevation.de">Raimund Renkert</a>
- */
- at RunWith(Arquillian.class)
- at FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class LadaLandTest extends BaseTest {
-
- private static Logger logger = Logger.getLogger(LadaLandTest.class);
-
- private Probe probeTest;
- private Query queryTest;
- private Messung messungTest;
- private KommentarP kommentarPTest;
- private KommentarM kommentarMTest;
- private Messwert messwertTest;
- private Ort ortTest;
- private Status statusTest;
- private Zusatzwert zusatzwertTest;
- private Messprogramm messprogrammTest;
-
- public LadaLandTest() {
- probeTest = new Probe();
- queryTest = new Query();
- messungTest = new Messung();
- kommentarPTest = new KommentarP();
- kommentarMTest = new KommentarM();
- messwertTest = new Messwert();
- ortTest = new Ort();
- statusTest = new Status();
- zusatzwertTest = new Zusatzwert();
- messprogrammTest = new Messprogramm();
- testProtocol = new ArrayList<Protocol>();
- verboseLogging = false;
- }
-
- @BeforeClass
- public static void beforeTests() {
- logger.info("---------- Testing Lada Land Services ----------");
- }
-
- /**
- * Testing GET Services.
- */
- @Test
- @RunAsClient
- public final void testA_ProbeGetAllServices(@ArquillianResource URL baseUrl)
- throws Exception {
- this.probeTest.getAllService(baseUrl, testProtocol);
- }
-
- /**
- * Testing GET Services.
- */
- @Test
- @RunAsClient
- public final void testA_ProbeGetByIdServices(@ArquillianResource URL baseUrl)
- throws Exception {
- this.probeTest.getByIdService(baseUrl, testProtocol);
- }
-
- /**
- * Testing GET Services.
- */
- @Test
- @RunAsClient
- public final void testA_ProbeGetByFilterServices(@ArquillianResource URL baseUrl)
- throws Exception {
- this.probeTest.filterService(baseUrl, testProtocol);
- }
-
- /**
- * Testing GET Services.
- */
- @Test
- @RunAsClient
- public final void testA_GetQueryServices(@ArquillianResource URL baseUrl)
- throws Exception {
- this.queryTest.getAllService(baseUrl, testProtocol);
- }
-
- /**
- * Testing GET Services.
- */
- @Test
- @RunAsClient
- public final void testA_MessungGetAllServices(@ArquillianResource URL baseUrl)
- throws Exception {
- this.messungTest.getAllService(baseUrl, testProtocol);
- }
-
- /**
- * Testing GET Services.
- */
- @Test
- @RunAsClient
- public final void testA_MessungGetByIdServices(@ArquillianResource URL baseUrl)
- throws Exception {
- this.messungTest.getByIdService(baseUrl, testProtocol);
- }
-
- /**
- * Testing GET Services.
- */
- @Test
- @RunAsClient
- public final void testA_MessungGetFilterServices(@ArquillianResource URL baseUrl)
- throws Exception {
- this.messungTest.filterService(baseUrl, testProtocol);
- }
-
- /**
- * Testing GET Services.
- */
- @Test
- @RunAsClient
- public final void testA_KommentarPGetAllServices(@ArquillianResource URL baseUrl)
- throws Exception {
- this.kommentarPTest.getAllService(baseUrl, testProtocol);
- }
-
- /**
- * Testing GET Services.
- */
- @Test
- @RunAsClient
- public final void testA_KommentarPGetByIdServices(@ArquillianResource URL baseUrl)
- throws Exception {
- this.kommentarPTest.getByIdService(baseUrl, testProtocol);
- }
-
- /**
- * Testing GET Services.
- */
- @Test
- @RunAsClient
- public final void testA_KommentarPGetFilterServices(@ArquillianResource URL baseUrl)
- throws Exception {
- this.kommentarPTest.filterService(baseUrl, testProtocol);
- }
-
- /**
- * Testing GET Services.
- */
- @Test
- @RunAsClient
- public final void testA_KommentarMGetAllServices(@ArquillianResource URL baseUrl)
- throws Exception {
- this.kommentarMTest.getAllService(baseUrl, testProtocol);
- }
-
- /**
- * Testing GET Services.
- */
- @Test
- @RunAsClient
- public final void testA_KommentarMGetByIdServices(@ArquillianResource URL baseUrl)
- throws Exception {
- this.kommentarMTest.getByIdService(baseUrl, testProtocol);
- }
-
- /**
- * Testing GET Services.
- */
- @Test
- @RunAsClient
- public final void testA_KommentarMGetFilterServices(@ArquillianResource URL baseUrl)
- throws Exception {
- this.kommentarMTest.filterService(baseUrl, testProtocol);
- }
-
- /**
- * Testing GET Services.
- */
- @Test
- @RunAsClient
- public final void testA_MesswertGetAllServices(@ArquillianResource URL baseUrl)
- throws Exception {
- this.messwertTest.getAllService(baseUrl, testProtocol);
- }
-
- /**
- * Testing GET Services.
- */
- @Test
- @RunAsClient
- public final void testA_MesswertGetByIdServices(@ArquillianResource URL baseUrl)
- throws Exception {
- this.messwertTest.getByIdService(baseUrl, testProtocol);
- }
-
- /**
- * Testing GET Services.
- */
- @Test
- @RunAsClient
- public final void testA_MesswertGetFilterServices(@ArquillianResource URL baseUrl)
- throws Exception {
- this.messwertTest.filterService(baseUrl, testProtocol);
- }
-
- /**
- * Testing GET Services.
- */
- @Test
- @RunAsClient
- public final void testA_OrtGetAllServices(@ArquillianResource URL baseUrl)
- throws Exception {
- this.ortTest.getAllService(baseUrl, testProtocol);
- }
-
- /**
- * Testing GET Services.
- */
- @Test
- @RunAsClient
- public final void testA_OrtGetByIdServices(@ArquillianResource URL baseUrl)
- throws Exception {
- this.ortTest.getByIdService(baseUrl, testProtocol);
- }
-
- /**
- * Testing GET Services.
- */
- @Test
- @RunAsClient
- public final void testA_OrtGetFilterServices(@ArquillianResource URL baseUrl)
- throws Exception {
- this.ortTest.filterService(baseUrl, testProtocol);
- }
-
- /**
- * Testing GET Services.
- */
- @Test
- @RunAsClient
- public final void testA_StatusGetAllServices(@ArquillianResource URL baseUrl)
- throws Exception {
- this.statusTest.getAllService(baseUrl, testProtocol);
- }
-
- /**
- * Testing GET Services.
- */
- @Test
- @RunAsClient
- public final void testA_StatusGetByIdServices(@ArquillianResource URL baseUrl)
- throws Exception {
- this.statusTest.getByIdService(baseUrl, testProtocol);
- }
-
- /**
- * Testing GET Services.
- */
- @Test
- @RunAsClient
- public final void testA_StatusGetFilterServices(@ArquillianResource URL baseUrl)
- throws Exception {
- this.statusTest.filterService(baseUrl, testProtocol);
- }
-
- /**
- * Testing GET Services.
- */
- @Test
- @RunAsClient
- public final void testA_ZusatzwertGetAllServices(@ArquillianResource URL baseUrl)
- throws Exception {
- this.zusatzwertTest.getAllService(baseUrl, testProtocol);
- }
-
- /**
- * Testing GET Services.
- */
- @Test
- @RunAsClient
- public final void testA_ZusatzwertGetByIdServices(@ArquillianResource URL baseUrl)
- throws Exception {
- this.zusatzwertTest.getByIdService(baseUrl, testProtocol);
- }
-
- /**
- * Testing GET Services.
- */
- @Test
- @RunAsClient
- public final void testA_ZusatzwertGetFilterServices(@ArquillianResource URL baseUrl)
- throws Exception {
- this.zusatzwertTest.filterService(baseUrl, testProtocol);
- }
-
- /**
- * Testing GET Services.
- */
- @Test
- @RunAsClient
- public final void testA_MessprogrammGetAllServices(@ArquillianResource URL baseUrl)
- throws Exception {
- this.messprogrammTest.getAllService(baseUrl, testProtocol);
- }
-
- /**
- * Testing GET Services.
- */
- @Test
- @RunAsClient
- public final void testA_MessprogrammGetByIdServices(@ArquillianResource URL baseUrl)
- throws Exception {
- this.messprogrammTest.getByIdService(baseUrl, testProtocol);
- }
-
- /**
- * Testing GET Services.
- */
- @Test
- @RunAsClient
- public final void testA_MessprogrammGetFilterServices(@ArquillianResource URL baseUrl)
- throws Exception {
- this.messprogrammTest.filterService(baseUrl, testProtocol);
- }
-
- /**
- * Testing CREATE services.
- */
- @Test
- @RunAsClient
- public final void testB_CreateServices(@ArquillianResource URL baseUrl)
- throws Exception {
- this.probeTest.createService(baseUrl, testProtocol);
- Assert.assertNotNull(this.probeTest.getCreatedProbeId());
- this.messungTest.createService(
- baseUrl,
- testProtocol,
- this.probeTest.getCreatedProbeId());
- this.kommentarPTest.createService(
- baseUrl,
- testProtocol,
- this.probeTest.getCreatedProbeId());
- this.ortTest.createService(
- baseUrl,
- testProtocol,
- this.probeTest.getCreatedProbeId());
- this.zusatzwertTest.createService(
- baseUrl,
- testProtocol,
- this.probeTest.getCreatedProbeId());
- Assert.assertNotNull(this.messungTest.getCreatedMessungId());
- this.kommentarMTest.createService(
- baseUrl,
- testProtocol,
- this.messungTest.getCreatedMessungId());
- this.messwertTest.createService(
- baseUrl,
- testProtocol,
- this.messungTest.getCreatedMessungId());
- this.messprogrammTest.createService(
- baseUrl,
- testProtocol);
- }
-
- /**
- * Testing UPDATE services.
- */
- @Test
- @RunAsClient
- public final void testC_probeUpdateService(@ArquillianResource URL baseUrl)
- throws Exception {
- Assert.assertNotNull(this.probeTest.getCreatedProbeId());
- this.probeTest.updateService(baseUrl, testProtocol);
- }
-
- /**
- * Testing UPDATE services.
- */
- @Test
- @RunAsClient
- public final void testC_messungUpdateService(@ArquillianResource URL baseUrl)
- throws Exception {
- Assert.assertNotNull(this.messungTest.getCreatedMessungId());
- this.messungTest.updateService(baseUrl, testProtocol);
- }
-
- /**
- * Testing UPDATE services.
- */
- @Test
- @RunAsClient
- public final void testC_kommentarPUpdateService(@ArquillianResource URL baseUrl)
- throws Exception {
- Assert.assertNotNull(this.kommentarPTest.getCreatedKommentarId());
- this.kommentarPTest.updateService(baseUrl, testProtocol);
- }
-
- /**
- * Testing UPDATE services.
- */
- @Test
- @RunAsClient
- public final void testC_kommentarMUpdateService(@ArquillianResource URL baseUrl)
- throws Exception {
- Assert.assertNotNull(this.kommentarMTest.getCreatedKommentarId());
- this.kommentarMTest.updateService(baseUrl, testProtocol);
- }
-
- /**
- * Testing UPDATE services.
- */
- @Test
- @RunAsClient
- public final void testC_messwertUpdateService(@ArquillianResource URL baseUrl)
- throws Exception {
- Assert.assertNotNull(this.messwertTest.getCreatedMesswertId());
- this.messwertTest.updateService(baseUrl, testProtocol);
- }
-
- /**
- * Testing UPDATE services.
- */
- @Test
- @RunAsClient
- public final void testC_ortUpdateService(@ArquillianResource URL baseUrl)
- throws Exception {
- Assert.assertNotNull(this.ortTest.getCreatedId());
- this.ortTest.updateService(baseUrl, testProtocol);
- }
-
- /**
- * Testing UPDATE services.
- */
- @Test
- @RunAsClient
- public final void testC_messprogrammUpdateService(@ArquillianResource URL baseUrl)
- throws Exception {
- Assert.assertNotNull(this.ortTest.getCreatedId());
- this.messprogrammTest.updateService(baseUrl, testProtocol);
- }
-
- @Test
- @RunAsClient
- public final void testC_zstatusCreateService(@ArquillianResource URL baseUrl)
- throws Exception {
- this.statusTest.createService(
- baseUrl,
- testProtocol,
- this.messungTest.getCreatedMessungId());
- }
-
- /**
- * Testing UPDATE services.
- */
- @Test
- @RunAsClient
- public final void testC_zstatusUpdateService(@ArquillianResource URL baseUrl)
- throws Exception {
- Assert.assertNotNull(this.ortTest.getCreatedId());
- this.statusTest.updateService(baseUrl, testProtocol);
- }
-
- /**
- * Testing DELETE services.
- */
- @Test
- @RunAsClient
- public final void testD_DeleteServices(@ArquillianResource URL baseUrl)
- throws Exception {
- //Assert.assertNotNull(this.statusTest.getCreatedId());
- //this.statusTest.deleteService(baseUrl, testProtocol);
- Assert.assertNotNull(this.zusatzwertTest.getCreatedId());
- this.zusatzwertTest.deleteService(baseUrl, testProtocol);
- Assert.assertNotNull(this.ortTest.getCreatedId());
- this.ortTest.deleteService(baseUrl, testProtocol);
- Assert.assertNotNull(this.messwertTest.getCreatedMesswertId());
- this.messwertTest.deleteService(baseUrl, testProtocol);
- Assert.assertNotNull(this.kommentarMTest.getCreatedKommentarId());
- this.kommentarMTest.deleteService(baseUrl, testProtocol);
- Assert.assertNotNull(this.kommentarPTest.getCreatedKommentarId());
- this.kommentarPTest.deleteService(baseUrl, testProtocol);
- Assert.assertNotNull(this.messungTest.getCreatedMessungId());
- this.messungTest.deleteService(baseUrl, testProtocol);
- Assert.assertNotNull(this.probeTest.getCreatedProbeId());
- this.probeTest.deleteService(baseUrl, testProtocol);
- this.messprogrammTest.deleteService(baseUrl, testProtocol);
- }
-}
diff -r 3d76d476894f -r 59c51da59b30 src/test/java/de/intevation/lada/LadaStammTest.java
--- a/src/test/java/de/intevation/lada/LadaStammTest.java Fri Dec 18 17:55:20 2015 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,384 +0,0 @@
-/* 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;
-
-import java.io.StringReader;
-import java.net.URL;
-import java.util.ArrayList;
-
-import javax.json.Json;
-import javax.json.JsonException;
-import javax.json.JsonObject;
-import javax.json.JsonReader;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.apache.log4j.Logger;
-import org.jboss.arquillian.container.test.api.RunAsClient;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.arquillian.test.api.ArquillianResource;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.FixMethodOrder;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.MethodSorters;
-
-import de.intevation.lada.BaseTest;
-import de.intevation.lada.test.stamm.Stammdaten;
-
-
-/**
- * Class to test the Lada server stammdaten services.
- *
- * @author <a href="mailto:rrenkert at intevation.de">Raimund Renkert</a>
- */
- at RunWith(Arquillian.class)
- at FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class LadaStammTest extends BaseTest {
-
- private static Logger logger = Logger.getLogger(LadaStammTest.class);
-
- private static Integer createdOrtId;
-
- private Stammdaten stammdatenTest;
-
- public LadaStammTest () {
- stammdatenTest = new Stammdaten();
- testProtocol = new ArrayList<Protocol>();
- verboseLogging = false;
- }
-
- @BeforeClass
- public static void beforeTests() {
- logger.info("---------- Testing Lada Stamm Services ----------");
- }
-
- @Test
- @RunAsClient
- public final void testDatenbasisAll(@ArquillianResource URL baseUrl) {
- stammdatenTest.getAll(baseUrl, "datenbasis", testProtocol);
- }
-
- @Test
- @RunAsClient
- public final void testDatenbasisById(@ArquillianResource URL baseUrl) {
- stammdatenTest.getById(baseUrl, "datenbasis", 9, testProtocol);
- }
-
- @Test
- @RunAsClient
- public final void testMesseinheitAll(@ArquillianResource URL baseUrl) {
- stammdatenTest.getAll(baseUrl, "messeinheit", testProtocol);
- }
-
- @Test
- @RunAsClient
- public final void testMesseinheitById(@ArquillianResource URL baseUrl) {
- stammdatenTest.getById(baseUrl, "messeinheit", 207, testProtocol);
- }
-
- @Test
- @RunAsClient
- public final void testMessgroesseAll(@ArquillianResource URL baseUrl) {
- stammdatenTest.getAll(baseUrl, "messgroesse", testProtocol);
- }
-
- @Test
- @RunAsClient
- public final void testMessgroesseById(@ArquillianResource URL baseUrl) {
- stammdatenTest.getById(baseUrl, "messgroesse", 56, testProtocol);
- }
-
- @Test
- @RunAsClient
- public final void testMessmethodeAll(@ArquillianResource URL baseUrl) {
- stammdatenTest.getAll(baseUrl, "messmethode", testProtocol);
- }
-
- @Test
- @RunAsClient
- public final void testMessmethodeById(@ArquillianResource URL baseUrl) {
- stammdatenTest.getById(baseUrl, "messmethode", "GI", testProtocol);
- }
-
- @Test
- @RunAsClient
- public final void testMessstelleAll(@ArquillianResource URL baseUrl) {
- stammdatenTest.getAll(baseUrl, "messstelle", testProtocol);
- }
-
- @Test
- @RunAsClient
- public final void testMessstelleById(@ArquillianResource URL baseUrl) {
- stammdatenTest.getById(baseUrl, "messstelle", "06010", testProtocol);
- }
-
- @Test
- @RunAsClient
- public final void testNetzbetreiberAll(@ArquillianResource URL baseUrl) {
- stammdatenTest.getAll(baseUrl, "netzbetreiber", testProtocol);
- }
-
- @Test
- @RunAsClient
- public final void testNetzbetreiberById(@ArquillianResource URL baseUrl) {
- stammdatenTest.getById(baseUrl, "netzbetreiber", "06", testProtocol);
- }
-
- @Test
- @RunAsClient
- public final void testPflichtmessgroesseAll(@ArquillianResource URL baseUrl) {
- stammdatenTest.getAll(baseUrl, "pflichtmessgroesse", testProtocol);
- }
-
- @Test
- @RunAsClient
- public final void testPflichtmessgroesseById(@ArquillianResource URL baseUrl) {
- stammdatenTest.getById(baseUrl, "pflichtmessgroesse", 33, testProtocol);
- }
-
- @Test
- @RunAsClient
- public final void testProbenartAll(@ArquillianResource URL baseUrl) {
- stammdatenTest.getAll(baseUrl, "probenart", testProtocol);
- }
-
- @Test
- @RunAsClient
- public final void testProbenartById(@ArquillianResource URL baseUrl) {
- stammdatenTest.getById(baseUrl, "probenart", 1, testProtocol);
- }
-
- @Test
- @RunAsClient
- public final void testProbenzusatzAll(@ArquillianResource URL baseUrl) {
- stammdatenTest.getAll(baseUrl, "probenzusatz", testProtocol);
- }
-
- @Test
- @RunAsClient
- public final void testProbenzusatzById(@ArquillianResource URL baseUrl) {
- stammdatenTest.getById(baseUrl, "probenzusatz", "A74", testProtocol);
- }
-
- @Test
- @RunAsClient
- public final void testLocationAll(@ArquillianResource URL baseUrl) {
- stammdatenTest.getAll(baseUrl, "location", testProtocol);
- }
-
- @Test
- @RunAsClient
- public final void testLocationById(@ArquillianResource URL baseUrl) {
- stammdatenTest.getById(baseUrl, "location", "19", testProtocol);
- }
-
- @Test
- @RunAsClient
- public final void testKoordinatenartAll(@ArquillianResource URL baseUrl) {
- stammdatenTest.getAll(baseUrl, "koordinatenart", testProtocol);
- }
-
- @Test
- @RunAsClient
- public final void testKoordinatenartById(@ArquillianResource URL baseUrl) {
- stammdatenTest.getById(baseUrl, "koordinatenart", 2, testProtocol);
- }
-
- @Test
- @RunAsClient
- public final void testStaatAll(@ArquillianResource URL baseUrl) {
- stammdatenTest.getAll(baseUrl, "staat", testProtocol);
- }
-
- @Test
- @RunAsClient
- public final void testStaatById(@ArquillianResource URL baseUrl) {
- stammdatenTest.getById(baseUrl, "staat", 322, testProtocol);
- }
-
- @Test
- @RunAsClient
- public final void testUmweltAll(@ArquillianResource URL baseUrl) {
- stammdatenTest.getAll(baseUrl, "umwelt", testProtocol);
- }
-
- @Test
- @RunAsClient
- public final void testUmweltById(@ArquillianResource URL baseUrl) {
- stammdatenTest.getById(baseUrl, "umwelt", "L6", testProtocol);
- }
-
- @Test
- @RunAsClient
- public final void testVerwaltungseinheitAll(@ArquillianResource URL baseUrl) {
- stammdatenTest.getAll(baseUrl, "verwaltungseinheit", testProtocol);
- }
-
- @Test
- @RunAsClient
- public final void testVerwaltungseinheitById(@ArquillianResource URL baseUrl) {
- stammdatenTest.getById(baseUrl, "verwaltungseinheit", "09575134", testProtocol);
- }
-
- /* TODO: The location service is moved to the "land"-services in
- future version. */
- @Test
- @RunAsClient
- public final void testLocation1CreateService(@ArquillianResource URL baseUrl)
- throws Exception {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("locationService");
- prot.setType("create");
- prot.setPassed(false);
- testProtocol.add(prot);
- try {
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target = client.target(baseUrl + "location");
- /* Send a post request containing a new kommentar*/
- String newObj = "{\"beschreibung\":\"Neuer Ort\"," +
- "\"bezeichnung\":\"T123456\",\"hoeheLand\":null," +
- "\"koordXExtern\":\"32531152\",\"koordYExtern\":\"5684269\"," +
- "\"latitude\":51.30888,\"letzteAenderung\":1376287046332," +
- "\"longitude\":9.44693,\"nutsCode\":\"DE731\",\"unscharf\":" +
- "\"0\",\"netzbetreiberId\":null,\"staatId\":0," +
- "\"verwaltungseinheitId\":\"06611000\",\"otyp\":\"Z\"," +
- "\"koordinatenartId\":5}";
-
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .post(Entity.entity(newObj, MediaType.APPLICATION_JSON));
- String entity = response.readEntity(String.class);
- /* Try to parse the response*/
- JsonReader fromServiceReader =
- Json.createReader(new StringReader(entity));
- JsonObject content = fromServiceReader.readObject();
- /* Save the id*/
- createdOrtId =
- content.getJsonObject("data").getJsonNumber("id").intValue();
- prot.addInfo("ortId", createdOrtId);
- /* Verify the response*/
- Assert.assertTrue(content.getBoolean("success"));
- prot.addInfo("success", content.getBoolean("success"));
- Assert.assertEquals("200", content.getString("message"));
- prot.addInfo("message", content.getString("message"));
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-
- /**
- * Test the UPDATE Service.
- *
- * @param baseUrl The url pointing to the test deployment.
- */
- @Test
- @RunAsClient
- public final void testLocation2UpdateService(@ArquillianResource URL baseUrl)
- throws Exception {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("locationService");
- prot.setType("update");
- prot.setPassed(false);
- testProtocol.add(prot);
- try {
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target =
- client.target(baseUrl + "location/" + createdOrtId);
- prot.addInfo("locationId", createdOrtId);
- /* Request a kommentar with the id saved when created a kommentar*/
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .get();
- String entity = response.readEntity(String.class);
- /* Try to parse the response*/
- JsonReader reader = Json.createReader(new StringReader(entity));
- JsonObject oldObj = reader.readObject().getJsonObject("data");
- /* Change the text*/
- String updatedEntity =
- oldObj.toString().replace("Neuer Ort", "Neuerer Ort");
- prot.addInfo("updated field", "beschreibung");
- prot.addInfo("updated value", "Neuer Ort");
- prot.addInfo("updated to", "Neuerer Ort");
- /* Send the updated kommentar via put reauest*/
- WebTarget putTarget = client.target(baseUrl + "location/" + createdOrtId);
- Response updated = putTarget.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .put(Entity.entity(updatedEntity, MediaType.APPLICATION_JSON));
- /* Try to parse the response*/
- JsonReader updatedReader = Json.createReader(
- new StringReader(updated.readEntity(String.class)));
- JsonObject updatedObj = updatedReader.readObject();
- /* Verify the response*/
- Assert.assertTrue(updatedObj.getBoolean("success"));
- prot.addInfo("success", updatedObj.getBoolean("success"));
- Assert.assertEquals("200", updatedObj.getString("message"));
- prot.addInfo("message", updatedObj.getString("message"));
- Assert.assertEquals("Neuerer Ort",
- updatedObj.getJsonObject("data").getString("beschreibung"));
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-
- @Test
- @RunAsClient
- public final void testLocation3DeleteService(@ArquillianResource URL baseUrl)
- throws Exception {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("locationService");
- prot.setType("delete");
- prot.setPassed(false);
- testProtocol.add(prot);
- try {
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target =
- client.target(baseUrl + "location/" + createdOrtId);
- prot.addInfo("locationId", createdOrtId);
- /* Delete the object with the saved id*/
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .delete();
- String entity = response.readEntity(String.class);
- /* Try to parse the response*/
- JsonReader reader = Json.createReader(new StringReader(entity));
- JsonObject respObj = reader.readObject();
- /* Verify the response*/
- Assert.assertTrue(respObj.getBoolean("success"));
- prot.addInfo("success", respObj.getBoolean("success"));
- Assert.assertEquals("200", respObj.getString("message"));
- prot.addInfo("message", respObj.getString("message"));
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-}
diff -r 3d76d476894f -r 59c51da59b30 src/test/java/de/intevation/lada/LadaValidatorTest.java
--- a/src/test/java/de/intevation/lada/LadaValidatorTest.java Fri Dec 18 17:55:20 2015 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,257 +0,0 @@
-package de.intevation.lada;
-
-import static de.intevation.lada.BaseTest.ARCHIVE_NAME;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.inject.Inject;
-
-import org.apache.log4j.Logger;
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.asset.EmptyAsset;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-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;
-
- at RunWith(Arquillian.class)
-public class LadaValidatorTest {
-
- private static Logger logger = Logger.getLogger(LadaStammTest.class);
-
- protected static List<Protocol> testProtocol;
-
- protected static boolean verboseLogging = false;
-
- @Inject
- @ValidationConfig(type="Probe")
- private Validator probeValidator;
- private Probe probeTest;
-
- @Inject
- @ValidationConfig(type="Messung")
- 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>();
- }
-
- /**
- * Create a deployable WAR archive.
- */
- @Deployment(testable=true)
- public static WebArchive createDeployment() throws Exception {
- WebArchive archive = ShrinkWrap.create(WebArchive.class, ARCHIVE_NAME)
- .addPackages(true, Package.getPackage("de.intevation.lada"))
- .deleteClass("de.intevation.lada.util.auth.ShibbolethFilter")
- .addAsResource("log4j.properties", "log4j.properties")
- .addAsResource("shibboleth.properties", "shibboleth.properties")
- .addAsResource("probequery.json", "probequery.json")
- .addAsResource("messprogrammquery.json", "messprogrammquery.json")
- .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
- .addAsResource("META-INF/test-persistence.xml",
- "META-INF/persistence.xml");
- return archive;
- }
-
-
- @BeforeClass
- public static void beforeTests() {
- logger.info("---------- Testing Lada Validator ----------");
- }
-
- @After
- public final void printLogs() {
- for (Protocol p : testProtocol) {
- logger.info(p.toString(verboseLogging));
- }
- }
-
- @AfterClass
- public static final void afterTests() {
- System.out.println("");
- }
-
- @Test
- public final void probeHasHauptprobenNr() {
- probeTest.setValidator(probeValidator);
- probeTest.hasHauptprobenNr(testProtocol);
- }
-
- @Test
- public final void probeHasNoHauptprobenNr() {
- probeTest.setValidator(probeValidator);
- probeTest.hasNoHauptprobenNr(testProtocol);
- }
-
- @Test
- public final void probeExistingHauptprobenNrNew() {
- probeTest.setValidator(probeValidator);
- probeTest.existingHauptprobenNrNew(testProtocol);
- }
-
- @Test
- public final void probeUniqueHauptprobenNrNew() {
- probeTest.setValidator(probeValidator);
- probeTest.uniqueHauptprobenNrNew(testProtocol);
- }
-
- @Test
- public final void probeExistingHauptprobenNrUpdate() {
- probeTest.setValidator(probeValidator);
- probeTest.existingHauptprobenNrUpdate(testProtocol);
- }
-
- @Test
- public final void probeUniqueHauptprobenNrUpdate() {
- probeTest.setValidator(probeValidator);
- probeTest.uniqueHauptprobenNrUpdate(testProtocol);
- }
-
- @Test
- public final void probeHasEntnahmeOrt() {
- probeTest.setValidator(probeValidator);
- probeTest.hasEntnahmeOrt(testProtocol);
- }
-
- @Test
- public final void probeHasNoEntnahmeOrt() {
- probeTest.setValidator(probeValidator);
- probeTest.hasNoEntnahmeOrt(testProtocol);
- }
-
- @Test
- public final void probeHasProbenahmeBegin() {
- probeTest.setValidator(probeValidator);
- probeTest.hasProbeentnahmeBegin(testProtocol);
- }
-
- @Test
- public final void probeHasNoProbenahmeBegin() {
- probeTest.setValidator(probeValidator);
- probeTest.hasNoProbeentnahmeBegin(testProtocol);
- }
-
- @Test
- public final void probeTimeNoEndProbenahmeBegin() {
- probeTest.setValidator(probeValidator);
- probeTest.timeNoEndProbeentnahmeBegin(testProtocol);
- }
-
- @Test
- public final void probeTimeNoBeginProbenahmeBegin() {
- probeTest.setValidator(probeValidator);
- probeTest.timeNoBeginProbeentnahmeBegin(testProtocol);
- }
-
- @Test
- public final void probeTimeBeginAfterEndProbenahmeBegin() {
- probeTest.setValidator(probeValidator);
- probeTest.timeBeginAfterEndProbeentnahmeBegin(testProtocol);
- }
-
- @Test
- public final void probeTimeBeginFutureProbenahmeBegin() {
- probeTest.setValidator(probeValidator);
- probeTest.timeBeginFutureProbeentnahmeBegin(testProtocol);
- }
-
- @Test
- public final void probeHasUmwelt() {
- probeTest.setValidator(probeValidator);
- probeTest.hasUmwelt(testProtocol);
- }
-
- @Test
- public final void probeHasNoUmwelt() {
- probeTest.setValidator(probeValidator);
- probeTest.hasNoUmwelt(testProtocol);
- }
-
- @Test
- public final void probeHasEmptyUmwelt() {
- probeTest.setValidator(probeValidator);
- probeTest.hasEmptyUmwelt(testProtocol);
- }
-
- @Test
- public final void messungHasNebenprobenNr() {
- messungTest.setValidator(messungValidator);
- messungTest.hasNebenprobenNr(testProtocol);
- }
-
- @Test
- public final void messungHasNoNebenprobenNr() {
- messungTest.setValidator(messungValidator);
- messungTest.hasNoNebenprobenNr(testProtocol);
- }
-
- @Test
- public final void messungHasEmptyNebenprobenNr() {
- messungTest.setValidator(messungValidator);
- messungTest.hasEmptyNebenprobenNr(testProtocol);
- }
-
- @Test
- public final void messungUniqueNebenprobenNrNew() {
- messungTest.setValidator(messungValidator);
- messungTest.uniqueNebenprobenNrNew(testProtocol);
- }
-
- @Test
- public final void messungUniqueNebenprobenNrUpdate() {
- messungTest.setValidator(messungValidator);
- messungTest.uniqueNebenprobenNrUpdate(testProtocol);
- }
-
- @Test
- public final void messungExistingNebenprobenNrNew() {
- messungTest.setValidator(messungValidator);
- messungTest.existingNebenprobenNrNew(testProtocol);
- }
-
- @Test
- public final void messungExistingNebenprobenNrUpdate() {
- messungTest.setValidator(messungValidator);
- messungTest.existingHauptprobenNrUpdate(testProtocol);
- }
-
- @Test
- public final void messungHasMesswert() {
- messungTest.setValidator(messungValidator);
- messungTest.hasMesswert(testProtocol);
- }
-
- @Test
- public final void messungHasNoMesswert() {
- messungTest.setValidator(messungValidator);
- messungTest.hasNoMesswert(testProtocol);
- }
-
- @Test
- public final void statusKombiNegative() {
- statusTest.setValidator(statusValidator);
- statusTest.checkKombiNegative(testProtocol);
- }
-}
diff -r 3d76d476894f -r 59c51da59b30 src/test/java/de/intevation/lada/LandTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/java/de/intevation/lada/LandTest.java Fri Dec 18 18:01:00 2015 +0100
@@ -0,0 +1,378 @@
+/* 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;
+
+import java.net.URL;
+import java.util.ArrayList;
+
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+import org.apache.log4j.Logger;
+import org.jboss.arquillian.container.test.api.RunAsClient;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.junit.InSequence;
+import org.jboss.arquillian.persistence.Cleanup;
+import org.jboss.arquillian.persistence.CleanupUsingScript;
+import org.jboss.arquillian.persistence.DataSource;
+import org.jboss.arquillian.persistence.TestExecutionPhase;
+import org.jboss.arquillian.persistence.UsingDataSet;
+import org.jboss.arquillian.test.api.ArquillianResource;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import de.intevation.lada.model.land.LKommentarM;
+import de.intevation.lada.model.land.LKommentarP;
+import de.intevation.lada.model.land.LMessung;
+import de.intevation.lada.model.land.LMesswert;
+import de.intevation.lada.model.land.LOrtszuordnung;
+import de.intevation.lada.model.land.LProbe;
+import de.intevation.lada.model.land.LZusatzWert;
+import de.intevation.lada.model.land.Messprogramm;
+import de.intevation.lada.test.land.KommentarMTest;
+import de.intevation.lada.test.land.KommentarPTest;
+import de.intevation.lada.test.land.MessprogrammTest;
+import de.intevation.lada.test.land.MessungTest;
+import de.intevation.lada.test.land.MesswertTest;
+import de.intevation.lada.test.land.OrtszuordnungTest;
+import de.intevation.lada.test.land.ProbeTest;
+import de.intevation.lada.test.land.QueryTest;
+import de.intevation.lada.test.land.StatusTest;
+import de.intevation.lada.test.land.ZusatzwertTest;
+
+
+/**
+ * Class to test the Lada server 'land' services.
+ *
+ * @author <a href="mailto:rrenkert at intevation.de">Raimund Renkert</a>
+ */
+ at RunWith(Arquillian.class)
+public class LandTest extends BaseTest {
+
+ @Inject
+ Logger internalLogger;
+
+ @PersistenceContext(unitName="land")
+ EntityManager em;
+
+ private ProbeTest probeTest;
+ private MessungTest messungTest;
+ private KommentarMTest mkommentarTest;
+ private KommentarPTest pkommentarTest;
+ private OrtszuordnungTest ortszuordnungTest;
+ private ZusatzwertTest zusatzwertTest;
+ private MesswertTest messwertTest;
+ private StatusTest statusTest;
+ private MessprogrammTest messprogrammTest;
+ private QueryTest queryTest;
+
+ public LandTest() {
+ probeTest = new ProbeTest();
+ messungTest = new MessungTest();
+ mkommentarTest = new KommentarMTest();
+ pkommentarTest = new KommentarPTest();
+ ortszuordnungTest = new OrtszuordnungTest();
+ zusatzwertTest = new ZusatzwertTest();
+ messwertTest = new MesswertTest();
+ statusTest = new StatusTest();
+ messprogrammTest = new MessprogrammTest();
+ queryTest = new QueryTest();
+ testProtocol = new ArrayList<Protocol>();
+ verboseLogging = false;
+ }
+
+ @BeforeClass
+ public static void beforeTests() {
+ }
+
+ /*------ REST service tests ------*/
+
+ /**
+ * Tests for probe operations
+ */
+ @Test
+ @InSequence(2)
+ @RunAsClient
+ public final void testProbe(@ArquillianResource URL baseUrl)
+ throws Exception {
+ probeTest.init(baseUrl, testProtocol);
+ probeTest.execute();
+ }
+
+ /**
+ * Tests for pkommentar operations
+ */
+ @Test
+ @InSequence(4)
+ @RunAsClient
+ public final void testPkommentar(@ArquillianResource URL baseUrl)
+ throws Exception {
+ pkommentarTest.init(baseUrl, testProtocol);
+ pkommentarTest.execute();
+ }
+
+ /**
+ * Tests for ortszurodnung operations
+ */
+ @Test
+ @InSequence(6)
+ @RunAsClient
+ public final void testOrtszuordnung(@ArquillianResource URL baseUrl)
+ throws Exception {
+ ortszuordnungTest.init(baseUrl, testProtocol);
+ ortszuordnungTest.execute();
+ }
+
+ /**
+ * Tests for zustzwert operations
+ */
+ @Test
+ @InSequence(8)
+ @RunAsClient
+ public final void testZusatzwert(@ArquillianResource URL baseUrl)
+ throws Exception {
+ zusatzwertTest.init(baseUrl, testProtocol);
+ zusatzwertTest.execute();
+ }
+ /**
+ * Tests for messung operations
+ */
+ @Test
+ @InSequence(10)
+ @RunAsClient
+ public final void testMessung(@ArquillianResource URL baseUrl)
+ throws Exception {
+ messungTest.init(baseUrl, testProtocol);
+ messungTest.execute();
+ }
+
+ /**
+ * Tests for mkommentar operations
+ */
+ @Test
+ @InSequence(12)
+ @RunAsClient
+ public final void testMkommentar(@ArquillianResource URL baseUrl)
+ throws Exception {
+ mkommentarTest.init(baseUrl, testProtocol);
+ mkommentarTest.execute();
+ }
+
+ /**
+ * Tests for mkommentar operations
+ */
+ @Test
+ @InSequence(14)
+ @RunAsClient
+ public final void testMesswert(@ArquillianResource URL baseUrl)
+ throws Exception {
+ messwertTest.init(baseUrl, testProtocol);
+ messwertTest.execute();
+ }
+
+ @Test
+ @InSequence(16)
+ @RunAsClient
+ public final void testStatus(@ArquillianResource URL baseUrl)
+ throws Exception {
+ statusTest.init(baseUrl, testProtocol);
+ statusTest.execute();
+ }
+
+ @Test
+ @InSequence(18)
+ @RunAsClient
+ public final void testMessprogramm(@ArquillianResource URL baseUrl)
+ throws Exception {
+ messprogrammTest.init(baseUrl, testProtocol);
+ messprogrammTest.execute();
+ }
+
+ @Test
+ @InSequence(20)
+ @RunAsClient
+ public final void testQuery(@ArquillianResource URL baseUrl)
+ throws Exception {
+ queryTest.init(baseUrl, testProtocol);
+ queryTest.execute();
+ }
+
+ /*------ Database operations ------*/
+
+ /**
+ * Insert a probe object into the database.
+ */
+ @Test
+ @InSequence(1)
+ @UsingDataSet("datasets/dbUnit_probe.json")
+ @DataSource("java:jboss/lada-land")
+ @Cleanup(phase=TestExecutionPhase.NONE)
+ public final void prepareDatabaseProbe() throws Exception {
+ Protocol protocol = new Protocol();
+ protocol.setName("database");
+ protocol.setType("insert probe");
+ protocol.addInfo("database", "Insert Probe into database");
+ testProtocol.add(protocol);
+ LProbe probe = em.find(LProbe.class, 1000);
+ Assert.assertNotNull(probe);
+ protocol.setPassed(true);
+ }
+
+ /**
+ * Insert a probe kommentar into the database.
+ */
+ @Test
+ @InSequence(3)
+ @UsingDataSet("datasets/dbUnit_pkommentar.json")
+ @DataSource("java:jboss/lada-land")
+ @Cleanup(phase=TestExecutionPhase.NONE)
+ public final void prepareDatabaseKommentarP() throws Exception {
+ Protocol protocol = new Protocol();
+ protocol.setName("database");
+ protocol.setType("insert kommentar_p");
+ protocol.addInfo("database", "Insert KommentarP into database");
+ testProtocol.add(protocol);
+ LKommentarP kommentar = em.find(LKommentarP.class, 1000);
+ Assert.assertNotNull(kommentar);
+ protocol.setPassed(true);
+ }
+
+ /**
+ * Insert a ortszuordnung into the database.
+ */
+ @Test
+ @InSequence(5)
+ @UsingDataSet("datasets/dbUnit_ortszuordnung.json")
+ @DataSource("java:jboss/lada-land")
+ @Cleanup(phase=TestExecutionPhase.NONE)
+ public final void prepareDatabaseOrtszuordnung() throws Exception {
+ Protocol protocol = new Protocol();
+ protocol.setName("database");
+ protocol.setType("insert ortszuordnung");
+ protocol.addInfo("database", "Insert Ortszuordnung into database");
+ testProtocol.add(protocol);
+ LOrtszuordnung ortszuordnung = em.find(LOrtszuordnung.class, 1000);
+ Assert.assertNotNull(ortszuordnung);
+ protocol.setPassed(true);
+ }
+
+ /**
+ * Insert a zusatzwert into the database.
+ */
+ @Test
+ @InSequence(7)
+ @UsingDataSet("datasets/dbUnit_zusatzwert.json")
+ @DataSource("java:jboss/lada-land")
+ @Cleanup(phase=TestExecutionPhase.NONE)
+ public final void prepareDatabaseZusatzwert() throws Exception {
+ Protocol protocol = new Protocol();
+ protocol.setName("database");
+ protocol.setType("insert zusatzwert");
+ protocol.addInfo("database", "Insert Zusatzwert into database");
+ testProtocol.add(protocol);
+ LZusatzWert zusatzwert = em.find(LZusatzWert.class, 1000);
+ Assert.assertNotNull(zusatzwert);
+ protocol.setPassed(true);
+ }
+
+ /**
+ * Insert a messung object into the database.
+ */
+ @Test
+ @InSequence(9)
+ @UsingDataSet("datasets/dbUnit_messung.json")
+ @DataSource("java:jboss/lada-land")
+ @Cleanup(phase=TestExecutionPhase.NONE)
+ public final void prepareDatabaseMessung() throws Exception {
+ Protocol protocol = new Protocol();
+ protocol.setName("database");
+ protocol.setType("insert messung");
+ protocol.addInfo("database", "Insert Messung into database");
+ testProtocol.add(protocol);
+ LMessung messung = em.find(LMessung.class, 1200);
+ messung.setStatus(1000);
+ em.merge(messung);
+ Assert.assertNotNull(messung);
+ protocol.setPassed(true);
+ }
+
+ /**
+ * Insert a messungs kommentar into the database.
+ */
+ @Test
+ @InSequence(11)
+ @UsingDataSet("datasets/dbUnit_mkommentar.json")
+ @DataSource("java:jboss/lada-land")
+ @Cleanup(phase=TestExecutionPhase.NONE)
+ public final void prepareDatabaseKommentarM() throws Exception {
+ Protocol protocol = new Protocol();
+ protocol.setName("database");
+ protocol.setType("insert kommentar_m");
+ protocol.addInfo("database", "Insert KommentarM into database");
+ testProtocol.add(protocol);
+ LKommentarM kommentar = em.find(LKommentarM.class, 1000);
+ Assert.assertNotNull(kommentar);
+ protocol.setPassed(true);
+ }
+
+ /**
+ * Insert a messwert into the database.
+ */
+ @Test
+ @InSequence(13)
+ @UsingDataSet("datasets/dbUnit_messwert.json")
+ @DataSource("java:jboss/lada-land")
+ @Cleanup(phase=TestExecutionPhase.NONE)
+ public final void prepareDatabaseMesswert() throws Exception {
+ Protocol protocol = new Protocol();
+ protocol.setName("database");
+ protocol.setType("insert messwert");
+ protocol.addInfo("database", "Insert Messwert into database");
+ testProtocol.add(protocol);
+ LMesswert messwert = em.find(LMesswert.class, 10000);
+ Assert.assertNotNull(messwert);
+ protocol.setPassed(true);
+ }
+
+ /**
+ * Insert a messprogramm into the database.
+ */
+ @Test
+ @InSequence(17)
+ @UsingDataSet("datasets/dbUnit_messprogramm.json")
+ @DataSource("java:jboss/lada-land")
+ @Cleanup(phase=TestExecutionPhase.NONE)
+ public final void prepareDatabaseMessprogramm() throws Exception {
+ Protocol protocol = new Protocol();
+ protocol.setName("database");
+ protocol.setType("insert messprogramm");
+ protocol.addInfo("database", "Insert Messprogramm into database");
+ testProtocol.add(protocol);
+ Messprogramm messprogramm = em.find(Messprogramm.class, 1000);
+ Assert.assertNotNull(messprogramm);
+ protocol.setPassed(true);
+ }
+ /**
+ * Cleanup the database.
+ */
+ @Test
+ @InSequence(19)
+ @DataSource("java:jboss/lada-land")
+ @CleanupUsingScript("datasets/cleanup.sql")
+ public final void cleanUp() {
+ Protocol protocol = new Protocol();
+ protocol.addInfo("database", "Cleaning the database.");
+ protocol.setName("database");
+ protocol.setType("cleanup");
+ protocol.setPassed(true);
+ testProtocol.add(protocol);
+ }
+}
diff -r 3d76d476894f -r 59c51da59b30 src/test/java/de/intevation/lada/StammdatenTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/java/de/intevation/lada/StammdatenTest.java Fri Dec 18 18:01:00 2015 +0100
@@ -0,0 +1,389 @@
+/* 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;
+
+import java.io.StringReader;
+import java.net.URL;
+import java.util.ArrayList;
+
+import javax.json.Json;
+import javax.json.JsonException;
+import javax.json.JsonObject;
+import javax.json.JsonReader;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.apache.log4j.Logger;
+import org.jboss.arquillian.container.test.api.RunAsClient;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.test.api.ArquillianResource;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.FixMethodOrder;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.MethodSorters;
+
+import de.intevation.lada.test.stamm.Stammdaten;
+
+
+/**
+ * Class to test the Lada server stammdaten services.
+ *
+ * @author <a href="mailto:rrenkert at intevation.de">Raimund Renkert</a>
+ */
+ at RunWith(Arquillian.class)
+ at FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class StammdatenTest extends BaseTest {
+
+ private static Logger logger = Logger.getLogger(StammdatenTest.class);
+
+ private static Integer createdOrtId;
+
+ private Stammdaten stammdatenTest;
+
+ public StammdatenTest () {
+ stammdatenTest = new Stammdaten();
+ testProtocol = new ArrayList<Protocol>();
+ verboseLogging = false;
+ }
+
+ @BeforeClass
+ public static void beforeTests() {
+ logger.info("---------- Testing Lada Stamm Services ----------");
+ }
+
+ @Test
+ @RunAsClient
+ public final void testDatenbasisAll(@ArquillianResource URL baseUrl) {
+ stammdatenTest.getAll(baseUrl, "datenbasis", testProtocol);
+ }
+
+ @Test
+ @RunAsClient
+ public final void testDatenbasisById(@ArquillianResource URL baseUrl) {
+ stammdatenTest.getById(baseUrl, "datenbasis", 9, testProtocol);
+ }
+
+ @Test
+ @RunAsClient
+ public final void testMesseinheitAll(@ArquillianResource URL baseUrl) {
+ stammdatenTest.getAll(baseUrl, "messeinheit", testProtocol);
+ }
+
+ @Test
+ @RunAsClient
+ public final void testMesseinheitById(@ArquillianResource URL baseUrl) {
+ stammdatenTest.getById(baseUrl, "messeinheit", 207, testProtocol);
+ }
+
+ @Test
+ @RunAsClient
+ public final void testMessgroesseAll(@ArquillianResource URL baseUrl) {
+ stammdatenTest.getAll(baseUrl, "messgroesse", testProtocol);
+ }
+
+ @Test
+ @RunAsClient
+ public final void testMessgroesseById(@ArquillianResource URL baseUrl) {
+ stammdatenTest.getById(baseUrl, "messgroesse", 56, testProtocol);
+ }
+
+ @Test
+ @RunAsClient
+ public final void testMessmethodeAll(@ArquillianResource URL baseUrl) {
+ stammdatenTest.getAll(baseUrl, "messmethode", testProtocol);
+ }
+
+ @Test
+ @RunAsClient
+ public final void testMessmethodeById(@ArquillianResource URL baseUrl) {
+ stammdatenTest.getById(baseUrl, "messmethode", "GI", testProtocol);
+ }
+
+ @Test
+ @RunAsClient
+ public final void testMessstelleAll(@ArquillianResource URL baseUrl) {
+ stammdatenTest.getAll(baseUrl, "messstelle", testProtocol);
+ }
+
+ @Test
+ @RunAsClient
+ public final void testMessstelleById(@ArquillianResource URL baseUrl) {
+ stammdatenTest.getById(baseUrl, "messstelle", "06010", testProtocol);
+ }
+
+ @Test
+ @RunAsClient
+ public final void testNetzbetreiberAll(@ArquillianResource URL baseUrl) {
+ stammdatenTest.getAll(baseUrl, "netzbetreiber", testProtocol);
+ }
+
+ @Test
+ @RunAsClient
+ public final void testNetzbetreiberById(@ArquillianResource URL baseUrl) {
+ stammdatenTest.getById(baseUrl, "netzbetreiber", "06", testProtocol);
+ }
+
+ @Test
+ @RunAsClient
+ public final void testPflichtmessgroesseAll(@ArquillianResource URL baseUrl) {
+ stammdatenTest.getAll(baseUrl, "pflichtmessgroesse", testProtocol);
+ }
+
+ @Test
+ @RunAsClient
+ public final void testPflichtmessgroesseById(@ArquillianResource URL baseUrl) {
+ stammdatenTest.getById(baseUrl, "pflichtmessgroesse", 33, testProtocol);
+ }
+
+ @Test
+ @RunAsClient
+ public final void testProbenartAll(@ArquillianResource URL baseUrl) {
+ stammdatenTest.getAll(baseUrl, "probenart", testProtocol);
+ }
+
+ @Test
+ @RunAsClient
+ public final void testProbenartById(@ArquillianResource URL baseUrl) {
+ stammdatenTest.getById(baseUrl, "probenart", 1, testProtocol);
+ }
+
+ @Test
+ @RunAsClient
+ public final void testProbenzusatzAll(@ArquillianResource URL baseUrl) {
+ stammdatenTest.getAll(baseUrl, "probenzusatz", testProtocol);
+ }
+
+ @Test
+ @RunAsClient
+ public final void testProbenzusatzById(@ArquillianResource URL baseUrl) {
+ stammdatenTest.getById(baseUrl, "probenzusatz", "A74", testProtocol);
+ }
+
+ @Test
+ @Ignore
+ @RunAsClient
+ public final void testLocationAll(@ArquillianResource URL baseUrl) {
+ stammdatenTest.getAll(baseUrl, "location", testProtocol);
+ }
+
+ @Test
+ @Ignore
+ @RunAsClient
+ public final void testLocationById(@ArquillianResource URL baseUrl) {
+ stammdatenTest.getById(baseUrl, "location", "19", testProtocol);
+ }
+
+ @Test
+ @RunAsClient
+ public final void testKoordinatenartAll(@ArquillianResource URL baseUrl) {
+ stammdatenTest.getAll(baseUrl, "koordinatenart", testProtocol);
+ }
+
+ @Test
+ @RunAsClient
+ public final void testKoordinatenartById(@ArquillianResource URL baseUrl) {
+ stammdatenTest.getById(baseUrl, "koordinatenart", 2, testProtocol);
+ }
+
+ @Test
+ @RunAsClient
+ public final void testStaatAll(@ArquillianResource URL baseUrl) {
+ stammdatenTest.getAll(baseUrl, "staat", testProtocol);
+ }
+
+ @Test
+ @RunAsClient
+ public final void testStaatById(@ArquillianResource URL baseUrl) {
+ stammdatenTest.getById(baseUrl, "staat", 322, testProtocol);
+ }
+
+ @Test
+ @RunAsClient
+ public final void testUmweltAll(@ArquillianResource URL baseUrl) {
+ stammdatenTest.getAll(baseUrl, "umwelt", testProtocol);
+ }
+
+ @Test
+ @RunAsClient
+ public final void testUmweltById(@ArquillianResource URL baseUrl) {
+ stammdatenTest.getById(baseUrl, "umwelt", "L6", testProtocol);
+ }
+
+ @Test
+ @RunAsClient
+ public final void testVerwaltungseinheitAll(@ArquillianResource URL baseUrl) {
+ stammdatenTest.getAll(baseUrl, "verwaltungseinheit", testProtocol);
+ }
+
+ @Test
+ @RunAsClient
+ public final void testVerwaltungseinheitById(@ArquillianResource URL baseUrl) {
+ stammdatenTest.getById(baseUrl, "verwaltungseinheit", "09575134", testProtocol);
+ }
+
+ /* TODO: The location service is moved to the "land"-services in
+ future version. */
+ @Test
+ @Ignore
+ @RunAsClient
+ public final void testLocation1CreateService(@ArquillianResource URL baseUrl)
+ throws Exception {
+ System.out.print(".");
+ Protocol prot = new Protocol();
+ prot.setName("locationService");
+ prot.setType("create");
+ prot.setPassed(false);
+ testProtocol.add(prot);
+ try {
+ /* Create a client*/
+ Client client = ClientBuilder.newClient();
+ WebTarget target = client.target(baseUrl + "location");
+ /* Send a post request containing a new kommentar*/
+ String newObj = "{\"beschreibung\":\"Neuer Ort\"," +
+ "\"bezeichnung\":\"T123456\",\"hoeheLand\":null," +
+ "\"koordXExtern\":\"32531152\",\"koordYExtern\":\"5684269\"," +
+ "\"latitude\":51.30888,\"letzteAenderung\":1376287046332," +
+ "\"longitude\":9.44693,\"nutsCode\":\"DE731\",\"unscharf\":" +
+ "\"0\",\"netzbetreiberId\":null,\"staatId\":0," +
+ "\"verwaltungseinheitId\":\"06611000\",\"otyp\":\"Z\"," +
+ "\"koordinatenartId\":5}";
+
+ Response response = target.request()
+ .header("X-SHIB-user", BaseTest.TEST_USER)
+ .header("X-SHIB-roles", BaseTest.TEST_ROLES)
+ .post(Entity.entity(newObj, MediaType.APPLICATION_JSON));
+ String entity = response.readEntity(String.class);
+ /* Try to parse the response*/
+ JsonReader fromServiceReader =
+ Json.createReader(new StringReader(entity));
+ JsonObject content = fromServiceReader.readObject();
+ /* Save the id*/
+ createdOrtId =
+ content.getJsonObject("data").getJsonNumber("id").intValue();
+ prot.addInfo("ortId", createdOrtId);
+ /* Verify the response*/
+ Assert.assertTrue(content.getBoolean("success"));
+ prot.addInfo("success", content.getBoolean("success"));
+ Assert.assertEquals("200", content.getString("message"));
+ prot.addInfo("message", content.getString("message"));
+ }
+ catch(JsonException je) {
+ prot.addInfo("exception", je.getMessage());
+ Assert.fail(je.getMessage());
+ }
+ prot.setPassed(true);
+ }
+
+ /**
+ * Test the UPDATE Service.
+ *
+ * @param baseUrl The url pointing to the test deployment.
+ */
+ @Test
+ @Ignore
+ @RunAsClient
+ public final void testLocation2UpdateService(@ArquillianResource URL baseUrl)
+ throws Exception {
+ System.out.print(".");
+ Protocol prot = new Protocol();
+ prot.setName("locationService");
+ prot.setType("update");
+ prot.setPassed(false);
+ testProtocol.add(prot);
+ try {
+ /* Create a client*/
+ Client client = ClientBuilder.newClient();
+ WebTarget target =
+ client.target(baseUrl + "location/" + createdOrtId);
+ prot.addInfo("locationId", createdOrtId);
+ /* Request a kommentar with the id saved when created a kommentar*/
+ Response response = target.request()
+ .header("X-SHIB-user", BaseTest.TEST_USER)
+ .header("X-SHIB-roles", BaseTest.TEST_ROLES)
+ .get();
+ String entity = response.readEntity(String.class);
+ /* Try to parse the response*/
+ JsonReader reader = Json.createReader(new StringReader(entity));
+ JsonObject oldObj = reader.readObject().getJsonObject("data");
+ /* Change the text*/
+ String updatedEntity =
+ oldObj.toString().replace("Neuer Ort", "Neuerer Ort");
+ prot.addInfo("updated field", "beschreibung");
+ prot.addInfo("updated value", "Neuer Ort");
+ prot.addInfo("updated to", "Neuerer Ort");
+ /* Send the updated kommentar via put reauest*/
+ WebTarget putTarget = client.target(baseUrl + "location/" + createdOrtId);
+ Response updated = putTarget.request()
+ .header("X-SHIB-user", BaseTest.TEST_USER)
+ .header("X-SHIB-roles", BaseTest.TEST_ROLES)
+ .put(Entity.entity(updatedEntity, MediaType.APPLICATION_JSON));
+ /* Try to parse the response*/
+ JsonReader updatedReader = Json.createReader(
+ new StringReader(updated.readEntity(String.class)));
+ JsonObject updatedObj = updatedReader.readObject();
+ /* Verify the response*/
+ Assert.assertTrue(updatedObj.getBoolean("success"));
+ prot.addInfo("success", updatedObj.getBoolean("success"));
+ Assert.assertEquals("200", updatedObj.getString("message"));
+ prot.addInfo("message", updatedObj.getString("message"));
+ Assert.assertEquals("Neuerer Ort",
+ updatedObj.getJsonObject("data").getString("beschreibung"));
+ }
+ catch(JsonException je) {
+ prot.addInfo("exception", je.getMessage());
+ Assert.fail(je.getMessage());
+ }
+ prot.setPassed(true);
+ }
+
+ @Test
+ @Ignore
+ @RunAsClient
+ public final void testLocation3DeleteService(@ArquillianResource URL baseUrl)
+ throws Exception {
+ System.out.print(".");
+ Protocol prot = new Protocol();
+ prot.setName("locationService");
+ prot.setType("delete");
+ prot.setPassed(false);
+ testProtocol.add(prot);
+ try {
+ /* Create a client*/
+ Client client = ClientBuilder.newClient();
+ WebTarget target =
+ client.target(baseUrl + "location/" + createdOrtId);
+ prot.addInfo("locationId", createdOrtId);
+ /* Delete the object with the saved id*/
+ Response response = target.request()
+ .header("X-SHIB-user", BaseTest.TEST_USER)
+ .header("X-SHIB-roles", BaseTest.TEST_ROLES)
+ .delete();
+ String entity = response.readEntity(String.class);
+ /* Try to parse the response*/
+ JsonReader reader = Json.createReader(new StringReader(entity));
+ JsonObject respObj = reader.readObject();
+ /* Verify the response*/
+ Assert.assertTrue(respObj.getBoolean("success"));
+ prot.addInfo("success", respObj.getBoolean("success"));
+ Assert.assertEquals("200", respObj.getString("message"));
+ prot.addInfo("message", respObj.getString("message"));
+ }
+ catch(JsonException je) {
+ prot.addInfo("exception", je.getMessage());
+ Assert.fail(je.getMessage());
+ }
+ prot.setPassed(true);
+ }
+}
diff -r 3d76d476894f -r 59c51da59b30 src/test/java/de/intevation/lada/ValidatorTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/java/de/intevation/lada/ValidatorTest.java Fri Dec 18 18:01:00 2015 +0100
@@ -0,0 +1,256 @@
+package de.intevation.lada;
+
+import static de.intevation.lada.BaseTest.ARCHIVE_NAME;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.inject.Inject;
+
+import org.apache.log4j.Logger;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+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;
+
+ at RunWith(Arquillian.class)
+public class ValidatorTest {
+
+ private static Logger logger = Logger.getLogger(StammdatenTest.class);
+
+ protected static List<Protocol> testProtocol;
+
+ protected static boolean verboseLogging = false;
+
+ @Inject
+ @ValidationConfig(type="Probe")
+ private Validator probeValidator;
+ private Probe probeTest;
+
+ @Inject
+ @ValidationConfig(type="Messung")
+ private Validator messungValidator;
+ private Messung messungTest;
+
+ @Inject
+ @ValidationConfig(type="Status")
+ private Validator statusValidator;
+ private Status statusTest;
+
+
+ public ValidatorTest() {
+ probeTest = new Probe();
+ messungTest = new Messung();
+ statusTest = new Status();
+ testProtocol = new ArrayList<Protocol>();
+ }
+
+ /**
+ * Create a deployable WAR archive.
+ */
+ @Deployment(testable=true)
+ public static WebArchive createDeployment() throws Exception {
+ WebArchive archive = ShrinkWrap.create(WebArchive.class, ARCHIVE_NAME)
+ .addPackages(true, Package.getPackage("de.intevation.lada"))
+ .addAsResource("log4j.properties", "log4j.properties")
+ .addAsResource("shibboleth.properties", "shibboleth.properties")
+ .addAsResource("probequery.json", "probequery.json")
+ .addAsResource("messprogrammquery.json", "messprogrammquery.json")
+ .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
+ .addAsResource("META-INF/test-persistence.xml",
+ "META-INF/persistence.xml");
+ return archive;
+ }
+
+
+ @BeforeClass
+ public static void beforeTests() {
+ logger.info("---------- Testing Lada Validator ----------");
+ }
+
+ @After
+ public final void printLogs() {
+ for (Protocol p : testProtocol) {
+ logger.info(p.toString(verboseLogging));
+ }
+ }
+
+ @AfterClass
+ public static final void afterTests() {
+ System.out.println("");
+ }
+
+ @Test
+ public final void probeHasHauptprobenNr() {
+ probeTest.setValidator(probeValidator);
+ probeTest.hasHauptprobenNr(testProtocol);
+ }
+
+ @Test
+ public final void probeHasNoHauptprobenNr() {
+ probeTest.setValidator(probeValidator);
+ probeTest.hasNoHauptprobenNr(testProtocol);
+ }
+
+ @Test
+ public final void probeExistingHauptprobenNrNew() {
+ probeTest.setValidator(probeValidator);
+ probeTest.existingHauptprobenNrNew(testProtocol);
+ }
+
+ @Test
+ public final void probeUniqueHauptprobenNrNew() {
+ probeTest.setValidator(probeValidator);
+ probeTest.uniqueHauptprobenNrNew(testProtocol);
+ }
+
+ @Test
+ public final void probeExistingHauptprobenNrUpdate() {
+ probeTest.setValidator(probeValidator);
+ probeTest.existingHauptprobenNrUpdate(testProtocol);
+ }
+
+ @Test
+ public final void probeUniqueHauptprobenNrUpdate() {
+ probeTest.setValidator(probeValidator);
+ probeTest.uniqueHauptprobenNrUpdate(testProtocol);
+ }
+
+ @Test
+ public final void probeHasEntnahmeOrt() {
+ probeTest.setValidator(probeValidator);
+ probeTest.hasEntnahmeOrt(testProtocol);
+ }
+
+ @Test
+ public final void probeHasNoEntnahmeOrt() {
+ probeTest.setValidator(probeValidator);
+ probeTest.hasNoEntnahmeOrt(testProtocol);
+ }
+
+ @Test
+ public final void probeHasProbenahmeBegin() {
+ probeTest.setValidator(probeValidator);
+ probeTest.hasProbeentnahmeBegin(testProtocol);
+ }
+
+ @Test
+ public final void probeHasNoProbenahmeBegin() {
+ probeTest.setValidator(probeValidator);
+ probeTest.hasNoProbeentnahmeBegin(testProtocol);
+ }
+
+ @Test
+ public final void probeTimeNoEndProbenahmeBegin() {
+ probeTest.setValidator(probeValidator);
+ probeTest.timeNoEndProbeentnahmeBegin(testProtocol);
+ }
+
+ @Test
+ public final void probeTimeNoBeginProbenahmeBegin() {
+ probeTest.setValidator(probeValidator);
+ probeTest.timeNoBeginProbeentnahmeBegin(testProtocol);
+ }
+
+ @Test
+ public final void probeTimeBeginAfterEndProbenahmeBegin() {
+ probeTest.setValidator(probeValidator);
+ probeTest.timeBeginAfterEndProbeentnahmeBegin(testProtocol);
+ }
+
+ @Test
+ public final void probeTimeBeginFutureProbenahmeBegin() {
+ probeTest.setValidator(probeValidator);
+ probeTest.timeBeginFutureProbeentnahmeBegin(testProtocol);
+ }
+
+ @Test
+ public final void probeHasUmwelt() {
+ probeTest.setValidator(probeValidator);
+ probeTest.hasUmwelt(testProtocol);
+ }
+
+ @Test
+ public final void probeHasNoUmwelt() {
+ probeTest.setValidator(probeValidator);
+ probeTest.hasNoUmwelt(testProtocol);
+ }
+
+ @Test
+ public final void probeHasEmptyUmwelt() {
+ probeTest.setValidator(probeValidator);
+ probeTest.hasEmptyUmwelt(testProtocol);
+ }
+
+ @Test
+ public final void messungHasNebenprobenNr() {
+ messungTest.setValidator(messungValidator);
+ messungTest.hasNebenprobenNr(testProtocol);
+ }
+
+ @Test
+ public final void messungHasNoNebenprobenNr() {
+ messungTest.setValidator(messungValidator);
+ messungTest.hasNoNebenprobenNr(testProtocol);
+ }
+
+ @Test
+ public final void messungHasEmptyNebenprobenNr() {
+ messungTest.setValidator(messungValidator);
+ messungTest.hasEmptyNebenprobenNr(testProtocol);
+ }
+
+ @Test
+ public final void messungUniqueNebenprobenNrNew() {
+ messungTest.setValidator(messungValidator);
+ messungTest.uniqueNebenprobenNrNew(testProtocol);
+ }
+
+ @Test
+ public final void messungUniqueNebenprobenNrUpdate() {
+ messungTest.setValidator(messungValidator);
+ messungTest.uniqueNebenprobenNrUpdate(testProtocol);
+ }
+
+ @Test
+ public final void messungExistingNebenprobenNrNew() {
+ messungTest.setValidator(messungValidator);
+ messungTest.existingNebenprobenNrNew(testProtocol);
+ }
+
+ @Test
+ public final void messungExistingNebenprobenNrUpdate() {
+ messungTest.setValidator(messungValidator);
+ messungTest.existingHauptprobenNrUpdate(testProtocol);
+ }
+
+ @Test
+ public final void messungHasMesswert() {
+ messungTest.setValidator(messungValidator);
+ messungTest.hasMesswert(testProtocol);
+ }
+
+ @Test
+ public final void messungHasNoMesswert() {
+ messungTest.setValidator(messungValidator);
+ messungTest.hasNoMesswert(testProtocol);
+ }
+
+ @Test
+ public final void statusKombiNegative() {
+ statusTest.setValidator(statusValidator);
+ statusTest.checkKombiNegative(testProtocol);
+ }
+}
diff -r 3d76d476894f -r 59c51da59b30 src/test/java/de/intevation/lada/test/land/KommentarM.java
--- a/src/test/java/de/intevation/lada/test/land/KommentarM.java Fri Dec 18 17:55:20 2015 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,345 +0,0 @@
-/* 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.land;
-
-import java.io.StringReader;
-import java.net.URL;
-import java.sql.Date;
-import java.util.List;
-import java.util.TimeZone;
-
-import javax.json.Json;
-import javax.json.JsonException;
-import javax.json.JsonObject;
-import javax.json.JsonReader;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.junit.Assert;
-
-import de.intevation.lada.BaseTest;
-import de.intevation.lada.Protocol;
-
-
-/**
- * Class containing test cases for messung kommentar objects.
- *
- * @author <a href="mailto:rrenkert at intevation.de">Raimund Renkert</a>
- */
-public class KommentarM {
-
- private static final String COMPARE_KOMMENTARM =
- "{\"messungsId\":5,\"datum\":1336634700000,\"erzeuger\":\"12010\"," +
- "\"id\":478,\"text\":\"Hofladen Lenzen geschlossen\",\"owner\":false," +
- "\"readonly\":true}";
-
- private static final String CREATE_KOMMENTARM =
- "{\"messungsId\":\"MID\",\"erzeuger\":\"06010\",\"text\":" +
- "\"test\",\"datum\":\"2015-02-09T10:58:36\",\"owner\":false}";
-
- private List<Protocol> protocol;
-
- private static Integer createdKommentarId;
-
- /**
- * @return The test protocol
- */
- public List<Protocol> getProtocol() {
- return protocol;
- }
-
- /**
- * @return The created KommentarId
- */
- public Integer getCreatedKommentarId() {
- return createdKommentarId;
- }
-
- /**
- * Test the GET Service by requesting all objects.
- *
- * @param baseUrl The url pointing to the test deployment.
- */
- public final void getAllService(URL baseUrl, List<Protocol> protocol)
- throws Exception {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("MessungKommentarService");
- prot.setType("get all");
- prot.setPassed(false);
- protocol.add(prot);
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target = client.target(baseUrl + "mkommentar");
- /* Request all objects*/
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .get();
- String entity = response.readEntity(String.class);
- try{
- /* Try to parse the response*/
- JsonReader reader = Json.createReader(new StringReader(entity));
- JsonObject content = reader.readObject();
- /* Verify the response*/
- Assert.assertTrue(content.getBoolean("success"));
- prot.addInfo("success", content.getBoolean("success"));
- Assert.assertEquals("200", content.getString("message"));
- prot.addInfo("message", content.getString("message"));
- Assert.assertNotNull(content.getJsonArray("data"));
- prot.addInfo("objects", content.getJsonArray("data").size());
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-
- /**
- * Test the GET Service by requesting a single object by id.
- *
- * @param baseUrl The url pointing to the test deployment.
- */
- public final void getByIdService(URL baseUrl, List<Protocol> protocol)
- throws Exception {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("MessungKommentarService");
- prot.setType("get by Id");
- prot.setPassed(false);
- protocol.add(prot);
- try {
- /* Create a json object from static string*/
- JsonReader fromStringRreader =
- Json.createReader(new StringReader(COMPARE_KOMMENTARM));
- JsonObject staticKommentar = fromStringRreader.readObject();
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target = client.target(baseUrl + "mkommentar/478");
- prot.addInfo("kommentarId", 478);
- /* Request an object by id*/
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .get();
- String entity = response.readEntity(String.class);
- /* Try to parse the response*/
- JsonReader fromServiceReader =
- Json.createReader(new StringReader(entity));
- JsonObject content = fromServiceReader.readObject();
- /* Verify the response*/
- Assert.assertTrue(content.getBoolean("success"));
- prot.addInfo("success", content.getBoolean("success"));
- Assert.assertEquals("200", content.getString("message"));
- prot.addInfo("message", content.getString("message"));
- Assert.assertEquals(staticKommentar,
- content.getJsonObject("data"));
- prot.addInfo("object", "equals");
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-
- /**
- * Test the GET service using filters.
- *
- * @param baseUrl The url poining to the test deployment.
- */
- public final void filterService(URL baseUrl, List<Protocol> protocol) {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("MessungKommentarService");
- prot.setType("get by filter");
- prot.setPassed(false);
- protocol.add(prot);
- try {
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target =
- client.target(baseUrl + "mkommentar?messungId=988");
- prot.addInfo("filter", "messungId=988");
- /* Request the objects using the filter*/
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .get();
- String entity = response.readEntity(String.class);
- /* Try to parse the response*/
- JsonReader reader = Json.createReader(new StringReader(entity));
- JsonObject respObj = reader.readObject();
- /* Verify the response*/
- Assert.assertTrue(respObj.getBoolean("success"));
- prot.addInfo("success", respObj.getBoolean("success"));
- Assert.assertEquals("200", respObj.getString("message"));
- prot.addInfo("message", respObj.getString("message"));
- Assert.assertNotNull(respObj.getJsonArray("data"));
- prot.addInfo("objects", respObj.getJsonArray("data").size());
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-
- /**
- * Test the CREATE Service.
- *
- * @param baseUrl The url pointing to the test deployment.
- */
- public final void createService(
- URL baseUrl,
- List<Protocol> protocol,
- Integer messungId)
- throws Exception {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("MessungKommentarService");
- prot.setType("create");
- prot.setPassed(false);
- protocol.add(prot);
- try {
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target = client.target(baseUrl + "mkommentar");
- /* Send a post request containing a new kommentar*/
- String mess = CREATE_KOMMENTARM.replace("MID", messungId.toString());
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .post(
- Entity.entity(mess, MediaType.APPLICATION_JSON));
- String entity = response.readEntity(String.class);
- /* Try to parse the response*/
- JsonReader fromServiceReader =
- Json.createReader(new StringReader(entity));
- JsonObject content = fromServiceReader.readObject();
- /* Save the id*/
- createdKommentarId =
- content.getJsonObject("data").getJsonNumber("id").intValue();
- prot.addInfo("kommentarId", createdKommentarId);
- /* Verify the response*/
- Assert.assertTrue(content.getBoolean("success"));
- prot.addInfo("success", content.getBoolean("success"));
- Assert.assertEquals("200", content.getString("message"));
- prot.addInfo("message", content.getString("message"));
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-
- /**
- * Test the UPDATE Service.
- *
- * @param baseUrl The url pointing to the test deployment.
- */
- public final void updateService(URL baseUrl, List<Protocol> protocol)
- throws Exception {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("MessungKommentarService");
- prot.setType("update");
- prot.setPassed(false);
- protocol.add(prot);
- try {
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target =
- client.target(baseUrl + "mkommentar/" + createdKommentarId);
- prot.addInfo("kommentarId", createdKommentarId);
- /* Request a kommentar with the id saved when created a kommentar*/
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .get();
- String entity = response.readEntity(String.class);
- /* Try to parse the response*/
- JsonReader reader = Json.createReader(new StringReader(entity));
- JsonObject oldKommentar = reader.readObject().getJsonObject("data");
- /* Change the text*/
- String updatedEntity =
- oldKommentar.toString().replace("test", "neu");
- prot.addInfo("updated field", "text");
- prot.addInfo("updated value", "test");
- prot.addInfo("updated to", "neu");
- /* Send the updated kommentar via put reauest*/
- WebTarget putTarget = client.target(baseUrl + "mkommentar/" + createdKommentarId);
- Response updated = putTarget.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .put(Entity.entity(updatedEntity, MediaType.APPLICATION_JSON));
- /* Try to parse the response*/
- JsonReader updatedReader = Json.createReader(
- new StringReader(updated.readEntity(String.class)));
- JsonObject updatedMessung = updatedReader.readObject();
- /* Verify the response*/
- Assert.assertTrue(updatedMessung.getBoolean("success"));
- prot.addInfo("success", updatedMessung.getBoolean("success"));
- Assert.assertEquals("200", updatedMessung.getString("message"));
- prot.addInfo("message", updatedMessung.getString("message"));
- Assert.assertEquals("neu",
- updatedMessung.getJsonObject("data").getString("text"));
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-
- /**
- * Test the DELETE Service.
- *
- * @param baseUrl The url pointing to the test deployment.
- */
- public final void deleteService(URL baseUrl, List<Protocol> protocol) {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("MessungKommentarService");
- prot.setType("delete");
- prot.setPassed(false);
- protocol.add(prot);
- try {
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target =
- client.target(baseUrl + "mkommentar/" + createdKommentarId);
- prot.addInfo("kommentarId", createdKommentarId);
- /* Delete a kommentar with the saved id*/
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .delete();
- String entity = response.readEntity(String.class);
- /* Try to parse the response*/
- JsonReader reader = Json.createReader(new StringReader(entity));
- JsonObject respObj = reader.readObject();
- /* Verify the response*/
- Assert.assertTrue(respObj.getBoolean("success"));
- prot.addInfo("success", respObj.getBoolean("success"));
- Assert.assertEquals("200", respObj.getString("message"));
- prot.addInfo("message", respObj.getString("message"));
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-}
diff -r 3d76d476894f -r 59c51da59b30 src/test/java/de/intevation/lada/test/land/KommentarMTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/java/de/intevation/lada/test/land/KommentarMTest.java Fri Dec 18 18:01:00 2015 +0100
@@ -0,0 +1,62 @@
+package de.intevation.lada.test.land;
+
+import java.net.URL;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.json.JsonObject;
+import javax.json.JsonObjectBuilder;
+import javax.json.JsonValue;
+
+import org.junit.Assert;
+
+import de.intevation.lada.Protocol;
+
+public class KommentarMTest extends ServiceTest {
+
+ private JsonObject expectedById;
+ private JsonObject create;
+
+ /**
+ * @return The test protocol
+ */
+ public List<Protocol> getProtocol() {
+ return protocol;
+ }
+
+ @Override
+ public void init(
+ URL baseUrl,
+ List<Protocol> protocol
+ ) {
+ super.init(baseUrl, protocol);
+ // Attributes with timestamps
+ timestampAttributes = Arrays.asList(new String[]{
+ "datum",
+ "treeModified"
+ });
+
+ // Prepare expected probe object
+ JsonObject content = readJsonResource("/datasets/dbUnit_mkommentar.json");
+ JsonObject messung = content.getJsonArray("land.kommentar_m").getJsonObject(0);
+ JsonObjectBuilder builder = convertObject(messung);
+ builder.add("parentModified", 1450371851654L);
+ builder.add("readonly", JsonValue.FALSE);
+ builder.add("owner", JsonValue.TRUE);
+ expectedById = builder.build();
+ Assert.assertNotNull(expectedById);
+
+ // Load probe object to test POST request
+ create = readJsonResource("/datasets/mkommentar.json");
+ Assert.assertNotNull(create);
+ }
+
+ public final void execute() {
+ getAll("mkommentar", "rest/mkommentar?messungsId=1000");
+ getById("mkommentar", "rest/mkommentar/1000", expectedById);
+ JsonObject created = create("mkommentar", "rest/mkommentar", create);
+ update("mkommentar", "rest/mkommentar/1000", "text", "Testkommentar", "Testkommentar geändert");
+ delete("mkommentar", "rest/mkommentar/" + created.getJsonObject("data").get("id"));
+ }
+
+}
diff -r 3d76d476894f -r 59c51da59b30 src/test/java/de/intevation/lada/test/land/KommentarP.java
--- a/src/test/java/de/intevation/lada/test/land/KommentarP.java Fri Dec 18 17:55:20 2015 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,343 +0,0 @@
-/* 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.land;
-
-import java.io.StringReader;
-import java.net.URL;
-import java.util.List;
-
-import javax.json.Json;
-import javax.json.JsonException;
-import javax.json.JsonObject;
-import javax.json.JsonReader;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.junit.Assert;
-
-import de.intevation.lada.BaseTest;
-import de.intevation.lada.Protocol;
-
-
-/**
- * Class containing test cases for probekommentar objects.
- *
- * @author <a href="mailto:rrenkert at intevation.de">Raimund Renkert</a>
- */
-public class KommentarP {
-
- private static final String COMPARE_KOMMENTARP =
- "{\"datum\":1321005677000,\"erzeuger\":\"06010\",\"id\":1,\"text\":" +
- "\"Die Probe wurde in Darmstadt gammaspektrometrisch gemessen und " +
- "für die Sr-Bestimmung verascht. \",\"probeId\":361,\"owner\":true," +
- "\"readonly\":false}";
-
- private static final String CREATE_KOMMENTARP =
- "{\"probeId\":\"PID\",\"erzeuger\":\"11010\",\"text\":" +
- "\"test\",\"datum\":\"2015-02-09T10:58:36\"}";
-
- private List<Protocol> protocol;
-
- private static Integer createdKommentarId;
-
- /**
- * @return The test protocol
- */
- public List<Protocol> getProtocol() {
- return protocol;
- }
-
- /**
- * @return The created KommentarId
- */
- public Integer getCreatedKommentarId() {
- return createdKommentarId;
- }
-
- /**
- * Test the GET Service by requesting all objects.
- *
- * @param baseUrl The url pointing to the test deployment.
- */
- public final void getAllService(URL baseUrl, List<Protocol> protocol)
- throws Exception {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("ProbeKommentarService");
- prot.setType("get all");
- prot.setPassed(false);
- protocol.add(prot);
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target = client.target(baseUrl + "pkommentar");
- /* Request all objects*/
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .get();
- String entity = response.readEntity(String.class);
- try{
- /* Try to parse the response*/
- JsonReader reader = Json.createReader(new StringReader(entity));
- JsonObject content = reader.readObject();
- /* Verify the response*/
- Assert.assertTrue(content.getBoolean("success"));
- prot.addInfo("success", content.getBoolean("success"));
- Assert.assertEquals("200", content.getString("message"));
- prot.addInfo("message", content.getString("message"));
- Assert.assertNotNull(content.getJsonArray("data"));
- prot.addInfo("objects", content.getJsonArray("data").size());
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-
- /**
- * Test the GET Service by requesting a single object by id.
- *
- * @param baseUrl The url pointing to the test deployment.
- */
- public final void getByIdService(URL baseUrl, List<Protocol> protocol)
- throws Exception {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("ProbeKommentarService");
- prot.setType("get by Id");
- prot.setPassed(false);
- protocol.add(prot);
- try {
- /* Create a json object from static string*/
- JsonReader fromStringRreader =
- Json.createReader(new StringReader(COMPARE_KOMMENTARP));
- JsonObject staticKommentar = fromStringRreader.readObject();
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target = client.target(baseUrl + "pkommentar/1");
- prot.addInfo("kommentarId", 1);
- /* Request an object by id*/
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .get();
- String entity = response.readEntity(String.class);
- /* Try to parse the response*/
- JsonReader fromServiceReader =
- Json.createReader(new StringReader(entity));
- JsonObject content = fromServiceReader.readObject();
- /* Verify the response*/
- Assert.assertTrue(content.getBoolean("success"));
- prot.addInfo("success", content.getBoolean("success"));
- Assert.assertEquals("200", content.getString("message"));
- prot.addInfo("message", content.getString("message"));
- Assert.assertEquals(staticKommentar,
- content.getJsonObject("data"));
- prot.addInfo("object", "equals");
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-
- /**
- * Test the GET service using filters.
- *
- * @param baseUrl The url poining to the test deployment.
- */
- public final void filterService(URL baseUrl, List<Protocol> protocol) {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("ProbeKommentarService");
- prot.setType("get by filter");
- prot.setPassed(false);
- protocol.add(prot);
- try {
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target =
- client.target(baseUrl + "pkommentar?probeId=400");
- prot.addInfo("filter", "probeId=400");
- /* Request the objects using the filter*/
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .get();
- String entity = response.readEntity(String.class);
- /* Try to parse the response*/
- JsonReader reader = Json.createReader(new StringReader(entity));
- JsonObject respObj = reader.readObject();
- /* Verify the response*/
- Assert.assertTrue(respObj.getBoolean("success"));
- prot.addInfo("success", respObj.getBoolean("success"));
- Assert.assertEquals("200", respObj.getString("message"));
- prot.addInfo("message", respObj.getString("message"));
- Assert.assertNotNull(respObj.getJsonArray("data"));
- prot.addInfo("objects", respObj.getJsonArray("data").size());
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-
- /**
- * Test the CREATE Service.
- *
- * @param baseUrl The url pointing to the test deployment.
- */
- public final void createService(
- URL baseUrl,
- List<Protocol> protocol,
- Integer probeId)
- throws Exception {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("ProbeKommentarService");
- prot.setType("create");
- prot.setPassed(false);
- protocol.add(prot);
- try {
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target = client.target(baseUrl + "pkommentar");
- /* Send a post request containing a new kommentar*/
- String mess = CREATE_KOMMENTARP.replace("PID", probeId.toString());
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .post(Entity.entity(mess, MediaType.APPLICATION_JSON));
- String entity = response.readEntity(String.class);
- /* Try to parse the response*/
- JsonReader fromServiceReader =
- Json.createReader(new StringReader(entity));
- JsonObject content = fromServiceReader.readObject();
- /* Save the id*/
- createdKommentarId =
- content.getJsonObject("data").getJsonNumber("id").intValue();
- prot.addInfo("kommentarId", createdKommentarId);
- /* Verify the response*/
- Assert.assertTrue(content.getBoolean("success"));
- prot.addInfo("success", content.getBoolean("success"));
- Assert.assertEquals("200", content.getString("message"));
- prot.addInfo("message", content.getString("message"));
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-
- /**
- * Test the UPDATE Service.
- *
- * @param baseUrl The url pointing to the test deployment.
- */
- public final void updateService(URL baseUrl, List<Protocol> protocol)
- throws Exception {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("ProbeKommentarService");
- prot.setType("update");
- prot.setPassed(false);
- protocol.add(prot);
- try {
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target =
- client.target(baseUrl + "pkommentar/" + createdKommentarId);
- prot.addInfo("kommentarId", createdKommentarId);
- /* Request a kommentar with the id saved when created a kommentar*/
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .get();
- String entity = response.readEntity(String.class);
- /* Try to parse the response*/
- JsonReader reader = Json.createReader(new StringReader(entity));
- JsonObject oldKommentar = reader.readObject().getJsonObject("data");
- /* Change the text*/
- String updatedEntity =
- oldKommentar.toString().replace("test", "neu");
- prot.addInfo("updated field", "text");
- prot.addInfo("updated value", "test");
- prot.addInfo("updated to", "neu");
- /* Send the updated kommentar via put reauest*/
- WebTarget putTarget = client.target(baseUrl + "pkommentar/" + createdKommentarId);
- Response updated = putTarget.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .put(Entity.entity(updatedEntity, MediaType.APPLICATION_JSON));
- /* Try to parse the response*/
- JsonReader updatedReader = Json.createReader(
- new StringReader(updated.readEntity(String.class)));
- JsonObject updatedMessung = updatedReader.readObject();
- /* Verify the response*/
- Assert.assertTrue(updatedMessung.getBoolean("success"));
- prot.addInfo("success", updatedMessung.getBoolean("success"));
- Assert.assertEquals("200", updatedMessung.getString("message"));
- prot.addInfo("message", updatedMessung.getString("message"));
- Assert.assertEquals("neu",
- updatedMessung.getJsonObject("data").getString("text"));
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-
- /**
- * Test the DELETE Service.
- *
- * @param baseUrl The url pointing to the test deployment.
- */
- public final void deleteService(URL baseUrl, List<Protocol> protocol) {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("ProbeKommentarService");
- prot.setType("delete");
- prot.setPassed(false);
- protocol.add(prot);
- try {
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target =
- client.target(baseUrl + "pkommentar/" + createdKommentarId);
- prot.addInfo("kommentarId", createdKommentarId);
- /* Delete a kommentar with the saved id*/
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .delete();
- String entity = response.readEntity(String.class);
- /* Try to parse the response*/
- JsonReader reader = Json.createReader(new StringReader(entity));
- JsonObject respObj = reader.readObject();
- /* Verify the response*/
- Assert.assertTrue(respObj.getBoolean("success"));
- prot.addInfo("success", respObj.getBoolean("success"));
- Assert.assertEquals("200", respObj.getString("message"));
- prot.addInfo("message", respObj.getString("message"));
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-}
diff -r 3d76d476894f -r 59c51da59b30 src/test/java/de/intevation/lada/test/land/KommentarPTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/java/de/intevation/lada/test/land/KommentarPTest.java Fri Dec 18 18:01:00 2015 +0100
@@ -0,0 +1,61 @@
+package de.intevation.lada.test.land;
+
+import java.net.URL;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.json.JsonObject;
+import javax.json.JsonObjectBuilder;
+import javax.json.JsonValue;
+
+import org.junit.Assert;
+
+import de.intevation.lada.Protocol;
+
+public class KommentarPTest extends ServiceTest {
+
+ private JsonObject expectedById;
+ private JsonObject create;
+
+ /**
+ * @return The test protocol
+ */
+ public List<Protocol> getProtocol() {
+ return protocol;
+ }
+
+ @Override
+ public void init(
+ URL baseUrl,
+ List<Protocol> protocol
+ ) {
+ super.init(baseUrl, protocol);
+ // Attributes with timestamps
+ timestampAttributes = Arrays.asList(new String[]{
+ "datum",
+ "treeModified"
+ });
+
+ // Prepare expected probe object
+ JsonObject content = readJsonResource("/datasets/dbUnit_pkommentar.json");
+ JsonObject messung = content.getJsonArray("land.kommentar_p").getJsonObject(0);
+ JsonObjectBuilder builder = convertObject(messung);
+ builder.add("parentModified", 1450371851654L);
+ builder.add("readonly", JsonValue.FALSE);
+ builder.add("owner", JsonValue.TRUE);
+ expectedById = builder.build();
+ Assert.assertNotNull(expectedById);
+
+ // Load probe object to test POST request
+ create = readJsonResource("/datasets/pkommentar.json");
+ Assert.assertNotNull(create);
+ }
+
+ public final void execute() {
+ getAll("pkommentar", "rest/pkommentar?probeId=1000");
+ getById("pkommentar", "rest/pkommentar/1000", expectedById);
+ JsonObject created = create("pkommentar", "rest/pkommentar", create);
+ update("pkommentar", "rest/pkommentar/1000", "text", "Testkommentar", "Testkommentar geändert");
+ delete("pkommentar", "rest/pkommentar/" + created.getJsonObject("data").get("id"));
+ }
+}
diff -r 3d76d476894f -r 59c51da59b30 src/test/java/de/intevation/lada/test/land/MessprogrammTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/java/de/intevation/lada/test/land/MessprogrammTest.java Fri Dec 18 18:01:00 2015 +0100
@@ -0,0 +1,65 @@
+package de.intevation.lada.test.land;
+
+import java.net.URL;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.json.JsonObject;
+import javax.json.JsonObjectBuilder;
+import javax.json.JsonValue;
+
+import org.junit.Assert;
+
+import de.intevation.lada.Protocol;
+
+public class MessprogrammTest extends ServiceTest {
+ private JsonObject expectedById;
+ private JsonObject create;
+
+ /**
+ * @return The test protocol
+ */
+ public List<Protocol> getProtocol() {
+ return protocol;
+ }
+
+ @Override
+ public void init(
+ URL baseUrl,
+ List<Protocol> protocol
+ ) {
+ super.init(baseUrl, protocol);
+ // Attributes with timestamps
+ timestampAttributes = Arrays.asList(new String[]{
+ "letzteAenderung",
+ "treeModified"
+ });
+
+ // Prepare expected object
+ JsonObject content = readJsonResource("/datasets/dbUnit_messprogramm.json");
+ JsonObject messprogramm = content.getJsonArray("land.messprogramm").getJsonObject(0);
+ JsonObjectBuilder builder = convertObject(messprogramm);
+ builder.add("baId", JsonValue.NULL);
+ builder.add("gueltigVon", JsonValue.NULL);
+ builder.add("gueltigBis", JsonValue.NULL);
+ builder.add("intervallOffset", JsonValue.NULL);
+ builder.add("ortId", JsonValue.NULL);
+ builder.add("probeKommentar", JsonValue.NULL);
+ builder.add("probeNehmerId", JsonValue.NULL);
+ expectedById = builder.build();
+ Assert.assertNotNull(expectedById);
+
+ // Load object to test POST request
+ create = readJsonResource("/datasets/messprogramm.json");
+ Assert.assertNotNull(create);
+ }
+
+ public final void execute() {
+ getAll("messprogramm", "rest/messprogramm");
+ getById("messprogramm", "rest/messprogramm/1000", expectedById);
+ filter("messprogramm", "rest/messprogramm?qid=1");
+ update("messprogramm", "rest/messprogramm/1000", "mediaDesk", "D: 50 90 01 06 02 05 00 00 00 00 00 00", "D: 50 90 01 06 02 05 00 00 00 00 00 01");
+ JsonObject created = create("messprogramm", "rest/messprogramm", create);
+ delete("messprogramm", "rest/messprogramm/" + created.getJsonObject("data").get("id"));
+ }
+}
diff -r 3d76d476894f -r 59c51da59b30 src/test/java/de/intevation/lada/test/land/Messung.java
--- a/src/test/java/de/intevation/lada/test/land/Messung.java Fri Dec 18 17:55:20 2015 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,335 +0,0 @@
-/* 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.land;
-
-import java.io.StringReader;
-import java.net.URL;
-import java.util.List;
-
-import javax.json.Json;
-import javax.json.JsonException;
-import javax.json.JsonObject;
-import javax.json.JsonReader;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.junit.Assert;
-
-import de.intevation.lada.BaseTest;
-import de.intevation.lada.Protocol;
-
-/**
- * Class containing test cases for messung objects.
- *
- * @author <a href="mailto:rrenkert at intevation.de">Raimund Renkert</a>
- */
-public class Messung {
-
- private static final String COMPARE_MESSUNG =
- "{\"id\":1,\"fertig\":true,\"letzteAenderung\":1331536340000," +
- "\"messdauer\":73929,\"messzeitpunkt\":1329139620000,\"mmtId\":" +
- "\"G1\",\"probeId\":575,\"owner\":false,\"readonly\":false," +
- "\"nebenprobenNr\":\"01G1\",\"geplant\":true,";
-
- private static final String CREATE_MESSUNG =
- "{\"probeId\":\"PID\",\"mmtId\":\"A4\",\"nebenprobenNr\":\"10R1\"," +
- "\"messdauer\":10,\"fertig\":false,\"letzteAenderung\":null," +
- "\"geplant\":true,\"messzeitpunkt\":\"2015-02-09T10:58:36\"}";
-
- private List<Protocol> protocol;
-
- private static Integer createdMessungId;
-
- public Integer getCreatedMessungId() {
- return createdMessungId;
- }
-
- /**
- * @return The test protocol
- */
- public List<Protocol> getProtocol() {
- return protocol;
- }
-
- /**
- * Test the GET Service by requesting all objects.
- *
- * @param baseUrl The url pointing to the test deployment.
- */
- public final void getAllService(URL baseUrl, List<Protocol> protocol)
- throws Exception {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("MessungService");
- prot.setType("get all");
- prot.setPassed(false);
- protocol.add(prot);
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target = client.target(baseUrl + "messung");
- /* Request all objects*/
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .get();
- String entity = response.readEntity(String.class);
- try{
- /* Try to parse the response*/
- JsonReader reader = Json.createReader(new StringReader(entity));
- JsonObject content = reader.readObject();
- /* Verify the response*/
- Assert.assertTrue(content.getBoolean("success"));
- prot.addInfo("success", content.getBoolean("success"));
- Assert.assertEquals("200", content.getString("message"));
- prot.addInfo("message", content.getString("message"));
- Assert.assertNotNull(content.getJsonArray("data"));
- prot.addInfo("objects", content.getJsonArray("data").size());
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-
- /**
- * Test the GET Service by requesting a single object by id.
- *
- * @param baseUrl The url pointing to the test deployment.
- */
- public final void getByIdService(URL baseUrl, List<Protocol> protocol)
- throws Exception {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("MessungService");
- prot.setType("get by Id");
- prot.setPassed(false);
- protocol.add(prot);
- try {
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target = client.target(baseUrl + "messung/1");
- prot.addInfo("messungId", 1);
- /* Request a object by id*/
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .get();
- String entity = response.readEntity(String.class);
- /* Try to parse the response*/
- JsonReader fromServiceReader =
- Json.createReader(new StringReader(entity));
- JsonObject content = fromServiceReader.readObject();
- /* Verify the response*/
- Assert.assertTrue(content.getBoolean("success"));
- prot.addInfo("success", content.getBoolean("success"));
- Assert.assertEquals("200", content.getString("message"));
- prot.addInfo("message", content.getString("message"));
- Assert.assertFalse(content.getJsonObject("data").isEmpty());
- prot.addInfo("object", "equals");
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-
- /**
- * Test the GET service using filters.
- *
- * @param baseUrl The url poining to the test deployment.
- */
- public final void filterService(URL baseUrl, List<Protocol> protocol) {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("MessungService");
- prot.setType("get by filter");
- prot.setPassed(false);
- protocol.add(prot);
- try {
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target =
- client.target(baseUrl + "messung?probeId=1");
- prot.addInfo("filter", "probeId=1");
- /* Request the objects using the filter*/
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .get();
- String entity = response.readEntity(String.class);
- /* Try to parse the response*/
- JsonReader reader = Json.createReader(new StringReader(entity));
- JsonObject respObj = reader.readObject();
- /* Verify the response*/
- Assert.assertTrue(respObj.getBoolean("success"));
- prot.addInfo("success", respObj.getBoolean("success"));
- Assert.assertEquals("200", respObj.getString("message"));
- prot.addInfo("message", respObj.getString("message"));
- Assert.assertNotNull(respObj.getJsonArray("data"));
- prot.addInfo("objects", respObj.getJsonArray("data").size());
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-
- /**
- * Test the CREATE Service.
- *
- * @param baseUrl The url pointing to the test deployment.
- */
- public final void createService(
- URL baseUrl,
- List<Protocol> protocol,
- Integer probeId)
- throws Exception {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("MessungService");
- prot.setType("create");
- prot.setPassed(false);
- protocol.add(prot);
- try {
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target = client.target(baseUrl + "messung");
- /* Send a post request containing a new object*/
- String mess = CREATE_MESSUNG.replace("PID", probeId.toString());
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .post(Entity.entity(mess, MediaType.APPLICATION_JSON));
- String entity = response.readEntity(String.class);
- /* Try to parse the response*/
- JsonReader fromServiceReader =
- Json.createReader(new StringReader(entity));
- JsonObject content = fromServiceReader.readObject();
- /* Save the id*/
- createdMessungId =
- content.getJsonObject("data").getJsonNumber("id").intValue();
- prot.addInfo("messungId", createdMessungId);
- /* Verify the response*/
- Assert.assertTrue(content.getBoolean("success"));
- prot.addInfo("success", content.getBoolean("success"));
- Assert.assertEquals("200", content.getString("message"));
- prot.addInfo("message", content.getString("message"));
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-
- /**
- * Test the UPDATE Service.
- *
- * @param baseUrl The url pointing to the test deployment.
- */
- public final void updateService(URL baseUrl, List<Protocol> protocol)
- throws Exception {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("MessungService");
- prot.setType("update");
- prot.setPassed(false);
- protocol.add(prot);
- try {
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target =
- client.target(baseUrl + "messung/" + createdMessungId);
- prot.addInfo("messungsId", createdMessungId);
- /* Request a messung with the saved id*/
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .get();
- String entity = response.readEntity(String.class);
- /* Try to parse the response*/
- JsonReader reader = Json.createReader(new StringReader(entity));
- JsonObject oldMessung = reader.readObject().getJsonObject("data");
- /* Change the mmtId*/
- String updatedEntity =
- oldMessung.toString().replace("A4", "G1");
- prot.addInfo("updated field", "mmtId");
- prot.addInfo("updated value", "A4");
- prot.addInfo("updated to", "G1");
- /* Send the updated messung via put request*/
- WebTarget putTarget = client.target(baseUrl + "messung/" + createdMessungId);
- Response updated = putTarget.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .put(Entity.entity(updatedEntity, MediaType.APPLICATION_JSON));
- /* Try to parse the response*/
- JsonReader updatedReader = Json.createReader(
- new StringReader(updated.readEntity(String.class)));
- JsonObject updatedMessung = updatedReader.readObject();
- /* Verify the response*/
- Assert.assertTrue(updatedMessung.getBoolean("success"));
- prot.addInfo("success", updatedMessung.getBoolean("success"));
- Assert.assertEquals("200", updatedMessung.getString("message"));
- prot.addInfo("message", updatedMessung.getString("message"));
- Assert.assertEquals("G1",
- updatedMessung.getJsonObject("data").getString("mmtId"));
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-
- /**
- * Test the DELETE Service.
- *
- * @param baseUrl The url pointing to the test deployment.
- */
- public final void deleteService(URL baseUrl, List<Protocol> protocol) {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("MessungService");
- prot.setType("delete");
- prot.setPassed(false);
- protocol.add(prot);
- try {
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target =
- client.target(baseUrl + "messung/" + createdMessungId);
- prot.addInfo("messungId", createdMessungId);
- /* Delete a messung with the saved id*/
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .delete();
- String entity = response.readEntity(String.class);
- /* Try to parse the response*/
- JsonReader reader = Json.createReader(new StringReader(entity));
- JsonObject respObj = reader.readObject();
- /* Verify the response*/
- Assert.assertTrue(respObj.getBoolean("success"));
- prot.addInfo("success", respObj.getBoolean("success"));
- Assert.assertEquals("200", respObj.getString("message"));
- prot.addInfo("message", respObj.getString("message"));
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-}
diff -r 3d76d476894f -r 59c51da59b30 src/test/java/de/intevation/lada/test/land/MessungTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/java/de/intevation/lada/test/land/MessungTest.java Fri Dec 18 18:01:00 2015 +0100
@@ -0,0 +1,67 @@
+package de.intevation.lada.test.land;
+
+import java.net.URL;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.json.JsonObject;
+import javax.json.JsonObjectBuilder;
+import javax.json.JsonValue;
+
+import org.junit.Assert;
+
+import de.intevation.lada.Protocol;
+
+public class MessungTest extends ServiceTest {
+
+ private JsonObject expectedById;
+ private JsonObject create;
+
+ /**
+ * @return The test protocol
+ */
+ public List<Protocol> getProtocol() {
+ return protocol;
+ }
+
+ @Override
+ public void init(
+ URL baseUrl,
+ List<Protocol> protocol
+ ) {
+ super.init(baseUrl, protocol);
+ // Attributes with timestamps
+ timestampAttributes = Arrays.asList(new String[]{
+ "letzteAenderung",
+ "messzeitpunkt",
+ "treeModified"
+ });
+
+ // Prepare expected probe object
+ JsonObject content = readJsonResource("/datasets/dbUnit_messung.json");
+ JsonObject messung = content.getJsonArray("land.messung").getJsonObject(0);
+ JsonObjectBuilder builder = convertObject(messung);
+ JsonObject trans =
+ content.getJsonArray("land.messung_translation").getJsonObject(0);
+ builder.add("messungsIdAlt", trans.get("messungs_id_alt"));
+ builder.add("parentModified", 1450371851654L);
+ builder.add("readonly", JsonValue.FALSE);
+ builder.add("owner", JsonValue.TRUE);
+ builder.add("statusEdit", JsonValue.TRUE);
+ builder.add("status", 1000);
+ expectedById = builder.build();
+ Assert.assertNotNull(expectedById);
+
+ // Load probe object to test POST request
+ create = readJsonResource("/datasets/messung.json");
+ Assert.assertNotNull(create);
+ }
+
+ public final void execute() {
+ getAll("messung", "rest/messung");
+ getById("messung", "rest/messung/1200", expectedById);
+ JsonObject created = create("messung", "rest/messung", create);
+ update("messung", "rest/messung/1200", "nebenprobenNr", "T100", "U200");
+ delete("messung", "rest/messung/" + created.getJsonObject("data").get("id"));
+ }
+}
diff -r 3d76d476894f -r 59c51da59b30 src/test/java/de/intevation/lada/test/land/Messwert.java
--- a/src/test/java/de/intevation/lada/test/land/Messwert.java Fri Dec 18 17:55:20 2015 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,337 +0,0 @@
-/* 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.land;
-
-import java.io.StringReader;
-import java.net.URL;
-import java.util.List;
-
-import javax.json.Json;
-import javax.json.JsonException;
-import javax.json.JsonObject;
-import javax.json.JsonReader;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.junit.Assert;
-
-import de.intevation.lada.BaseTest;
-import de.intevation.lada.Protocol;
-
-/**
- * Class containing test cases for messwert objects.
- *
- * @author <a href="mailto:rrenkert at intevation.de">Raimund Renkert</a>
- */
-public class Messwert {
-
- private static final String COMPARE_MESSWERT =
- "{\"id\":1,\"grenzwertueberschreitung\":null,\"letzteAenderung\":" +
- "1327305368000,\"mehId\":69,\"messfehler\":1.1,\"messgroesseId\":28," +
- "\"messungsId\":749,\"messwert\":97.0,\"messwertNwg\":null," +
- "\"nwgZuMesswert\":null,\"owner\":false,\"readonly\":false," +
- "\"treeModified\":null,\"parentModified\":null}";
-
- private static final String CREATE_MESSWERT =
- "{\"messungsId\":MID,\"messgroesseId\":242,\"messwert\":1," +
- "\"messwertNwg\":\"\",\"messfehler\":1,\"nwgZuMesswert\":3," +
- "\"mehId\":207,\"grenzwertueberschreitung\":false," +
- "\"letzteAenderung\":null}";
-
- private List<Protocol> protocol;
-
- private static Integer createdMesswertId;
-
- public Integer getCreatedMesswertId() {
- return createdMesswertId;
- }
-
- /**
- * @return The test protocol
- */
- public List<Protocol> getProtocol() {
- return protocol;
- }
-
- /**
- * Test the GET Service by requesting all objects.
- *
- * @param baseUrl The url pointing to the test deployment.
- */
- public final void getAllService(URL baseUrl, List<Protocol> protocol)
- throws Exception {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("MesswertService");
- prot.setType("get all");
- prot.setPassed(false);
- protocol.add(prot);
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target = client.target(baseUrl + "messwert");
- /* Request all objects*/
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .get();
- String entity = response.readEntity(String.class);
- try{
- /* Try to parse the response*/
- JsonReader reader = Json.createReader(new StringReader(entity));
- JsonObject content = reader.readObject();
- /* Verify the response*/
- Assert.assertTrue(content.getBoolean("success"));
- prot.addInfo("success", content.getBoolean("success"));
- Assert.assertEquals("200", content.getString("message"));
- prot.addInfo("message", content.getString("message"));
- Assert.assertNotNull(content.getJsonArray("data"));
- prot.addInfo("objects", content.getJsonArray("data").size());
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-
- /**
- * Test the GET Service by requesting a single object by id.
- *
- * @param baseUrl The url pointing to the test deployment.
- */
- public final void getByIdService(URL baseUrl, List<Protocol> protocol)
- throws Exception {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("MesswertService");
- prot.setType("get by Id");
- prot.setPassed(false);
- protocol.add(prot);
- try {
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target = client.target(baseUrl + "messwert/1");
- prot.addInfo("messwertId", 1);
- /* Request a object by id*/
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .get();
- String entity = response.readEntity(String.class);
- /* Try to parse the response*/
- JsonReader fromServiceReader =
- Json.createReader(new StringReader(entity));
- JsonObject content = fromServiceReader.readObject();
- /* Verify the response*/
- Assert.assertTrue(content.getBoolean("success"));
- prot.addInfo("success", content.getBoolean("success"));
- Assert.assertEquals("200", content.getString("message"));
- prot.addInfo("message", content.getString("message"));
- Assert.assertFalse(content.getJsonObject("data").isEmpty());
- prot.addInfo("object", "equals");
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-
- /**
- * Test the GET service using filters.
- *
- * @param baseUrl The url poining to the test deployment.
- */
- public final void filterService(URL baseUrl, List<Protocol> protocol) {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("MesswertService");
- prot.setType("get by filter");
- prot.setPassed(false);
- protocol.add(prot);
- try {
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target =
- client.target(baseUrl + "messwert?messungId=1");
- prot.addInfo("filter", "messungId=1");
- /* Request the objects using the filter*/
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .get();
- String entity = response.readEntity(String.class);
- /* Try to parse the response*/
- JsonReader reader = Json.createReader(new StringReader(entity));
- JsonObject respObj = reader.readObject();
- /* Verify the response*/
- Assert.assertTrue(respObj.getBoolean("success"));
- prot.addInfo("success", respObj.getBoolean("success"));
- Assert.assertEquals("200", respObj.getString("message"));
- prot.addInfo("message", respObj.getString("message"));
- Assert.assertNotNull(respObj.getJsonArray("data"));
- prot.addInfo("objects", respObj.getJsonArray("data").size());
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-
- /**
- * Test the CREATE Service.
- *
- * @param baseUrl The url pointing to the test deployment.
- */
- public final void createService(
- URL baseUrl,
- List<Protocol> protocol,
- Integer messungId)
- throws Exception {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("MesswertService");
- prot.setType("create");
- prot.setPassed(false);
- protocol.add(prot);
- try {
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target = client.target(baseUrl + "messwert");
- /* Send a post request containing a new object*/
- String mess = CREATE_MESSWERT.replace("MID", messungId.toString());
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .post(Entity.entity(mess, MediaType.APPLICATION_JSON));
- String entity = response.readEntity(String.class);
- /* Try to parse the response*/
- JsonReader fromServiceReader =
- Json.createReader(new StringReader(entity));
- JsonObject content = fromServiceReader.readObject();
- /* Save the id*/
- createdMesswertId =
- content.getJsonObject("data").getJsonNumber("id").intValue();
- prot.addInfo("messwertId", createdMesswertId);
- /* Verify the response*/
- Assert.assertTrue(content.getBoolean("success"));
- prot.addInfo("success", content.getBoolean("success"));
- Assert.assertEquals("200", content.getString("message"));
- prot.addInfo("message", content.getString("message"));
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-
- /**
- * Test the UPDATE Service.
- *
- * @param baseUrl The url pointing to the test deployment.
- */
- public final void updateService(URL baseUrl, List<Protocol> protocol)
- throws Exception {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("MesswertService");
- prot.setType("update");
- prot.setPassed(false);
- protocol.add(prot);
- try {
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target =
- client.target(baseUrl + "messwert/" + createdMesswertId);
- prot.addInfo("messwertId", createdMesswertId);
- /* Request a messwert with the saved id*/
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .get();
- String entity = response.readEntity(String.class);
- /* Try to parse the response*/
- JsonReader reader = Json.createReader(new StringReader(entity));
- JsonObject oldMesswert = reader.readObject().getJsonObject("data");
- /* Change the mmtId*/
- String updatedEntity =
- oldMesswert.toString().replace("207", "69");
- prot.addInfo("updated field", "mehId");
- prot.addInfo("updated value", "207");
- prot.addInfo("updated to", "69");
- /* Send the updated messwert via put request*/
- WebTarget putTarget = client.target(baseUrl + "messwert/" + createdMesswertId);
- Response updated = putTarget.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .put(Entity.entity(updatedEntity, MediaType.APPLICATION_JSON));
- /* Try to parse the response*/
- JsonReader updatedReader = Json.createReader(
- new StringReader(updated.readEntity(String.class)));
- JsonObject updatedMessung = updatedReader.readObject();
- /* Verify the response*/
- Assert.assertTrue(updatedMessung.getBoolean("success"));
- prot.addInfo("success", updatedMessung.getBoolean("success"));
- Assert.assertEquals("200", updatedMessung.getString("message"));
- prot.addInfo("message", updatedMessung.getString("message"));
- Assert.assertEquals(69,
- updatedMessung.getJsonObject("data").getInt("mehId"));
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-
- /**
- * Test the DELETE Service.
- *
- * @param baseUrl The url pointing to the test deployment.
- */
- public final void deleteService(URL baseUrl, List<Protocol> protocol) {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("MesswertService");
- prot.setType("delete");
- prot.setPassed(false);
- protocol.add(prot);
- try {
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target =
- client.target(baseUrl + "messwert/" + createdMesswertId);
- prot.addInfo("messwertId", createdMesswertId);
- /* Delete a messwert with the saved id*/
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .delete();
- String entity = response.readEntity(String.class);
- /* Try to parse the response*/
- JsonReader reader = Json.createReader(new StringReader(entity));
- JsonObject respObj = reader.readObject();
- /* Verify the response*/
- Assert.assertTrue(respObj.getBoolean("success"));
- prot.addInfo("success", respObj.getBoolean("success"));
- Assert.assertEquals("200", respObj.getString("message"));
- prot.addInfo("message", respObj.getString("message"));
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-}
diff -r 3d76d476894f -r 59c51da59b30 src/test/java/de/intevation/lada/test/land/MesswertTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/java/de/intevation/lada/test/land/MesswertTest.java Fri Dec 18 18:01:00 2015 +0100
@@ -0,0 +1,61 @@
+package de.intevation.lada.test.land;
+
+import java.net.URL;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.json.JsonObject;
+import javax.json.JsonObjectBuilder;
+import javax.json.JsonValue;
+
+import org.junit.Assert;
+
+import de.intevation.lada.Protocol;
+
+public class MesswertTest extends ServiceTest {
+
+ private JsonObject expectedById;
+ private JsonObject create;
+
+ /**
+ * @return The test protocol
+ */
+ public List<Protocol> getProtocol() {
+ return protocol;
+ }
+
+ @Override
+ public void init(
+ URL baseUrl,
+ List<Protocol> protocol
+ ) {
+ super.init(baseUrl, protocol);
+ // Attributes with timestamps
+ timestampAttributes = Arrays.asList(new String[]{
+ "letzteAenderung",
+ "treeModified"
+ });
+
+ // Prepare expected probe object
+ JsonObject content = readJsonResource("/datasets/dbUnit_messwert.json");
+ JsonObject messung = content.getJsonArray("land.messwert").getJsonObject(0);
+ JsonObjectBuilder builder = convertObject(messung);
+ builder.add("parentModified", 1450371851654L);
+ builder.add("readonly", JsonValue.FALSE);
+ builder.add("owner", JsonValue.TRUE);
+ expectedById = builder.build();
+ Assert.assertNotNull(expectedById);
+
+ // Load probe object to test POST request
+ create = readJsonResource("/datasets/messwert.json");
+ Assert.assertNotNull(create);
+ }
+
+ public final void execute() {
+ getAll("messwert", "rest/messwert?messungsId=1000");
+ getById("messwert", "rest/messwert/10000", expectedById);
+ JsonObject created = create("messwert", "rest/messwert", create);
+ update("messwert", "rest/messwert/10000", "messwertNwg", "<", ">");
+ delete("messwert", "rest/messwert/" + created.getJsonObject("data").get("id"));
+ }
+}
diff -r 3d76d476894f -r 59c51da59b30 src/test/java/de/intevation/lada/test/land/Ort.java
--- a/src/test/java/de/intevation/lada/test/land/Ort.java Fri Dec 18 17:55:20 2015 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,333 +0,0 @@
-/* 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.land;
-
-import java.io.StringReader;
-import java.net.URL;
-import java.util.List;
-
-import javax.json.Json;
-import javax.json.JsonException;
-import javax.json.JsonObject;
-import javax.json.JsonReader;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.junit.Assert;
-
-import de.intevation.lada.BaseTest;
-import de.intevation.lada.Protocol;
-
-/**
- * Class containing test cases for ort objects.
- *
- * @author <a href="mailto:rrenkert at intevation.de">Raimund Renkert</a>
- */
-public class Ort {
-
- private static final String COMPARE =
- "{\"id\":1,\"letzteAenderung\":1376287046510,\"ortsTyp\":\"Z\"," +
- "\"ortszusatztext\":null,\"probeId\":96,\"ort\":213,\"owner\":false," +
- "\"readonly\":false,\"treeModified\":null,\"parentModified\":null}";
-
- private static final String CREATE =
- "{\"letzteAenderung\":1376287046510,\"ortsTyp\":\"Z\"," +
- "\"ortszusatztext\":\"textzusatz\",\"probeId\":PID,\"ort\":213}";
-
- private List<Protocol> protocol;
-
- private static Integer createdId;
-
- public Integer getCreatedId() {
- return createdId;
- }
-
- /**
- * @return The test protocol
- */
- public List<Protocol> getProtocol() {
- return protocol;
- }
-
- /**
- * Test the GET Service by requesting all objects.
- *
- * @param baseUrl The url pointing to the test deployment.
- */
- public final void getAllService(URL baseUrl, List<Protocol> protocol)
- throws Exception {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("OrtService");
- prot.setType("get all");
- prot.setPassed(false);
- protocol.add(prot);
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target = client.target(baseUrl + "ort");
- /* Request all objects*/
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .get();
- String entity = response.readEntity(String.class);
- try{
- /* Try to parse the response*/
- JsonReader reader = Json.createReader(new StringReader(entity));
- JsonObject content = reader.readObject();
- /* Verify the response*/
- Assert.assertTrue(content.getBoolean("success"));
- prot.addInfo("success", content.getBoolean("success"));
- Assert.assertEquals("200", content.getString("message"));
- prot.addInfo("message", content.getString("message"));
- Assert.assertNotNull(content.getJsonArray("data"));
- prot.addInfo("objects", content.getJsonArray("data").size());
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-
- /**
- * Test the GET Service by requesting a single object by id.
- *
- * @param baseUrl The url pointing to the test deployment.
- */
- public final void getByIdService(URL baseUrl, List<Protocol> protocol)
- throws Exception {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("OrtService");
- prot.setType("get by Id");
- prot.setPassed(false);
- protocol.add(prot);
- try {
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target = client.target(baseUrl + "ort/1");
- prot.addInfo("ortId", 1);
- /* Request a object by id*/
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .get();
- String entity = response.readEntity(String.class);
- /* Try to parse the response*/
- JsonReader fromServiceReader =
- Json.createReader(new StringReader(entity));
- JsonObject content = fromServiceReader.readObject();
- /* Verify the response*/
- Assert.assertTrue(content.getBoolean("success"));
- prot.addInfo("success", content.getBoolean("success"));
- Assert.assertEquals("200", content.getString("message"));
- prot.addInfo("message", content.getString("message"));
- Assert.assertFalse(content.getJsonObject("data").isEmpty());
- prot.addInfo("object", "equals");
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-
- /**
- * Test the GET service using filters.
- *
- * @param baseUrl The url poining to the test deployment.
- */
- public final void filterService(URL baseUrl, List<Protocol> protocol) {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("OrtService");
- prot.setType("get by filter");
- prot.setPassed(false);
- protocol.add(prot);
- try {
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target =
- client.target(baseUrl + "ort?probeId=1");
- prot.addInfo("filter", "probeId=1");
- /* Request the objects using the filter*/
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .get();
- String entity = response.readEntity(String.class);
- /* Try to parse the response*/
- JsonReader reader = Json.createReader(new StringReader(entity));
- JsonObject respObj = reader.readObject();
- /* Verify the response*/
- Assert.assertTrue(respObj.getBoolean("success"));
- prot.addInfo("success", respObj.getBoolean("success"));
- Assert.assertEquals("200", respObj.getString("message"));
- prot.addInfo("message", respObj.getString("message"));
- Assert.assertNotNull(respObj.getJsonArray("data"));
- prot.addInfo("objects", respObj.getJsonArray("data").size());
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-
- /**
- * Test the CREATE Service.
- *
- * @param baseUrl The url pointing to the test deployment.
- */
- public final void createService(
- URL baseUrl,
- List<Protocol> protocol,
- Integer probeId)
- throws Exception {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("OrtService");
- prot.setType("create");
- prot.setPassed(false);
- protocol.add(prot);
- try {
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target = client.target(baseUrl + "ort");
- /* Send a post request containing a new object*/
- String mess = CREATE.replace("PID", probeId.toString());
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .post(Entity.entity(mess, MediaType.APPLICATION_JSON));
- String entity = response.readEntity(String.class);
- /* Try to parse the response*/
- JsonReader fromServiceReader =
- Json.createReader(new StringReader(entity));
- JsonObject content = fromServiceReader.readObject();
- /* Save the id*/
- createdId =
- content.getJsonObject("data").getJsonNumber("id").intValue();
- prot.addInfo("ortId", createdId);
- /* Verify the response*/
- Assert.assertTrue(content.getBoolean("success"));
- prot.addInfo("success", content.getBoolean("success"));
- Assert.assertEquals("200", content.getString("message"));
- prot.addInfo("message", content.getString("message"));
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-
- /**
- * Test the UPDATE Service.
- *
- * @param baseUrl The url pointing to the test deployment.
- */
- public final void updateService(URL baseUrl, List<Protocol> protocol)
- throws Exception {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("OrtService");
- prot.setType("update");
- prot.setPassed(false);
- protocol.add(prot);
- try {
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target =
- client.target(baseUrl + "ort/" + createdId);
- prot.addInfo("ortId", createdId);
- /* Request an object with the saved id*/
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .get();
- String entity = response.readEntity(String.class);
- /* Try to parse the response*/
- JsonReader reader = Json.createReader(new StringReader(entity));
- JsonObject old = reader.readObject().getJsonObject("data");
- /* Change the mmtId*/
- String updatedEntity =
- old.toString().replace("textzusatz", "changedzusatz");
- prot.addInfo("updated field", "ortszusatztext");
- prot.addInfo("updated value", "text");
- prot.addInfo("updated to", "zusatz");
- /* Send the updated messwert via put request*/
- WebTarget putTarget = client.target(baseUrl + "ort/" + createdId);
- Response updated = putTarget.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .put(Entity.entity(updatedEntity, MediaType.APPLICATION_JSON));
- /* Try to parse the response*/
- JsonReader updatedReader = Json.createReader(
- new StringReader(updated.readEntity(String.class)));
- JsonObject updatedObj = updatedReader.readObject();
- /* Verify the response*/
- Assert.assertTrue(updatedObj.getBoolean("success"));
- prot.addInfo("success", updatedObj.getBoolean("success"));
- Assert.assertEquals("200", updatedObj.getString("message"));
- prot.addInfo("message", updatedObj.getString("message"));
- Assert.assertEquals("changedzusatz",
- updatedObj.getJsonObject("data").getString("ortszusatztext"));
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-
- /**
- * Test the DELETE Service.
- *
- * @param baseUrl The url pointing to the test deployment.
- */
- public final void deleteService(URL baseUrl, List<Protocol> protocol) {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("OrtService");
- prot.setType("delete");
- prot.setPassed(false);
- protocol.add(prot);
- try {
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target =
- client.target(baseUrl + "ort/" + createdId);
- prot.addInfo("ortId", createdId);
- /* Delete the object with the saved id*/
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .delete();
- String entity = response.readEntity(String.class);
- /* Try to parse the response*/
- JsonReader reader = Json.createReader(new StringReader(entity));
- JsonObject respObj = reader.readObject();
- /* Verify the response*/
- Assert.assertTrue(respObj.getBoolean("success"));
- prot.addInfo("success", respObj.getBoolean("success"));
- Assert.assertEquals("200", respObj.getString("message"));
- prot.addInfo("message", respObj.getString("message"));
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-}
diff -r 3d76d476894f -r 59c51da59b30 src/test/java/de/intevation/lada/test/land/OrtszuordnungTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/java/de/intevation/lada/test/land/OrtszuordnungTest.java Fri Dec 18 18:01:00 2015 +0100
@@ -0,0 +1,60 @@
+package de.intevation.lada.test.land;
+
+import java.net.URL;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.json.JsonObject;
+import javax.json.JsonObjectBuilder;
+import javax.json.JsonValue;
+
+import org.junit.Assert;
+
+import de.intevation.lada.Protocol;
+
+public class OrtszuordnungTest extends ServiceTest {
+
+ private JsonObject expectedById;
+ private JsonObject create;
+
+ /**
+ * @return The test protocol
+ */
+ public List<Protocol> getProtocol() {
+ return protocol;
+ }
+
+ @Override
+ public void init(
+ URL baseUrl,
+ List<Protocol> protocol
+ ) {
+ super.init(baseUrl, protocol);
+ // Attributes with timestamps
+ timestampAttributes = Arrays.asList(new String[]{
+ "letzteAenderung"
+ });
+
+ // Prepare expected probe object
+ JsonObject content = readJsonResource("/datasets/dbUnit_ortszuordnung.json");
+ JsonObject messung = content.getJsonArray("land.ortszuordnung").getJsonObject(0);
+ JsonObjectBuilder builder = convertObject(messung);
+ builder.add("parentModified", 1450371851654L);
+ builder.add("readonly", JsonValue.FALSE);
+ builder.add("owner", JsonValue.TRUE);
+ expectedById = builder.build();
+ Assert.assertNotNull(expectedById);
+
+ // Load probe object to test POST request
+ create = readJsonResource("/datasets/ortszuordnung.json");
+ Assert.assertNotNull(create);
+ }
+
+ public final void execute() {
+ getAll("ortszuordnung", "rest/ortszuordnung");
+ getById("ortszuordnung", "rest/ortszuordnung/1000", expectedById);
+ JsonObject created = create("ortszuordnung", "rest/ortszuordnung", create);
+ update("ortszuordnung", "rest/ortszuordnung/1000", "ortszusatztext", "Test", "Test geändert");
+ delete("ortszuordnung", "rest/ortszuordnung/" + created.getJsonObject("data").get("id"));
+ }
+}
diff -r 3d76d476894f -r 59c51da59b30 src/test/java/de/intevation/lada/test/land/Probe.java
--- a/src/test/java/de/intevation/lada/test/land/Probe.java Fri Dec 18 17:55:20 2015 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,346 +0,0 @@
-/* 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.land;
-
-import java.io.StringReader;
-import java.net.URL;
-import java.util.List;
-
-import javax.json.Json;
-import javax.json.JsonException;
-import javax.json.JsonObject;
-import javax.json.JsonReader;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.junit.Assert;
-
-import de.intevation.lada.BaseTest;
-import de.intevation.lada.Protocol;
-
-
-/**
- * Class containing test cases for probe objects.
- *
- * @author <a href="mailto:rrenkert at intevation.de">Raimund Renkert</a>
- */
-public class Probe {
-
- private static final String COMPARE_PROBE =
- "{\"id\":1,\"baId\":\"1\",\"datenbasisId\":2," +
- "\"letzteAenderung\":1339570306000,\"media\":\"Trinkwasser " +
- "Zentralversorgung Oberflächenwasser aufbereitet\",\"mediaDesk\":" +
- "\"D: 59 04 01 00 05 05 01 02 00 00 00 00\",\"mittelungsdauer\":" +
- "null,\"mstId\":\"06010\",\"netzbetreiberId\":\"06\"," +
- "\"probeentnahmeBeginn\":1336467600000,\"probeentnahmeEnde\":" +
- "null,\"probenartId\":1,\"test\":false,\"umwId\":\"N72\"," +
- "\"hauptprobenNr\":\"120510002\",\"erzeugerId\":null,\"mpKat\":\"1\"," +
- "\"mplId\":null,\"mprId\":3749,\"probeNehmerId\":726," +
- "\"solldatumBeginn\":1336341600000,\"solldatumEnde\":1336939199000," +
- "\"treeModified\":null,\"readonly\":false,\"owner\":false," +
- "\"probeIdAlt\":\"000007581034X\"}";
-
- private static final String CREATE_PROBE =
- "{\"baId\":\"1\",\"datenbasisId\":2,\"erzeugerId\":\"\"," +
- "\"hauptprobenNr\":\"4554567890\",\"media\":\"\",\"mediaDesk\":" +
- "\"\",\"mittelungsdauer\":\"\",\"mpKat\":\"\",\"mplId\":\"\"," +
- "\"mprId\":\"\",\"mstId\":\"11010\",\"netzbetreiberId\":\"11\"," +
- "\"probeNehmerId\":3,\"probenartId\":1,\"test\":true,\"umwId\":" +
- "\"A1\",\"letzteAenderung\":\"2015-02-09T10:58:36\"" +
- ",\"probeentnahmeBeginn\":\"2015-02-08T10:58:36\"," +
- "\"probeentnahmeEnde\":\"2015-02-09T10:58:36\",\"solldatumBeginn\":" +
- "\"2015-02-09T10:58:36\",\"solldatumEnde\":\"2015-02-09T10:58:36\"}";
-
- private List<Protocol> protocol;
-
- private static Integer createdProbeId;
-
- public Integer getCreatedProbeId() {
- return createdProbeId;
- }
-
- /**
- * @return The test protocol
- */
- public List<Protocol> getProtocol() {
- return protocol;
- }
-
- /**
- * Test the GET Service by requesting all objects.
- *
- * @param baseUrl The url pointing to the test deployment.
- */
- public final void getAllService(URL baseUrl, List<Protocol> protocol)
- throws Exception {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("ProbeService");
- prot.setType("get all");
- prot.setPassed(false);
- protocol.add(prot);
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target = client.target(baseUrl + "probe");
- /* Request all objects*/
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .get();
- String entity = response.readEntity(String.class);
- try{
- /* Try to parse the response*/
- JsonReader reader = Json.createReader(new StringReader(entity));
- JsonObject content = reader.readObject();
- /* Verify the response*/
- Assert.assertTrue(content.getBoolean("success"));
- prot.addInfo("success", content.getBoolean("success"));
- Assert.assertEquals("200", content.getString("message"));
- prot.addInfo("message", content.getString("message"));
- Assert.assertNotNull(content.getJsonArray("data"));
- prot.addInfo("objects", content.getJsonArray("data").size());
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-
- /**
- * Test the GET Service by requesting a single object by id.
- *
- * @param baseUrl The url pointing to the test deployment.
- */
- public final void getByIdService(URL baseUrl, List<Protocol> protocol)
- throws Exception {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("ProbeService");
- prot.setType("get by Id");
- prot.setPassed(false);
- protocol.add(prot);
- try {
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target = client.target(baseUrl + "probe/1");
- prot.addInfo("probeId", 1);
- /* Request a object by id*/
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .get();
- String entity = response.readEntity(String.class);
- /* Try to parse the response*/
- JsonReader fromServiceReader =
- Json.createReader(new StringReader(entity));
- JsonObject content = fromServiceReader.readObject();
- /* Verify the response*/
- Assert.assertTrue(content.getBoolean("success"));
- prot.addInfo("success", content.getBoolean("success"));
- Assert.assertEquals("200", content.getString("message"));
- prot.addInfo("message", content.getString("message"));
- Assert.assertFalse(content.getJsonObject("data").isEmpty());
- prot.addInfo("object", "equals");
- }
- catch(JsonException je) {
- prot.addInfo("exception",je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-
- /**
- * Test the GET service using filters.
- *
- * @param baseUrl The url poining to the test deployment.
- */
- public final void filterService(URL baseUrl, List<Protocol> protocol) {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("ProbeService");
- prot.setType("get by filter");
- prot.setPassed(false);
- protocol.add(prot);
- try {
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target =
- client.target(baseUrl + "probe?qid=2&mst_id=11010&umw_id=N24");
- prot.addInfo("filter", "qid=2&mst_id=11010&umw_id=N24");
- /* Request the objects using the filter*/
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .get();
- String entity = response.readEntity(String.class);
- /* Try to parse the response*/
- JsonReader reader = Json.createReader(new StringReader(entity));
- JsonObject respObj = reader.readObject();
- /* Verify the response*/
- Assert.assertTrue(respObj.getBoolean("success"));
- prot.addInfo("success", respObj.getBoolean("success"));
- Assert.assertEquals("200", respObj.getString("message"));
- prot.addInfo("message", respObj.getString("message"));
- Assert.assertNotNull(respObj.getJsonArray("data"));
- prot.addInfo("objects", respObj.getJsonArray("data").size());
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-
- /**
- * Test the CREATE Service.
- *
- * @param baseUrl The url pointing to the test deployment.
- */
- public final void createService(URL baseUrl, List<Protocol> protocol)
- throws Exception {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("ProbeService");
- prot.setType("create");
- prot.setPassed(false);
- protocol.add(prot);
- try {
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target = client.target(baseUrl + "probe");
- /* Send a post request containing a new probe*/
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .post(Entity.entity(CREATE_PROBE, MediaType.APPLICATION_JSON));
- String entity = response.readEntity(String.class);
- /* Try to parse the response*/
- JsonReader fromServiceReader =
- Json.createReader(new StringReader(entity));
- JsonObject content = fromServiceReader.readObject();
- /* Save the id*/
- createdProbeId =
- content.getJsonObject("data").getJsonNumber("id").intValue();
- prot.addInfo("probeId", createdProbeId);
- /* Verify the response*/
- Assert.assertTrue(content.getBoolean("success"));
- prot.addInfo("success", content.getBoolean("success"));
- Assert.assertEquals("200", content.getString("message"));
- prot.addInfo("message", content.getString("message"));
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-
- /**
- * Test the probe update service.
- *
- * @param baseUrl The url pointing to the test deployment.
- */
- public final void updateService(URL baseUrl, List<Protocol> protocol)
- throws Exception {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("ProbeService");
- prot.setType("update");
- prot.setPassed(false);
- protocol.add(prot);
- try {
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target =
- client.target(baseUrl + "probe/" + createdProbeId);
- prot.addInfo("probeId", createdProbeId);
- /* Request a with the saved id*/
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .get();
- String entity = response.readEntity(String.class);
- /* Try to parse the response*/
- JsonReader reader = Json.createReader(new StringReader(entity));
- JsonObject oldProbe = reader.readObject().getJsonObject("data");
- /* Change the hauptprobenNr*/
- String updatedEntity =
- oldProbe.toString().replace("4554567890", "2345678911");
- prot.addInfo("updated datafield", "hauptprobenNr");
- prot.addInfo("updated value", "1234567890");
- prot.addInfo("updated to", "2345678911");
- /* Send the updated probe via put request*/
- WebTarget putTarget = client.target(baseUrl + "probe/" + createdProbeId);
- Response updated = putTarget.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .put(Entity.entity(updatedEntity, MediaType.APPLICATION_JSON));
- /* Try to parse the response*/
- JsonReader updatedReader = Json.createReader(
- new StringReader(updated.readEntity(String.class)));
- JsonObject updatedProbe = updatedReader.readObject();
- /* Verify the response*/
- Assert.assertTrue(updatedProbe.getBoolean("success"));
- prot.addInfo("success", updatedProbe.getBoolean("success"));
- Assert.assertEquals("200", updatedProbe.getString("message"));
- prot.addInfo("message", updatedProbe.getString("message"));
- Assert.assertEquals("2345678911",
- updatedProbe.getJsonObject("data").getString("hauptprobenNr"));
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-
- /**
- * Test the DELETE Service.
- *
- * @param baseUrl The url pointing to the test deployment.
- */
- public final void deleteService(URL baseUrl, List<Protocol> protocol) {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("ProbeService");
- prot.setType("delete");
- prot.setPassed(false);
- protocol.add(prot);
- try {
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target =
- client.target(baseUrl + "probe/" + createdProbeId);
- prot.addInfo("probeId", createdProbeId);
- /* Delete a probe with the id saved when created a probe*/
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .delete();
- String entity = response.readEntity(String.class);
- /* Try to parse the response*/
- JsonReader reader = Json.createReader(new StringReader(entity));
- JsonObject respObj = reader.readObject();
- /* Verify the response*/
- Assert.assertTrue(respObj.getBoolean("success"));
- prot.addInfo("success", respObj.getBoolean("success"));
- Assert.assertEquals("200", respObj.getString("message"));
- prot.addInfo("message", respObj.getString("message"));
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-}
diff -r 3d76d476894f -r 59c51da59b30 src/test/java/de/intevation/lada/test/land/ProbeTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/java/de/intevation/lada/test/land/ProbeTest.java Fri Dec 18 18:01:00 2015 +0100
@@ -0,0 +1,71 @@
+package de.intevation.lada.test.land;
+
+import java.net.URL;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.json.JsonObject;
+import javax.json.JsonObjectBuilder;
+import javax.json.JsonValue;
+
+import org.junit.Assert;
+
+import de.intevation.lada.Protocol;
+
+public class ProbeTest extends ServiceTest {
+
+ private JsonObject expectedById;
+ private JsonObject create;
+
+ /**
+ * @return The test protocol
+ */
+ public List<Protocol> getProtocol() {
+ return protocol;
+ }
+
+ @Override
+ public void init(
+ URL baseUrl,
+ List<Protocol> protocol
+ ) {
+ super.init(baseUrl, protocol);
+ // Attributes with timestamps
+ timestampAttributes = Arrays.asList(new String[]{
+ "letzteAenderung",
+ "probeentnahmeBeginn",
+ "solldatumBeginn",
+ "solldatumEnde",
+ "treeModified"
+ });
+
+ // Prepare expected probe object
+ JsonObject content = readJsonResource("/datasets/dbUnit_probe.json");
+ JsonObject probe = content.getJsonArray("land.probe").getJsonObject(0);
+ JsonObjectBuilder builder = convertObject(probe);
+ JsonObject trans =
+ content.getJsonArray("land.probe_translation").getJsonObject(0);
+ builder.add("probeIdAlt", trans.get("probe_id_alt"));
+ builder.add("mittelungsdauer", JsonValue.NULL);
+ builder.add("probeentnahmeEnde", JsonValue.NULL);
+ builder.add("erzeugerId", JsonValue.NULL);
+ builder.add("mplId", JsonValue.NULL);
+ builder.add("readonly", JsonValue.FALSE);
+ builder.add("owner", JsonValue.TRUE);
+ expectedById = builder.build();
+ Assert.assertNotNull(expectedById);
+
+ // Load probe object to test POST request
+ create = readJsonResource("/datasets/probe.json");
+ Assert.assertNotNull(create);
+ }
+
+ public final void execute() {
+ getAll("probe", "rest/probe");
+ getById("probe", "rest/probe/1000", expectedById);
+ filter("probe", "rest/probe?qid=2&mst_id=11010&umw_id=N24");
+ JsonObject created = create("probe", "rest/probe", create);
+ update("probe", "rest/probe/1000", "hauptprobenNr", "120510002", "130510002");
+ delete("probe", "rest/probe/" + created.getJsonObject("data").get("id"));
+ }
+}
diff -r 3d76d476894f -r 59c51da59b30 src/test/java/de/intevation/lada/test/land/Query.java
--- a/src/test/java/de/intevation/lada/test/land/Query.java Fri Dec 18 17:55:20 2015 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,85 +0,0 @@
-/* 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.land;
-
-import java.io.StringReader;
-import java.net.URL;
-import java.util.List;
-
-import javax.json.Json;
-import javax.json.JsonException;
-import javax.json.JsonObject;
-import javax.json.JsonReader;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
-import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.Response;
-
-import org.junit.Assert;
-
-import de.intevation.lada.BaseTest;
-import de.intevation.lada.Protocol;
-
-
-/**
- * Class containing test cases for query config.
- *
- * @author <a href="mailto:rrenkert at intevation.de">Raimund Renkert</a>
- */
-public class Query {
-
- private List<Protocol> protocol;
-
- /**
- * @return The test protocol
- */
- public List<Protocol> getProtocol() {
- return protocol;
- }
-
- /**
- * Test the GET Service by requesting all queries.
- *
- * @param baseUrl The url pointing to the test deployment.
- */
- public final void getAllService(URL baseUrl, List<Protocol> protocol)
- throws Exception {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("QueryService");
- prot.setType("get all");
- prot.setPassed(false);
- protocol.add(prot);
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target = client.target(baseUrl + "query/probe");
- /* Request all queries*/
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .get();
- String entity = response.readEntity(String.class);
- try{
- /* Try to parse the response*/
- JsonReader reader = Json.createReader(new StringReader(entity));
- JsonObject content = reader.readObject();
- /* Verfiy the response*/
- Assert.assertTrue(content.getBoolean("success"));
- prot.addInfo("success", content.getBoolean("success"));
- Assert.assertEquals("200", content.getString("message"));
- prot.addInfo("message", content.getString("message"));
- Assert.assertNotNull(content.getJsonArray("data"));
- prot.addInfo("objects", content.getJsonArray("data").size());
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-}
diff -r 3d76d476894f -r 59c51da59b30 src/test/java/de/intevation/lada/test/land/QueryTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/java/de/intevation/lada/test/land/QueryTest.java Fri Dec 18 18:01:00 2015 +0100
@@ -0,0 +1,29 @@
+package de.intevation.lada.test.land;
+
+import java.net.URL;
+import java.util.List;
+
+import de.intevation.lada.Protocol;
+
+public class QueryTest extends ServiceTest {
+
+ /**
+ * @return The test protocol
+ */
+ public List<Protocol> getProtocol() {
+ return protocol;
+ }
+
+ @Override
+ public void init(
+ URL baseUrl,
+ List<Protocol> protocol
+ ) {
+ super.init(baseUrl, protocol);
+ }
+
+ public final void execute() {
+ getAll("query", "rest/query/probe");
+ getAll("query", "rest/query/messprogramm");
+ }
+}
diff -r 3d76d476894f -r 59c51da59b30 src/test/java/de/intevation/lada/test/land/ServiceTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/java/de/intevation/lada/test/land/ServiceTest.java Fri Dec 18 18:01:00 2015 +0100
@@ -0,0 +1,362 @@
+package de.intevation.lada.test.land;
+
+import java.io.InputStream;
+import java.io.StringReader;
+import java.net.URL;
+import java.sql.Timestamp;
+import java.util.List;
+import java.util.Map.Entry;
+import java.util.Scanner;
+
+import javax.json.Json;
+import javax.json.JsonException;
+import javax.json.JsonObject;
+import javax.json.JsonObjectBuilder;
+import javax.json.JsonReader;
+import javax.json.JsonValue;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.apache.commons.lang.WordUtils;
+import org.junit.Assert;
+
+import de.intevation.lada.BaseTest;
+import de.intevation.lada.Protocol;
+
+public class ServiceTest {
+
+ protected List<Protocol> protocol;
+
+ protected List<String> timestampAttributes;
+
+ protected URL baseUrl;
+
+ public void init(URL baseUrl, List<Protocol> protocol) {
+ this.baseUrl = baseUrl;
+ this.protocol = protocol;
+ }
+
+ /**
+ * @return The test protocol
+ */
+ public List<Protocol> getProtocol() {
+ return protocol;
+ }
+
+ protected JsonObject readJsonResource(String resource) {
+ InputStream stream =
+ ProbeTest.class.getResourceAsStream(resource);
+ Scanner scanner = new Scanner(stream, "UTF-8");
+ scanner.useDelimiter("\\A");
+ String raw = scanner.next();
+ scanner.close();
+ JsonReader reader = Json.createReader(new StringReader(raw));
+ JsonObject content = reader.readObject();
+ reader.close();
+ return content;
+ }
+
+ protected JsonObjectBuilder convertObject(JsonObject object) {
+ JsonObjectBuilder builder = Json.createObjectBuilder();
+ for (Entry<String, JsonValue> entry : object.entrySet()) {
+ String key = WordUtils.capitalize(
+ entry.getKey(), new char[]{'_'}).replaceAll("_","");
+ key = key.replaceFirst(key.substring(0, 1), key.substring(0, 1).toLowerCase());
+ if (timestampAttributes.contains(key)) {
+ Timestamp timestamp = Timestamp.valueOf(entry.getValue().toString().replaceAll("\"", ""));
+ builder.add(key, timestamp.getTime());
+ }
+ else {
+ builder.add(key, entry.getValue());
+ }
+ }
+ return builder;
+ }
+
+ public JsonObject getAll(String name, String parameter) {
+ System.out.print(".");
+ Protocol prot = new Protocol();
+ prot.setName(name + " service");
+ prot.setType("get all");
+ prot.setPassed(false);
+ protocol.add(prot);
+ /* Create a client*/
+ Client client = ClientBuilder.newClient();
+ WebTarget target = client.target(baseUrl + parameter);
+ /* Request all objects*/
+ Response response = target.request()
+ .header("X-SHIB-user", BaseTest.TEST_USER)
+ .header("X-SHIB-roles", BaseTest.TEST_ROLES)
+ .get();
+ String entity = response.readEntity(String.class);
+ try{
+ /* Try to parse the response*/
+ JsonReader reader = Json.createReader(new StringReader(entity));
+ JsonObject content = reader.readObject();
+ /* Verify the response*/
+ Assert.assertTrue(content.getBoolean("success"));
+ prot.addInfo("success", content.getBoolean("success"));
+ Assert.assertEquals("200", content.getString("message"));
+ prot.addInfo("message", content.getString("message"));
+ Assert.assertNotNull(content.getJsonArray("data"));
+ prot.addInfo("objects", content.getJsonArray("data").size());
+ prot.setPassed(true);
+ return content;
+ }
+ catch(JsonException je) {
+ prot.addInfo("exception", je.getMessage());
+ Assert.fail(je.getMessage());
+ }
+ return null;
+ }
+ /**
+ * Test the GET Service by requesting a single object by id.
+ *
+ * @param baseUrl The url pointing to the test deployment.
+ */
+ public JsonObject getById(
+ String name,
+ String parameter,
+ JsonObject expected
+ ) {
+ System.out.print(".");
+ Protocol prot = new Protocol();
+ prot.setName(name + " service");
+ prot.setType("get by Id");
+ prot.setPassed(false);
+ protocol.add(prot);
+ try {
+ /* Create a client*/
+ Client client = ClientBuilder.newClient();
+ WebTarget target = client.target(baseUrl + parameter);
+ prot.addInfo("parameter", parameter);
+ /* Request a object by id*/
+ Response response = target.request()
+ .header("X-SHIB-user", BaseTest.TEST_USER)
+ .header("X-SHIB-roles", BaseTest.TEST_ROLES)
+ .get();
+ String entity = response.readEntity(String.class);
+ /* Try to parse the response*/
+ JsonReader fromServiceReader =
+ Json.createReader(new StringReader(entity));
+ JsonObject content = fromServiceReader.readObject();
+ /* Verify the response*/
+ Assert.assertTrue(content.getBoolean("success"));
+ prot.addInfo("success", content.getBoolean("success"));
+ Assert.assertEquals("200", content.getString("message"));
+ prot.addInfo("message", content.getString("message"));
+ Assert.assertFalse(content.getJsonObject("data").isEmpty());
+ JsonObject object = content.getJsonObject("data");
+ for (Entry<String, JsonValue> entry : expected.entrySet()) {
+ if (entry.getKey().equals("parentModified") ||
+ entry.getKey().equals("treeModified")) {
+ continue;
+ }
+ Assert.assertEquals(entry.getValue(), object.get(entry.getKey()));
+ }
+ prot.addInfo("object", "equals");
+ prot.setPassed(true);
+ return content;
+ }
+ catch(JsonException je) {
+ prot.addInfo("exception",je.getMessage());
+ Assert.fail(je.getMessage());
+ }
+ return null;
+ }
+
+ /**
+ * Test the GET service using filters.
+ *
+ * @param baseUrl The url poining to the test deployment.
+ */
+ public JsonObject filter(String name, String parameter) {
+ System.out.print(".");
+ Protocol prot = new Protocol();
+ prot.setName(name + " service");
+ prot.setType("filter");
+ prot.setPassed(false);
+ protocol.add(prot);
+ try {
+ /* Create a client*/
+ Client client = ClientBuilder.newClient();
+ WebTarget target =
+ client.target(baseUrl + parameter);//"probe?qid=2&mst_id=11010&umw_id=N24");
+ prot.addInfo("filter", parameter);//"qid=2&mst_id=11010&umw_id=N24");
+ /* Request the objects using the filter*/
+ Response response = target.request()
+ .header("X-SHIB-user", BaseTest.TEST_USER)
+ .header("X-SHIB-roles", BaseTest.TEST_ROLES)
+ .get();
+ String entity = response.readEntity(String.class);
+ /* Try to parse the response*/
+ JsonReader reader = Json.createReader(new StringReader(entity));
+ JsonObject content = reader.readObject();
+ /* Verify the response*/
+ Assert.assertTrue(content.getBoolean("success"));
+ prot.addInfo("success", content.getBoolean("success"));
+ Assert.assertEquals("200", content.getString("message"));
+ prot.addInfo("message", content.getString("message"));
+ Assert.assertNotNull(content.getJsonArray("data"));
+ prot.addInfo("objects", content.getJsonArray("data").size());
+ prot.setPassed(true);
+ return content;
+ }
+ catch(JsonException je) {
+ prot.addInfo("exception", je.getMessage());
+ Assert.fail(je.getMessage());
+ }
+ return null;
+ }
+
+ /**
+ * Test the CREATE Service.
+ *
+ * @param baseUrl The url pointing to the test deployment.
+ */
+ public JsonObject create(String name, String parameter, JsonObject create) {
+ System.out.print(".");
+ Protocol prot = new Protocol();
+ prot.setName(name + " service");
+ prot.setType("create");
+ prot.setPassed(false);
+ protocol.add(prot);
+ try {
+ /* Create a client*/
+ Client client = ClientBuilder.newClient();
+ WebTarget target = client.target(baseUrl + parameter);
+ /* Send a post request containing a new probe*/
+ Response response = target.request()
+ .header("X-SHIB-user", BaseTest.TEST_USER)
+ .header("X-SHIB-roles", BaseTest.TEST_ROLES)
+ .post(Entity.entity(create.toString(), MediaType.APPLICATION_JSON));
+ String entity = response.readEntity(String.class);
+ /* Try to parse the response*/
+ JsonReader fromServiceReader =
+ Json.createReader(new StringReader(entity));
+ JsonObject content = fromServiceReader.readObject();
+ /* Verify the response*/
+ Assert.assertTrue(content.getBoolean("success"));
+ prot.addInfo("success", content.getBoolean("success"));
+ Assert.assertEquals("200", content.getString("message"));
+ prot.addInfo("message", content.getString("message"));
+ prot.setPassed(true);
+ return content;
+ }
+ catch(JsonException je) {
+ prot.addInfo("exception", je.getMessage());
+ Assert.fail(je.getMessage());
+ }
+ return null;
+ }
+
+ /**
+ * Test the probe update service.
+ *
+ * @param baseUrl The url pointing to the test deployment.
+ */
+ public JsonObject update(
+ String name,
+ String parameter,
+ String updateAttribute,
+ String oldValue,
+ String newValue
+ ) {
+ System.out.print(".");
+ Protocol prot = new Protocol();
+ prot.setName(name + " service");
+ prot.setType("update");
+ prot.setPassed(false);
+ protocol.add(prot);
+ try {
+ /* Create a client*/
+ Client client = ClientBuilder.newClient();
+ WebTarget target = client.target(baseUrl + parameter);
+ /* Request a with the saved id*/
+ Response response = target.request()
+ .header("X-SHIB-user", BaseTest.TEST_USER)
+ .header("X-SHIB-roles", BaseTest.TEST_ROLES)
+ .get();
+ String entity = response.readEntity(String.class);
+ /* Try to parse the response*/
+ JsonReader reader = Json.createReader(new StringReader(entity));
+ JsonObject oldObject = reader.readObject().getJsonObject("data");
+ /* Change the hauptprobenNr*/
+ String updatedEntity =
+ oldObject.toString().replace(oldValue, newValue);
+ prot.addInfo("updated datafield", updateAttribute);
+ prot.addInfo("updated value", oldValue);
+ prot.addInfo("updated to", newValue);
+ /* Send the updated probe via put request*/
+ WebTarget putTarget = client.target(baseUrl + parameter);
+ Response updated = putTarget.request()
+ .header("X-SHIB-user", BaseTest.TEST_USER)
+ .header("X-SHIB-roles", BaseTest.TEST_ROLES)
+ .put(Entity.entity(updatedEntity, MediaType.APPLICATION_JSON));
+ /* Try to parse the response*/
+ JsonReader updatedReader = Json.createReader(
+ new StringReader(updated.readEntity(String.class)));
+ JsonObject updatedObject = updatedReader.readObject();
+ /* Verify the response*/
+ Assert.assertTrue(updatedObject.getBoolean("success"));
+ prot.addInfo("success", updatedObject.getBoolean("success"));
+ Assert.assertEquals("200", updatedObject.getString("message"));
+ prot.addInfo("message", updatedObject.getString("message"));
+ Assert.assertEquals(newValue,
+ updatedObject.getJsonObject("data").getString(updateAttribute));
+ prot.setPassed(true);
+ return updatedObject;
+ }
+ catch(JsonException je) {
+ prot.addInfo("exception", je.getMessage());
+ Assert.fail(je.getMessage());
+ }
+ return null;
+ }
+
+ /**
+ * Test the DELETE Service.
+ *
+ * @param baseUrl The url pointing to the test deployment.
+ */
+ public JsonObject delete(String name, String parameter) {
+ System.out.print(".");
+ Protocol prot = new Protocol();
+ prot.setName(name + " service");
+ prot.setType("delete");
+ prot.setPassed(false);
+ protocol.add(prot);
+ try {
+ /* Create a client*/
+ Client client = ClientBuilder.newClient();
+ WebTarget target =
+ client.target(baseUrl + parameter);
+ prot.addInfo("parameter", parameter);
+ /* Delete a probe with the id saved when created a probe*/
+ Response response = target.request()
+ .header("X-SHIB-user", BaseTest.TEST_USER)
+ .header("X-SHIB-roles", BaseTest.TEST_ROLES)
+ .delete();
+ String entity = response.readEntity(String.class);
+ /* Try to parse the response*/
+ JsonReader reader = Json.createReader(new StringReader(entity));
+ JsonObject content = reader.readObject();
+ /* Verify the response*/
+ Assert.assertTrue(content.getBoolean("success"));
+ prot.addInfo("success", content.getBoolean("success"));
+ Assert.assertEquals("200", content.getString("message"));
+ prot.addInfo("message", content.getString("message"));
+ prot.setPassed(true);
+ return content;
+ }
+ catch(JsonException je) {
+ prot.addInfo("exception", je.getMessage());
+ Assert.fail(je.getMessage());
+ }
+ return null;
+ }
+}
diff -r 3d76d476894f -r 59c51da59b30 src/test/java/de/intevation/lada/test/land/Status.java
--- a/src/test/java/de/intevation/lada/test/land/Status.java Fri Dec 18 17:55:20 2015 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,335 +0,0 @@
-/* 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.land;
-
-import java.io.StringReader;
-import java.net.URL;
-import java.util.List;
-
-import javax.json.Json;
-import javax.json.JsonException;
-import javax.json.JsonObject;
-import javax.json.JsonReader;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.junit.Assert;
-
-import de.intevation.lada.BaseTest;
-import de.intevation.lada.Protocol;
-
-/**
- * Class containing test cases for status objects.
- *
- * @author <a href="mailto:rrenkert at intevation.de">Raimund Renkert</a>
- */
-public class Status {
-
- private static final String COMPARE =
- "{\"id\":1,\"erzeuger\":\"06010\",\"messungsId\":440,\"status\":3," +
- "\"owner\":false,\"readonly\":false,\"treeModified\":null," +
- "\"parentModified\":null," +
- "\"sdatum\":1373846400000,\"skommentar\":\"test\"}";
-
- private static final String CREATE =
- "{\"erzeuger\":\"06010\",\"messungsId\":MID,\"statusStufe\":1," +
- "\"statusWert\":1," +
- "\"datum\":1373846400000,\"text\":\"status test\"}";
-
- private List<Protocol> protocol;
-
- private static Integer createdId;
-
- public Integer getCreatedId() {
- return createdId;
- }
-
- /**
- * @return The test protocol
- */
- public List<Protocol> getProtocol() {
- return protocol;
- }
-
- /**
- * Test the GET Service by requesting all objects.
- *
- * @param baseUrl The url pointing to the test deployment.
- */
- public final void getAllService(URL baseUrl, List<Protocol> protocol)
- throws Exception {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("StatusService");
- prot.setType("get all");
- prot.setPassed(false);
- protocol.add(prot);
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target = client.target(baseUrl + "status");
- /* Request all objects*/
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .get();
- String entity = response.readEntity(String.class);
- try{
- /* Try to parse the response*/
- JsonReader reader = Json.createReader(new StringReader(entity));
- JsonObject content = reader.readObject();
- /* Verify the response*/
- Assert.assertTrue(content.getBoolean("success"));
- prot.addInfo("success", content.getBoolean("success"));
- Assert.assertEquals("200", content.getString("message"));
- prot.addInfo("message", content.getString("message"));
- Assert.assertNotNull(content.getJsonArray("data"));
- prot.addInfo("objects", content.getJsonArray("data").size());
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-
- /**
- * Test the GET Service by requesting a single object by id.
- *
- * @param baseUrl The url pointing to the test deployment.
- */
- public final void getByIdService(URL baseUrl, List<Protocol> protocol)
- throws Exception {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("StatusService");
- prot.setType("get by Id");
- prot.setPassed(false);
- protocol.add(prot);
- try {
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target = client.target(baseUrl + "status/511");
- prot.addInfo("statusId", 1);
- /* Request a object by id*/
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .get();
- String entity = response.readEntity(String.class);
- /* Try to parse the response*/
- JsonReader fromServiceReader =
- Json.createReader(new StringReader(entity));
- JsonObject content = fromServiceReader.readObject();
- /* Verify the response*/
- Assert.assertTrue(content.getBoolean("success"));
- prot.addInfo("success", content.getBoolean("success"));
- Assert.assertEquals("200", content.getString("message"));
- prot.addInfo("message", content.getString("message"));
- Assert.assertFalse(content.getJsonObject("data").isEmpty());
- prot.addInfo("object", "equals");
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-
- /**
- * Test the GET service using filters.
- *
- * @param baseUrl The url poining to the test deployment.
- */
- public final void filterService(URL baseUrl, List<Protocol> protocol) {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("StatusService");
- prot.setType("get by filter");
- prot.setPassed(false);
- protocol.add(prot);
- try {
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target =
- client.target(baseUrl + "status?messungId=1");
- prot.addInfo("filter", "messungId=1");
- /* Request the objects using the filter*/
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .get();
- String entity = response.readEntity(String.class);
- /* Try to parse the response*/
- JsonReader reader = Json.createReader(new StringReader(entity));
- JsonObject respObj = reader.readObject();
- /* Verify the response*/
- Assert.assertTrue(respObj.getBoolean("success"));
- prot.addInfo("success", respObj.getBoolean("success"));
- Assert.assertEquals("200", respObj.getString("message"));
- prot.addInfo("message", respObj.getString("message"));
- Assert.assertNotNull(respObj.getJsonArray("data"));
- prot.addInfo("objects", respObj.getJsonArray("data").size());
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-
- /**
- * Test the CREATE Service.
- *
- * @param baseUrl The url pointing to the test deployment.
- */
- public final void createService(
- URL baseUrl,
- List<Protocol> protocol,
- Integer messungId)
- throws Exception {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("StatusService");
- prot.setType("create");
- prot.setPassed(false);
- protocol.add(prot);
- try {
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target = client.target(baseUrl + "status");
- /* Send a post request containing a new object*/
- String stat = CREATE.replace("MID", messungId.toString());
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .post(Entity.entity(stat, MediaType.APPLICATION_JSON));
- String entity = response.readEntity(String.class);
- /* Try to parse the response*/
- JsonReader fromServiceReader =
- Json.createReader(new StringReader(entity));
- JsonObject content = fromServiceReader.readObject();
- /* Save the id*/
- createdId =
- content.getJsonObject("data").getJsonNumber("id").intValue();
- prot.addInfo("statusId", createdId);
- /* Verify the response*/
- Assert.assertTrue(content.getBoolean("success"));
- prot.addInfo("success", content.getBoolean("success"));
- Assert.assertEquals("200", content.getString("message"));
- prot.addInfo("message", content.getString("message"));
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-
- /**
- * Test the UPDATE Service.
- *
- * @param baseUrl The url pointing to the test deployment.
- */
- public final void updateService(URL baseUrl, List<Protocol> protocol)
- throws Exception {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("StatusService");
- prot.setType("update");
- prot.setPassed(false);
- protocol.add(prot);
- try {
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target =
- client.target(baseUrl + "status/" + createdId);
- prot.addInfo("statusId", createdId);
- /* Request an object with the saved id*/
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .get();
- String entity = response.readEntity(String.class);
- /* Try to parse the response*/
- JsonReader reader = Json.createReader(new StringReader(entity));
- JsonObject old = reader.readObject().getJsonObject("data");
- /* Change the mmtId*/
- String updatedEntity =
- old.toString().replace("statusWert\":1", "statusWert\":0");
- prot.addInfo("updated field", "statusWert");
- prot.addInfo("updated value", "1");
- prot.addInfo("updated to", "0");
- /* Send the updated messwert via put request*/
- WebTarget putTarget = client.target(baseUrl + "status/" + createdId);
- Response updated = putTarget.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .put(Entity.entity(updatedEntity, MediaType.APPLICATION_JSON));
- /* Try to parse the response*/
- JsonReader updatedReader = Json.createReader(
- new StringReader(updated.readEntity(String.class)));
- JsonObject updatedObj = updatedReader.readObject();
- /* Verify the response*/
- Assert.assertTrue(updatedObj.getBoolean("success"));
- prot.addInfo("success", updatedObj.getBoolean("success"));
- Assert.assertEquals("200", updatedObj.getString("message"));
- prot.addInfo("message", updatedObj.getString("message"));
- Assert.assertEquals(0,
- updatedObj.getJsonObject("data").getJsonNumber("statusWert").intValue());
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-
- /**
- * Test the DELETE Service.
- *
- * @param baseUrl The url pointing to the test deployment.
- */
- public final void deleteService(URL baseUrl, List<Protocol> protocol) {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("StatusService");
- prot.setType("delete");
- prot.setPassed(false);
- protocol.add(prot);
- try {
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target =
- client.target(baseUrl + "status/" + createdId);
- prot.addInfo("statusId", createdId);
- /* Delete the object with the saved id*/
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .delete();
- String entity = response.readEntity(String.class);
- /* Try to parse the response*/
- JsonReader reader = Json.createReader(new StringReader(entity));
- JsonObject respObj = reader.readObject();
- /* Verify the response*/
- Assert.assertTrue(respObj.getBoolean("success"));
- prot.addInfo("success", respObj.getBoolean("success"));
- Assert.assertEquals("200", respObj.getString("message"));
- prot.addInfo("message", respObj.getString("message"));
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-}
diff -r 3d76d476894f -r 59c51da59b30 src/test/java/de/intevation/lada/test/land/StatusTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/java/de/intevation/lada/test/land/StatusTest.java Fri Dec 18 18:01:00 2015 +0100
@@ -0,0 +1,63 @@
+package de.intevation.lada.test.land;
+
+import java.net.URL;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.json.JsonObject;
+import javax.json.JsonObjectBuilder;
+import javax.json.JsonValue;
+
+import org.junit.Assert;
+
+import de.intevation.lada.Protocol;
+
+public class StatusTest extends ServiceTest {
+
+ private JsonObject expectedById;
+ private JsonObject create;
+
+ /**
+ * @return The test protocol
+ */
+ public List<Protocol> getProtocol() {
+ return protocol;
+ }
+
+ @Override
+ public void init(
+ URL baseUrl,
+ List<Protocol> protocol
+ ) {
+ super.init(baseUrl, protocol);
+ // Attributes with timestamps
+ timestampAttributes = Arrays.asList(new String[]{
+ "datum",
+ "treeModified"
+ });
+
+ // Prepare expected object
+ JsonObject content = readJsonResource("/datasets/dbUnit_messung.json");
+ JsonObject status = content.getJsonArray("land.status_protokoll").getJsonObject(0);
+ JsonObjectBuilder builder = convertObject(status);
+ builder.add("parentModified", 1450371851654L);
+ builder.add("readonly", JsonValue.FALSE);
+ builder.add("owner", JsonValue.TRUE);
+ expectedById = builder.build();
+ Assert.assertNotNull(expectedById);
+
+ // Load object to test POST request
+ create = readJsonResource("/datasets/status.json");
+ Assert.assertNotNull(create);
+ }
+
+ public final void execute() {
+ getAll("status", "rest/status?messungsId=1000");
+ getById("status", "rest/status/1000", expectedById);
+ //update("status", "rest/status/1000", "text", "Initialer Status", "Initialer Status geändert");
+ //JsonObject created =
+ create("status", "rest/status", create);
+ //delete("status", "rest/status/" + created.getJsonObject("data").get("id"));
+ }
+
+}
diff -r 3d76d476894f -r 59c51da59b30 src/test/java/de/intevation/lada/test/land/Zusatzwert.java
--- a/src/test/java/de/intevation/lada/test/land/Zusatzwert.java Fri Dec 18 17:55:20 2015 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,335 +0,0 @@
-/* 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.land;
-
-import java.io.StringReader;
-import java.net.URL;
-import java.util.List;
-
-import javax.json.Json;
-import javax.json.JsonException;
-import javax.json.JsonObject;
-import javax.json.JsonReader;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.junit.Assert;
-
-import de.intevation.lada.BaseTest;
-import de.intevation.lada.Protocol;
-
-/**
- * Class containing test cases for zusatzwert objects.
- *
- * @author <a href="mailto:rrenkert at intevation.de">Raimund Renkert</a>
- */
-public class Zusatzwert {
-
- private static final String COMPARE =
- "{\"id\":1,\"letzteAenderung\":1335177176000,\"messfehler\":48.0," +
- "\"messwertPzs\":7.5,\"nwgZuMesswert\":null,\"probeId\":84," +
- "\"pzsId\":\"A76\",\"owner\":false,\"readonly\":false," +
- "\"treeModified\":null,\"parentModified\":null}";
-
- private static final String CREATE =
- "{\"letzteAenderung\":1335177176000,\"messfehler\":18.0," +
- "\"messwertPzs\":3.5,\"nwgZuMesswert\":null,\"probeId\":PID," +
- "\"pzsId\":\"A76\"}";
-
- private List<Protocol> protocol;
-
- private static Integer createdId;
-
- public Integer getCreatedId() {
- return createdId;
- }
-
- /**
- * @return The test protocol
- */
- public List<Protocol> getProtocol() {
- return protocol;
- }
-
- /**
- * Test the GET Service by requesting all objects.
- *
- * @param baseUrl The url pointing to the test deployment.
- */
- public final void getAllService(URL baseUrl, List<Protocol> protocol)
- throws Exception {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("ZusatzwertService");
- prot.setType("get all");
- prot.setPassed(false);
- protocol.add(prot);
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target = client.target(baseUrl + "zusatzwert");
- /* Request all objects*/
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .get();
- String entity = response.readEntity(String.class);
- try{
- /* Try to parse the response*/
- JsonReader reader = Json.createReader(new StringReader(entity));
- JsonObject content = reader.readObject();
- /* Verify the response*/
- Assert.assertTrue(content.getBoolean("success"));
- prot.addInfo("success", content.getBoolean("success"));
- Assert.assertEquals("200", content.getString("message"));
- prot.addInfo("message", content.getString("message"));
- Assert.assertNotNull(content.getJsonArray("data"));
- prot.addInfo("objects", content.getJsonArray("data").size());
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-
- /**
- * Test the GET Service by requesting a single object by id.
- *
- * @param baseUrl The url pointing to the test deployment.
- */
- public final void getByIdService(URL baseUrl, List<Protocol> protocol)
- throws Exception {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("ZusatzwertService");
- prot.setType("get by Id");
- prot.setPassed(false);
- protocol.add(prot);
- try {
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target = client.target(baseUrl + "zusatzwert/1");
- prot.addInfo("zustzwertId", 1);
- /* Request a object by id*/
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .get();
- String entity = response.readEntity(String.class);
- /* Try to parse the response*/
- JsonReader fromServiceReader =
- Json.createReader(new StringReader(entity));
- JsonObject content = fromServiceReader.readObject();
- /* Verify the response*/
- Assert.assertTrue(content.getBoolean("success"));
- prot.addInfo("success", content.getBoolean("success"));
- Assert.assertEquals("200", content.getString("message"));
- prot.addInfo("message", content.getString("message"));
- Assert.assertFalse(content.getJsonObject("data").isEmpty());
- prot.addInfo("object", "equals");
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-
- /**
- * Test the GET service using filters.
- *
- * @param baseUrl The url poining to the test deployment.
- */
- public final void filterService(URL baseUrl, List<Protocol> protocol) {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("ZusatzwertService");
- prot.setType("get by filter");
- prot.setPassed(false);
- protocol.add(prot);
- try {
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target =
- client.target(baseUrl + "zusatzwert?probeIdId=1");
- prot.addInfo("filter", "probeId=1");
- /* Request the objects using the filter*/
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .get();
- String entity = response.readEntity(String.class);
- /* Try to parse the response*/
- JsonReader reader = Json.createReader(new StringReader(entity));
- JsonObject respObj = reader.readObject();
- /* Verify the response*/
- Assert.assertTrue(respObj.getBoolean("success"));
- prot.addInfo("success", respObj.getBoolean("success"));
- Assert.assertEquals("200", respObj.getString("message"));
- prot.addInfo("message", respObj.getString("message"));
- Assert.assertNotNull(respObj.getJsonArray("data"));
- prot.addInfo("objects", respObj.getJsonArray("data").size());
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-
- /**
- * Test the CREATE Service.
- *
- * @param baseUrl The url pointing to the test deployment.
- */
- public final void createService(
- URL baseUrl,
- List<Protocol> protocol,
- Integer probeId)
- throws Exception {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("ZusatzwertService");
- prot.setType("create");
- prot.setPassed(false);
- protocol.add(prot);
- try {
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target = client.target(baseUrl + "zusatzwert");
- /* Send a post request containing a new object*/
- String zus = CREATE.replace("PID", probeId.toString());
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .post(Entity.entity(zus, MediaType.APPLICATION_JSON));
- String entity = response.readEntity(String.class);
- /* Try to parse the response*/
- JsonReader fromServiceReader =
- Json.createReader(new StringReader(entity));
- JsonObject content = fromServiceReader.readObject();
- /* Save the id*/
- createdId =
- content.getJsonObject("data").getJsonNumber("id").intValue();
- prot.addInfo("zusatzwertId", createdId);
- /* Verify the response*/
- Assert.assertTrue(content.getBoolean("success"));
- prot.addInfo("success", content.getBoolean("success"));
- Assert.assertEquals("200", content.getString("message"));
- prot.addInfo("message", content.getString("message"));
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-
- /**
- * Test the UPDATE Service.
- *
- * @param baseUrl The url pointing to the test deployment.
- */
- public final void updateService(URL baseUrl, List<Protocol> protocol)
- throws Exception {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("ZusatzwertService");
- prot.setType("update");
- prot.setPassed(false);
- protocol.add(prot);
- try {
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target =
- client.target(baseUrl + "zusatzwert/" + createdId);
- prot.addInfo("zusatzwertId", createdId);
- /* Request an object with the saved id*/
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .get();
- String entity = response.readEntity(String.class);
- /* Try to parse the response*/
- JsonReader reader = Json.createReader(new StringReader(entity));
- JsonObject old = reader.readObject().getJsonObject("data");
- /* Change the mmtId*/
- String updatedEntity =
- old.toString().replace("3.5", "14");
- prot.addInfo("updated field", "messwertPzs");
- prot.addInfo("updated value", "3.5");
- prot.addInfo("updated to", "14");
- /* Send the updated messwert via put request*/
- WebTarget putTarget = client.target(baseUrl + "zusatzwert");
- Response updated = putTarget.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .put(Entity.entity(updatedEntity, MediaType.APPLICATION_JSON));
- /* Try to parse the response*/
- JsonReader updatedReader = Json.createReader(
- new StringReader(updated.readEntity(String.class)));
- JsonObject updatedObj = updatedReader.readObject();
- /* Verify the response*/
- Assert.assertTrue(updatedObj.getBoolean("success"));
- prot.addInfo("success", updatedObj.getBoolean("success"));
- Assert.assertEquals("200", updatedObj.getString("message"));
- prot.addInfo("message", updatedObj.getString("message"));
- Assert.assertEquals(14,
- updatedObj.getJsonObject("data").getJsonNumber("messwertPzs"));
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-
- /**
- * Test the DELETE Service.
- *
- * @param baseUrl The url pointing to the test deployment.
- */
- public final void deleteService(URL baseUrl, List<Protocol> protocol) {
- System.out.print(".");
- Protocol prot = new Protocol();
- prot.setName("ZusatzwertService");
- prot.setType("delete");
- prot.setPassed(false);
- protocol.add(prot);
- try {
- /* Create a client*/
- Client client = ClientBuilder.newClient();
- WebTarget target =
- client.target(baseUrl + "zusatzwert/" + createdId);
- prot.addInfo("zusatzwertId", createdId);
- /* Delete the object with the saved id*/
- Response response = target.request()
- .header("X-SHIB-user", BaseTest.TEST_USER)
- .header("X-SHIB-roles", BaseTest.TEST_ROLES)
- .delete();
- String entity = response.readEntity(String.class);
- /* Try to parse the response*/
- JsonReader reader = Json.createReader(new StringReader(entity));
- JsonObject respObj = reader.readObject();
- /* Verify the response*/
- Assert.assertTrue(respObj.getBoolean("success"));
- prot.addInfo("success", respObj.getBoolean("success"));
- Assert.assertEquals("200", respObj.getString("message"));
- prot.addInfo("message", respObj.getString("message"));
- }
- catch(JsonException je) {
- prot.addInfo("exception", je.getMessage());
- Assert.fail(je.getMessage());
- }
- prot.setPassed(true);
- }
-}
diff -r 3d76d476894f -r 59c51da59b30 src/test/java/de/intevation/lada/test/land/ZusatzwertTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/java/de/intevation/lada/test/land/ZusatzwertTest.java Fri Dec 18 18:01:00 2015 +0100
@@ -0,0 +1,61 @@
+package de.intevation.lada.test.land;
+
+import java.net.URL;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.json.JsonObject;
+import javax.json.JsonObjectBuilder;
+import javax.json.JsonValue;
+
+import org.junit.Assert;
+
+import de.intevation.lada.Protocol;
+
+public class ZusatzwertTest extends ServiceTest {
+
+ private JsonObject expectedById;
+ private JsonObject create;
+
+ /**
+ * @return The test protocol
+ */
+ public List<Protocol> getProtocol() {
+ return protocol;
+ }
+
+ @Override
+ public void init(
+ URL baseUrl,
+ List<Protocol> protocol
+ ) {
+ super.init(baseUrl, protocol);
+ // Attributes with timestamps
+ timestampAttributes = Arrays.asList(new String[]{
+ "letzteAenderung",
+ "treeModified"
+ });
+
+ // Prepare expected probe object
+ JsonObject content = readJsonResource("/datasets/dbUnit_zusatzwert.json");
+ JsonObject messung = content.getJsonArray("land.zusatz_wert").getJsonObject(0);
+ JsonObjectBuilder builder = convertObject(messung);
+ builder.add("parentModified", 1450371851654L);
+ builder.add("readonly", JsonValue.FALSE);
+ builder.add("owner", JsonValue.TRUE);
+ expectedById = builder.build();
+ Assert.assertNotNull(expectedById);
+
+ // Load probe object to test POST request
+ create = readJsonResource("/datasets/zusatzwert.json");
+ Assert.assertNotNull(create);
+ }
+
+ public final void execute() {
+ getAll("zusatzwert", "rest/zusatzwert");
+ getById("zusatzwert", "rest/zusatzwert/1000", expectedById);
+ JsonObject created = create("zusatzwert", "rest/zusatzwert", create);
+ update("zusatzwert", "rest/zusatzwert/1000", "pzsId", "A77", "A78");
+ delete("zusatzwert", "rest/zusatzwert/" + created.getJsonObject("data").get("id"));
+ }
+}
diff -r 3d76d476894f -r 59c51da59b30 src/test/resources/datasets/cleanup.sql
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/resources/datasets/cleanup.sql Fri Dec 18 18:01:00 2015 +0100
@@ -0,0 +1,2 @@
+DELETE from land.probe where id = 1000;
+DELETE from land.messprogramm where id = 1000;
\ No newline at end of file
diff -r 3d76d476894f -r 59c51da59b30 src/test/resources/datasets/dbUnit_messprogramm.json
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/resources/datasets/dbUnit_messprogramm.json Fri Dec 18 18:01:00 2015 +0100
@@ -0,0 +1,18 @@
+{
+ "land.messprogramm": [{
+ "id": 1000,
+ "name": "testprogramm",
+ "test": false,
+ "netzbetreiber_id": "06",
+ "mst_id": "06010",
+ "datenbasis_id": 2,
+ "gem_id": "11000000",
+ "media_desk": "D: 50 90 01 06 02 05 00 00 00 00 00 00",
+ "umw_id": "N81",
+ "probenart_id": 3,
+ "probenintervall": "M",
+ "teilintervall_von": 1,
+ "teilintervall_bis": 30,
+ "letzte_aenderung": "2015-03-01 12:00:00"
+ }]
+}
diff -r 3d76d476894f -r 59c51da59b30 src/test/resources/datasets/dbUnit_messung.json
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/resources/datasets/dbUnit_messung.json Fri Dec 18 18:01:00 2015 +0100
@@ -0,0 +1,29 @@
+{
+ "land.messung": [{
+ "id": 1200,
+ "probe_id": 1000,
+ "nebenproben_nr": "T100",
+ "mmt_id": "G1",
+ "messdauer": 3600,
+ "messzeitpunkt": "2012-05-06 14:00:00",
+ "fertig": false,
+ "letzte_aenderung": "2012-05-08 12:00:00",
+ "geplant": true,
+ "tree_modified": "2012-05-09 12:00:00"
+ }],
+ "land.messung_translation": [{
+ "id": 1200,
+ "messungs_id": 1200,
+ "messungs_id_alt": 453
+ }],
+ "land.status_protokoll": [{
+ "id": 1000,
+ "erzeuger": "06010",
+ "datum": "2012-05-08 11:00:00",
+ "text": "Initialer Status",
+ "messungs_id": 1200,
+ "status_stufe": 1,
+ "status_wert": 0,
+ "tree_modified": "2012-05-09 12:00:00"
+ }]
+}
diff -r 3d76d476894f -r 59c51da59b30 src/test/resources/datasets/dbUnit_messwert.json
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/resources/datasets/dbUnit_messwert.json Fri Dec 18 18:01:00 2015 +0100
@@ -0,0 +1,14 @@
+{
+ "land.messwert":[{
+ "id": 10000,
+ "messungs_id": 1200,
+ "messgroesse_id": 29,
+ "messwert_nwg": "<",
+ "messwert": 28.0,
+ "messfehler": 3.3,
+ "nwg_zu_messwert": 2.4,
+ "meh_id": 65,
+ "grenzwertueberschreitung": false,
+ "letzte_aenderung": "2012-05-09 09:00:00"
+ }]
+}
diff -r 3d76d476894f -r 59c51da59b30 src/test/resources/datasets/dbUnit_mkommentar.json
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/resources/datasets/dbUnit_mkommentar.json Fri Dec 18 18:01:00 2015 +0100
@@ -0,0 +1,9 @@
+{
+ "land.kommentar_m": [{
+ "id":1000,
+ "erzeuger":"06010",
+ "datum":"2012-05-08 11:00:00",
+ "text":"Testkommentar",
+ "messungs_id":1200
+ }]
+}
diff -r 3d76d476894f -r 59c51da59b30 src/test/resources/datasets/dbUnit_ortszuordnung.json
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/resources/datasets/dbUnit_ortszuordnung.json Fri Dec 18 18:01:00 2015 +0100
@@ -0,0 +1,10 @@
+{
+ "land.ortszuordnung": [{
+ "id": 1000,
+ "probe_id": 1000,
+ "ort_id": 23,
+ "ortszuordnung_typ": "E",
+ "ortszusatztext": "Test",
+ "letzte_aenderung": "2012-05-07 09:00:00"
+ }]
+}
diff -r 3d76d476894f -r 59c51da59b30 src/test/resources/datasets/dbUnit_pkommentar.json
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/resources/datasets/dbUnit_pkommentar.json Fri Dec 18 18:01:00 2015 +0100
@@ -0,0 +1,9 @@
+{
+ "land.kommentar_p": [{
+ "id": 1000,
+ "erzeuger": "06010",
+ "datum": "2012-05-11 12:01:00",
+ "text": "Testkommentar",
+ "probe_id": 1000
+ }]
+}
diff -r 3d76d476894f -r 59c51da59b30 src/test/resources/datasets/dbUnit_probe.json
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/resources/datasets/dbUnit_probe.json Fri Dec 18 18:01:00 2015 +0100
@@ -0,0 +1,28 @@
+{
+ "land.probe": [{
+ "id": 1000,
+ "ba_id": "1",
+ "datenbasis_id": 2,
+ "letzte_aenderung": "2012-05-05 11:12:00",
+ "media": "Trinkwasser Zentralversorgung Oberflächenwasser aufbereitet",
+ "media_desk": "D: 59 04 01 00 05 05 01 02 00 00 00 00",
+ "mst_id": "06010",
+ "netzbetreiber_id": "06",
+ "probeentnahme_beginn": "2012-05-03 13:07:00",
+ "probenart_id": 1,
+ "test": false,
+ "umw_id":"N72",
+ "hauptproben_nr": "120510002",
+ "mp_kat": "1",
+ "mpr_id": 3749,
+ "probe_nehmer_id": 726,
+ "solldatum_beginn": "2012-05-01 16:00:00",
+ "solldatum_ende": "2012-05-05 16:00:00",
+ "tree_modified": "2012-05-08 10:00:00"
+ }],
+ "land.probe_translation": [{
+ "id": 1100,
+ "probe_id": 1000,
+ "probe_id_alt": "T001"
+ }]
+}
diff -r 3d76d476894f -r 59c51da59b30 src/test/resources/datasets/dbUnit_zusatzwert.json
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/resources/datasets/dbUnit_zusatzwert.json Fri Dec 18 18:01:00 2015 +0100
@@ -0,0 +1,11 @@
+{
+ "land.zusatz_wert": [{
+ "id": 1000,
+ "probe_id": 1000,
+ "pzs_id": "A77",
+ "messwert_pzs": 12.0,
+ "messfehler": 8.0,
+ "nwg_zu_messwert": 3.0,
+ "letzte_aenderung": "2012-05-08 14:00:00"
+ }]
+}
diff -r 3d76d476894f -r 59c51da59b30 src/test/resources/datasets/messprogramm.json
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/resources/datasets/messprogramm.json Fri Dec 18 18:01:00 2015 +0100
@@ -0,0 +1,22 @@
+{
+ "baId": null,
+ "datenbasisId": 2,
+ "gemId": "11000000",
+ "gueltigBis": null,
+ "gueltigVon": null,
+ "intervallOffset": null,
+ "letzteAenderung": 1381413048800,
+ "mediaDesk": "D: 01 01 01 01 01 01 00 00 00 00 00 00",
+ "mstId": "06010",
+ "name": "Test 1",
+ "netzbetreiberId": "06",
+ "ortId": null,
+ "probeKommentar": null,
+ "probeNehmerId": null,
+ "probenartId": 3,
+ "probenintervall": "M",
+ "teilintervallBis": 30,
+ "teilintervallVon": 1,
+ "test": false,
+ "umwId": "N11"
+}
diff -r 3d76d476894f -r 59c51da59b30 src/test/resources/datasets/messung.json
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/resources/datasets/messung.json Fri Dec 18 18:01:00 2015 +0100
@@ -0,0 +1,9 @@
+{
+ "probeId":"1000",
+ "mmtId":"A4",
+ "nebenprobenNr":"10R1",
+ "messdauer":10,
+ "fertig":false,
+ "geplant":true,
+ "messzeitpunkt":"2015-02-09T10:58:36"
+}
diff -r 3d76d476894f -r 59c51da59b30 src/test/resources/datasets/messwert.json
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/resources/datasets/messwert.json Fri Dec 18 18:01:00 2015 +0100
@@ -0,0 +1,11 @@
+{
+ "messungsId": 1200,
+ "messgroesseId": 242,
+ "messwert":1,
+ "messwertNwg":"",
+ "messfehler":1,
+ "nwgZuMesswert":3,
+ "mehId":207,
+ "grenzwertueberschreitung":false
+}
+
diff -r 3d76d476894f -r 59c51da59b30 src/test/resources/datasets/mkommentar.json
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/resources/datasets/mkommentar.json Fri Dec 18 18:01:00 2015 +0100
@@ -0,0 +1,7 @@
+{
+ "messungsId":1200,
+ "erzeuger":"06010",
+ "text":"test",
+ "datum":"2015-02-09T10:58:36"
+}
+
diff -r 3d76d476894f -r 59c51da59b30 src/test/resources/datasets/ortszuordnung.json
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/resources/datasets/ortszuordnung.json Fri Dec 18 18:01:00 2015 +0100
@@ -0,0 +1,6 @@
+{
+ "ortszuordnungTyp": "Z",
+ "ortszusatztext": "textzusatz",
+ "probeId": 1000,
+ "ortId":213
+}
diff -r 3d76d476894f -r 59c51da59b30 src/test/resources/datasets/pkommentar.json
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/resources/datasets/pkommentar.json Fri Dec 18 18:01:00 2015 +0100
@@ -0,0 +1,6 @@
+{
+ "probeId": "1000",
+ "erzeuger": "06010",
+ "text": "test",
+ "datum": "2015-02-09T10:58:36"
+}
diff -r 3d76d476894f -r 59c51da59b30 src/test/resources/datasets/probe.json
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/resources/datasets/probe.json Fri Dec 18 18:01:00 2015 +0100
@@ -0,0 +1,23 @@
+{
+ "baId":"1",
+ "datenbasisId":2,
+ "erzeugerId":"",
+ "hauptprobenNr":"4554554550",
+ "media":"",
+ "mediaDesk": "",
+ "mittelungsdauer":"",
+ "mpKat":"",
+ "mplId":"",
+ "mprId":"",
+ "mstId":"06010",
+ "netzbetreiberId":"11",
+ "probeNehmerId":3,
+ "probenartId":1,
+ "test":true,
+ "umwId":"A11",
+ "letzteAenderung":"2015-02-09T10:58:36",
+ "probeentnahmeBeginn":"2015-02-08T10:58:36",
+ "probeentnahmeEnde":"2015-02-09T10:58:36",
+ "solldatumBeginn":"2015-02-09T10:58:36",
+ "solldatumEnde":"2015-02-09T10:58:36"
+}
diff -r 3d76d476894f -r 59c51da59b30 src/test/resources/datasets/status.json
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/resources/datasets/status.json Fri Dec 18 18:01:00 2015 +0100
@@ -0,0 +1,9 @@
+{
+ "erzeuger": "06010",
+ "messungsId": 1200,
+ "statusStufe":1,
+ "statusWert":2,
+ "datum": "2012-05-10T09:09:00",
+ "text": "Status geändert"
+}
+
diff -r 3d76d476894f -r 59c51da59b30 src/test/resources/datasets/zusatzwert.json
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/resources/datasets/zusatzwert.json Fri Dec 18 18:01:00 2015 +0100
@@ -0,0 +1,7 @@
+{
+ "messfehler":18.0,
+ "messwertPzs":3.5,
+ "nwgZuMesswert":null,
+ "probeId":1000,
+ "pzsId":"A76"
+}
diff -r 3d76d476894f -r 59c51da59b30 src/test/resources/messprogrammquery.json
--- a/src/test/resources/messprogrammquery.json Fri Dec 18 17:55:20 2015 +0100
+++ b/src/test/resources/messprogrammquery.json Fri Dec 18 18:01:00 2015 +0100
@@ -1,6 +1,7 @@
[
{ "id": "1",
"name": "Kein Filter",
+ "type": "messprogramm",
"description": "Abfrage der Messprogramme ohne Filter",
"sql": "select m.id as id, m.name as name, m.mst_id as mstId, m.umw_id as umwId from land.messprogramm m",
"result": [
diff -r 3d76d476894f -r 59c51da59b30 src/test/resources/probequery.json
--- a/src/test/resources/probequery.json Fri Dec 18 17:55:20 2015 +0100
+++ b/src/test/resources/probequery.json Fri Dec 18 18:01:00 2015 +0100
@@ -3,6 +3,7 @@
"name": "Kein Filter",
"description": "Abfrage der Proben ohne Filter",
"sql": "select p.id as id, pt.probe_id_alt as probeId, p.mst_id as mstId, p.umw_id as umwId from land.probe p join land.probe_translation pt on p.id = pt.probe_id",
+ "type": "probe",
"result": [
{"dataIndex": "probeId", "header": "ProbeId", "width": 100},
{"dataIndex": "mstId", "header": "MST", "width": 100},
@@ -15,6 +16,7 @@
"name": "MST und UMW",
"description": "Abfrage der Proben gefiltert nach Messtellen ID und ID des Umweltbereichs",
"sql": "select p.id as id, pt.probe_id_alt as probeId, p.mst_id as mstId, p.umw_id as umwId from land.probe p join land.probe_translation pt on p.id = pt.probe_id where (p.mst_id = :mst_id OR '' = :mst_id) and (p.umw_id = :umw_id OR '' = :umw_id)",
+ "type": "probe",
"result": [
{"dataIndex": "probeId", "header": "ProbeId", "width": 100},
{"dataIndex": "mstId", "header": "MST", "width": 100},
@@ -29,6 +31,7 @@
"name": "Proben pro Land",
"description": "Proben gefiltert nach Ländern",
"sql": "select p.id as id, pt.probe_id_alt as probeId, p.netzbetreiber_id as netzbetreiberId, p.mst_id as mstId, p.umw_id as umwId, p.hauptproben_nr as hauptprobenNr from land.probe p join land.probe_translation pt on p.id = pt.probe_id where (netzbetreiber_id = :netz OR '' = :netz)",
+ "type": "probe",
"result": [
{"dataIndex": "probeId", "header": "ProbeId", "width": 100},
{"dataIndex": "netzbetreiberId", "header": "Land", "width": 100},
@@ -44,6 +47,7 @@
"name": "alle Proben mit Ort",
"description": "alle Proben mit Entnahmeort",
"sql": "select p.id as id, pt.probe_id_alt as probeId, p.netzbetreiber_id as netzbetreiberId, p.mst_id as mstId, p.umw_id as umwId, p.hauptproben_nr as hauptprobenNr, so.gem_id as gemId, v.bezeichnung as bezeichnung from land.probe p join land.probe_translation pt on p.id = pt.probe_id left outer join land.ort o on (p.id = o.probe_id) left outer join stammdaten.ort so on (o.ort_id = so.id) left outer join stammdaten.verwaltungseinheit v on (so.gem_id = v.id) where o.orts_typ = 'E' or o.orts_typ is null",
+ "type": "probe",
"result": [
{"dataIndex": "probeId", "header": "ProbeId", "width": 100},
{"dataIndex": "netzbetreiberId", "header": "Land", "width": 50},
@@ -60,6 +64,7 @@
"name": "Proben pro Land und UMW (Multiselect)",
"description": "Abfrage aller Proben gefiltert pro Land und Umweltbereich (mit Mehrfachauswahl)",
"sql": "select p.id as id, pt.probe_id_alt as probeId, p.netzbetreiber_id as netzbetreiberId, p.mst_id as mstId, to_char(p.probeentnahme_beginn,'YYYY-mm-dd HH24:MI') entnahmeVon, to_char(p.probeentnahme_ende,'YYYY-mm-dd HH24:MI') entnahmeBis, p.umw_id as umwId, p.hauptproben_nr as hauptprobenNr, o.orts_typ as ortsTyp, so.gem_id as gemId, v.bezeichnung as bezeichnung from land.probe p join land.probe_translation pt on p.id = pt.probe_id left outer join land.ort o on (p.id = o.probe_id) left outer join stammdaten.ort so on (o.ort_id = so.id) left outer join stammdaten.verwaltungseinheit v on (so.gem_id = v.id) where (o.orts_typ = 'E' or o.orts_typ is null) and (p.netzbetreiber_id = :netz OR '' =:netz) and (p.umw_id similar to (:umw_id) OR '' = :umw_id)",
+ "type": "probe",
"result": [
{"dataIndex": "probeId", "header": "ProbeId", "width": 100},
{"dataIndex": "netzbetreiberId", "header": "Land", "width": 50},
diff -r 3d76d476894f -r 59c51da59b30 src/test/resources/shibboleth.properties
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/resources/shibboleth.properties Fri Dec 18 18:01:00 2015 +0100
@@ -0,0 +1,2 @@
+applicationId=default
+enabled=false
More information about the Lada-commits
mailing list