[Lada-commits] [PATCH 6 of 7] Added, reordered and fixed tests

Wald Commits scm-commit at wald.intevation.org
Wed Nov 18 15:40:13 CET 2015


# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1447857561 -3600
# Node ID 4262acdd466da177eb93910a4557e289de6e625e
# Parent  dea5ed4b7fa403fc9ca0fa4e73ca7d63adaabec2
Added, reordered and fixed tests.

diff -r dea5ed4b7fa4 -r 4262acdd466d src/test/java/de/intevation/lada/BaseTest.java
--- a/src/test/java/de/intevation/lada/BaseTest.java	Wed Nov 18 15:38:47 2015 +0100
+++ b/src/test/java/de/intevation/lada/BaseTest.java	Wed Nov 18 15:39:21 2015 +0100
@@ -28,7 +28,7 @@
 
     public static String TEST_USER = "testeins";
 
-    public static String TEST_ROLES = "cn=Imis-World, cn=mst_06010, cn=mst_11010";
+    public static String TEST_ROLES = "cn=Imis-World, cn=mst_06010, cn=mst_11010, cn=mst_11010_status";
 
     private static Logger logger = Logger.getLogger(BaseTest.class);
 
diff -r dea5ed4b7fa4 -r 4262acdd466d src/test/java/de/intevation/lada/LadaLandTest.java
--- a/src/test/java/de/intevation/lada/LadaLandTest.java	Wed Nov 18 15:38:47 2015 +0100
+++ b/src/test/java/de/intevation/lada/LadaLandTest.java	Wed Nov 18 15:39:21 2015 +0100
@@ -17,7 +17,6 @@
 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;
@@ -270,7 +269,6 @@
      * Testing GET Services.
      */
     @Test
-    @Ignore
     @RunAsClient
     public final void testA_StatusGetAllServices(@ArquillianResource URL baseUrl)
     throws Exception {
@@ -281,7 +279,6 @@
      * Testing GET Services.
      */
     @Test
-    @Ignore
     @RunAsClient
     public final void testA_StatusGetByIdServices(@ArquillianResource URL baseUrl)
     throws Exception {
@@ -292,7 +289,6 @@
      * Testing GET Services.
      */
     @Test
-    @Ignore
     @RunAsClient
     public final void testA_StatusGetFilterServices(@ArquillianResource URL baseUrl)
     throws Exception {
@@ -393,10 +389,6 @@
             baseUrl,
             testProtocol,
             this.messungTest.getCreatedMessungId());
-        //this.statusTest.createService(
-        //    baseUrl,
-        //    testProtocol,
-        //    this.messungTest.getCreatedMessungId());
         this.messprogrammTest.createService(
             baseUrl,
             testProtocol);
@@ -472,12 +464,21 @@
      * Testing UPDATE services.
      */
     @Test
-    @Ignore
     @RunAsClient
-    public final void testC_statusUpdateService(@ArquillianResource URL baseUrl)
+    public final void testC_messprogrammUpdateService(@ArquillianResource URL baseUrl)
     throws Exception {
         Assert.assertNotNull(this.ortTest.getCreatedId());
-        this.statusTest.updateService(baseUrl, testProtocol);
+        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());
     }
 
     /**
@@ -485,10 +486,10 @@
      */
     @Test
     @RunAsClient
-    public final void testC_messprogrammUpdateService(@ArquillianResource URL baseUrl)
+    public final void testC_zstatusUpdateService(@ArquillianResource URL baseUrl)
     throws Exception {
         Assert.assertNotNull(this.ortTest.getCreatedId());
-        this.messprogrammTest.updateService(baseUrl, testProtocol);
+        this.statusTest.updateService(baseUrl, testProtocol);
     }
 
     /**
@@ -498,10 +499,10 @@
     @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.statusTest.getCreatedId());
-        // this.statusTest.deleteService(baseUrl, testProtocol);
         Assert.assertNotNull(this.ortTest.getCreatedId());
         this.ortTest.deleteService(baseUrl, testProtocol);
         Assert.assertNotNull(this.messwertTest.getCreatedMesswertId());
diff -r dea5ed4b7fa4 -r 4262acdd466d src/test/java/de/intevation/lada/test/land/KommentarM.java
--- a/src/test/java/de/intevation/lada/test/land/KommentarM.java	Wed Nov 18 15:38:47 2015 +0100
+++ b/src/test/java/de/intevation/lada/test/land/KommentarM.java	Wed Nov 18 15:39:21 2015 +0100
@@ -9,7 +9,9 @@
 
 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;
@@ -36,7 +38,7 @@
 public class KommentarM {
 
     private static final String COMPARE_KOMMENTARM =
-        "{\"messungsId\":5,\"datum\":1336627500000,\"erzeuger\":\"12010\"," +
+        "{\"messungsId\":5,\"datum\":1336634700000,\"erzeuger\":\"12010\"," +
         "\"id\":478,\"text\":\"Hofladen Lenzen geschlossen\",\"owner\":false," +
         "\"readonly\":true}";
 
diff -r dea5ed4b7fa4 -r 4262acdd466d src/test/java/de/intevation/lada/test/land/KommentarP.java
--- a/src/test/java/de/intevation/lada/test/land/KommentarP.java	Wed Nov 18 15:38:47 2015 +0100
+++ b/src/test/java/de/intevation/lada/test/land/KommentarP.java	Wed Nov 18 15:39:21 2015 +0100
@@ -36,10 +36,10 @@
 public class KommentarP {
 
     private static final String COMPARE_KOMMENTARP =
-        "{\"datum\":1321002077000,\"erzeuger\":\"06010\",\"id\":1,\"text\":" +
+        "{\"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\":true}";
+        "\"readonly\":false}";
 
     private static final String CREATE_KOMMENTARP =
         "{\"probeId\":\"PID\",\"erzeuger\":\"11010\",\"text\":" +
diff -r dea5ed4b7fa4 -r 4262acdd466d src/test/java/de/intevation/lada/test/land/Messprogramm.java
--- a/src/test/java/de/intevation/lada/test/land/Messprogramm.java	Wed Nov 18 15:38:47 2015 +0100
+++ b/src/test/java/de/intevation/lada/test/land/Messprogramm.java	Wed Nov 18 15:39:21 2015 +0100
@@ -37,7 +37,7 @@
     private static final String COMPARE = "{\"id\":1,\"baId\":null," +
         "\"datenbasisId\":2,\"gemId\":\"11000000\",\"gueltigBis\":null," +
         "\"gueltigVon\":null,\"intervallOffset\":null,\"letzteAenderung\":" +
-        "1381413048800,\"mediaDesk\":\"D: 50 90 01 06 02 05 00 00 00 00 00 00\"," +
+        "1381420248800,\"mediaDesk\":\"D: 50 90 01 06 02 05 00 00 00 00 00 00\"," +
         "\"mstId\":\"11010\",\"name\":null,\"netzbetreiberId\":\"11\"," +
         "\"ortId\":null,\"probeKommentar\":null,\"probeNehmerId\":null," +
         "\"probenartId\":3,\"probenintervall\":\"M\",\"teilintervallBis\":30," +
diff -r dea5ed4b7fa4 -r 4262acdd466d src/test/java/de/intevation/lada/test/land/Probe.java
--- a/src/test/java/de/intevation/lada/test/land/Probe.java	Wed Nov 18 15:38:47 2015 +0100
+++ b/src/test/java/de/intevation/lada/test/land/Probe.java	Wed Nov 18 15:39:21 2015 +0100
@@ -275,11 +275,11 @@
             JsonObject oldProbe = reader.readObject().getJsonObject("data");
             /* Change the hauptprobenNr*/
             String updatedEntity =
-                oldProbe.toString().replace("4554567890", "2345678901");
+                oldProbe.toString().replace("4554567890", "2345678911");
             prot.addInfo("updated datafield", "hauptprobenNr");
             prot.addInfo("updated value", "1234567890");
-            prot.addInfo("updated to", "2345678901");
-            /* Send the updated probe via put reauest*/
+            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)
@@ -294,7 +294,7 @@
             prot.addInfo("success", updatedProbe.getBoolean("success"));
             Assert.assertEquals("200", updatedProbe.getString("message"));
             prot.addInfo("message", updatedProbe.getString("message"));
-            Assert.assertEquals("2345678901",
+            Assert.assertEquals("2345678911",
                 updatedProbe.getJsonObject("data").getString("hauptprobenNr"));
         }
         catch(JsonException je) {
diff -r dea5ed4b7fa4 -r 4262acdd466d src/test/java/de/intevation/lada/test/land/Status.java
--- a/src/test/java/de/intevation/lada/test/land/Status.java	Wed Nov 18 15:38:47 2015 +0100
+++ b/src/test/java/de/intevation/lada/test/land/Status.java	Wed Nov 18 15:39:21 2015 +0100
@@ -24,6 +24,7 @@
 
 import org.junit.Assert;
 
+import de.intevation.lada.BaseTest;
 import de.intevation.lada.Protocol;
 
 /**
@@ -40,8 +41,9 @@
         "\"sdatum\":1373846400000,\"skommentar\":\"test\"}";
 
     private static final String CREATE =
-        "{\"erzeuger\":\"06010\",\"messungsId\":MID,\"status\":3," +
-        "\"sdatum\":1373846400000,\"skommentar\":\"status3\"}";
+        "{\"erzeuger\":\"06010\",\"messungsId\":MID,\"statusStufe\":1," +
+        "\"statusWert\":1," +
+        "\"datum\":1373846400000,\"text\":\"status test\"}";
 
     private List<Protocol> protocol;
 
@@ -75,7 +77,10 @@
         Client client = ClientBuilder.newClient();
         WebTarget target = client.target(baseUrl + "status");
         /* Request all objects*/
-        Response response = target.request().get();
+        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*/
@@ -112,10 +117,13 @@
         try {
             /* Create a client*/
             Client client = ClientBuilder.newClient();
-            WebTarget target = client.target(baseUrl + "status/1");
+            WebTarget target = client.target(baseUrl + "status/511");
             prot.addInfo("statusId", 1);
             /* Request a object by id*/
-            Response response = target.request().get();
+            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 =
@@ -155,7 +163,10 @@
                 client.target(baseUrl + "status?messungId=1");
             prot.addInfo("filter", "messungId=1");
             /* Request the objects using the filter*/
-            Response response = target.request().get();
+            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));
@@ -197,8 +208,10 @@
             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().post(
-                    Entity.entity(stat, MediaType.APPLICATION_JSON));
+            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 =
@@ -241,21 +254,27 @@
                 client.target(baseUrl + "status/" + createdId);
             prot.addInfo("statusId", createdId);
             /* Request an object with the saved id*/
-            Response response = target.request().get();
+            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("status3", "status3updated");
-            prot.addInfo("updated field", "skommentar");
-            prot.addInfo("updated value", "status3");
-            prot.addInfo("updated to", "status3updated");
+                old.toString().replace("statusWert\":1", "statusWert\":0");
+            System.out.println(updatedEntity);
+            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().put(
-                Entity.entity(updatedEntity, MediaType.APPLICATION_JSON));
+            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)));
@@ -265,8 +284,8 @@
             prot.addInfo("success", updatedObj.getBoolean("success"));
             Assert.assertEquals("200", updatedObj.getString("message"));
             prot.addInfo("message", updatedObj.getString("message"));
-            Assert.assertEquals("status3updated",
-                updatedObj.getJsonObject("data").getString("skommentar"));
+            Assert.assertEquals(0,
+                updatedObj.getJsonObject("data").getJsonNumber("statusWert").intValue());
         }
         catch(JsonException je) {
             prot.addInfo("exception", je.getMessage());
@@ -294,7 +313,10 @@
                 client.target(baseUrl + "status/" + createdId);
             prot.addInfo("statusId", createdId);
             /* Delete the object with the saved id*/
-            Response response = target.request().delete();
+            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));


More information about the Lada-commits mailing list