changeset 977:aba3a5384c69

Use a minimal set of master data based on empty database for tests.
author Tom Gottfried <tom@intevation.de>
date Tue, 14 Jun 2016 18:30:41 +0200
parents 01ce190079e5
children 1a3a3996e072
files README.markdown src/test/java/de/intevation/lada/BaseTest.java src/test/java/de/intevation/lada/StammdatenTest.java src/test/resources/datasets/clean_and_seed.sql src/test/resources/datasets/cleanup.sql
diffstat 5 files changed, 63 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/README.markdown	Wed Jun 08 12:56:37 2016 +0200
+++ b/README.markdown	Tue Jun 14 18:30:41 2016 +0200
@@ -74,6 +74,12 @@
 
  $ mvn -Premote-test clean test
 
+und benötigt eine leere Datenbank, die z.B. mit
+
+ $ ./setup-db.sh -cn
+
+angelegt werden kann.
+
 Dokumenation
 ------------
 Die Entwicklerdokumentation (Javadoc) kann mit dem folgenden Befehl im
--- a/src/test/java/de/intevation/lada/BaseTest.java	Wed Jun 08 12:56:37 2016 +0200
+++ b/src/test/java/de/intevation/lada/BaseTest.java	Tue Jun 14 18:30:41 2016 +0200
@@ -28,7 +28,7 @@
 
     public static String TEST_USER = "testeins";
 
-    public static String TEST_ROLES = "cn=Imis-World, cn=mst_06010, cn=mst_11010, cn=mst_06_status, cn=land_06_stamm";
+    public static String TEST_ROLES = "cn=mst_06_status, cn=land_06_stamm";
 
     private static Logger logger = Logger.getLogger(BaseTest.class);
 
--- a/src/test/java/de/intevation/lada/StammdatenTest.java	Wed Jun 08 12:56:37 2016 +0200
+++ b/src/test/java/de/intevation/lada/StammdatenTest.java	Tue Jun 14 18:30:41 2016 +0200
@@ -17,6 +17,7 @@
 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.ApplyScriptBefore;
 import org.jboss.arquillian.persistence.Cleanup;
 import org.jboss.arquillian.persistence.DataSource;
 import org.jboss.arquillian.persistence.TestExecutionPhase;
@@ -47,6 +48,7 @@
  */
 @RunWith(Arquillian.class)
 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
+@ApplyScriptBefore("datasets/clean_and_seed.sql")
 public class StammdatenTest extends BaseTest {
 
     private static Logger logger = Logger.getLogger(StammdatenTest.class);
@@ -316,7 +318,7 @@
     @Test
     @RunAsClient
     public final void testKoordinatenartById(@ArquillianResource URL baseUrl) {
-        stammdatenTest.getById(baseUrl, "koordinatenart", 2, testProtocol);
+        stammdatenTest.getById(baseUrl, "koordinatenart", 5, testProtocol);
     }
 
     @Test
@@ -328,7 +330,7 @@
     @Test
     @RunAsClient
     public final void testStaatById(@ArquillianResource URL baseUrl) {
-        stammdatenTest.getById(baseUrl, "staat", 322, testProtocol);
+        stammdatenTest.getById(baseUrl, "staat", 0, testProtocol);
     }
 
     @Test
@@ -352,6 +354,7 @@
     @Test
     @RunAsClient
     public final void testVerwaltungseinheitById(@ArquillianResource URL baseUrl) {
-        stammdatenTest.getById(baseUrl, "verwaltungseinheit", "09575134", testProtocol);
+        stammdatenTest.getById(baseUrl, "verwaltungseinheit",
+            "11000000", testProtocol);
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/resources/datasets/clean_and_seed.sql	Tue Jun 14 18:30:41 2016 +0200
@@ -0,0 +1,50 @@
+SET search_path TO stammdaten;
+
+-- minimal master data to make interface tests runnable
+DELETE FROM auth;
+DELETE FROM ort;
+DELETE FROM ort_typ;
+DELETE FROM pflicht_messgroesse;
+DELETE FROM datenbasis;
+DELETE FROM mess_einheit;
+DELETE FROM messgroesse;
+DELETE FROM mess_methode;
+DELETE FROM datensatz_erzeuger;
+DELETE FROM mess_stelle;
+DELETE FROM probenehmer;
+DELETE FROM messprogramm_kategorie;
+DELETE FROM netz_betreiber;
+DELETE FROM probenart;
+DELETE FROM proben_zusatz;
+DELETE FROM koordinaten_art;
+DELETE FROM staat;
+DELETE FROM umwelt;
+DELETE FROM verwaltungseinheit;
+
+-- seed
+-- minimal master data to make interface tests runnable
+INSERT INTO ort_typ (id) VALUES (1);
+INSERT INTO datenbasis (id) VALUES (9);
+INSERT INTO mess_einheit (id) VALUES (207);
+INSERT INTO messgroesse (id, messgroesse) VALUES (56, 'Mangan');
+INSERT INTO mess_methode (id) VALUES ('GI');
+INSERT INTO netz_betreiber (id) VALUES ('06');
+INSERT INTO mess_stelle (id, netzbetreiber_id) VALUES ('06010', '06');
+INSERT INTO pflicht_messgroesse (id, datenbasis_id) VALUES (33, 9);
+INSERT INTO probenart (id, probenart, probenart_eudf_id) VALUES (1, 'E', 'A');
+INSERT INTO proben_zusatz (id, beschreibung, zusatzwert)
+       VALUES ('A74', 'Volumenstrom', 'VOLSTR');
+INSERT INTO koordinaten_art (id) VALUES (5);
+INSERT INTO staat (id, staat, hkl_id, staat_iso)
+       VALUES (0, 'Deutschland', 0, 'DE');
+INSERT INTO umwelt (id, umwelt_bereich) VALUES ('L6', 'Spurenmessung Luft');
+INSERT INTO verwaltungseinheit (
+            id, bundesland, bezeichnung,
+            is_bundesland, is_gemeinde, is_landkreis, is_regbezirk)
+       VALUES ('11000000', '11000000', 'Berlin', 1, 1, 1, 0);
+
+-- authorization data needed for tests
+INSERT INTO auth (ldap_group, netzbetreiber_id, mst_id, funktion_id)
+       VALUES ('mst_06_status', '06', '06010', 1);
+INSERT INTO auth (ldap_group, netzbetreiber_id, funktion_id)
+       VALUES ('land_06_stamm', '06', 4);
--- a/src/test/resources/datasets/cleanup.sql	Wed Jun 08 12:56:37 2016 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-DELETE FROM land.probe WHERE id = 1000;
-DELETE FROM land.messprogramm WHERE id = 1000;
-DELETE FROM stammdaten.datensatz_erzeuger WHERE id = 1000;
-DELETE FROM stammdaten.probenehmer WHERE id = 1000;
-DELETE FROM stammdaten.messprogramm_kategorie WHERE id = 1000;
-DELETE FROM stammdaten.ort WHERE id = 1000;
\ No newline at end of file
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)