changeset 9226:83aee0942eae

JUnit-Tests - tkh works
author gernotbelger
date Wed, 04 Jul 2018 17:14:16 +0200
parents 001a8ed1e71d
children 84397da33d17
files gwt-client/src/test/java/test/AbstractModuleRunner.java gwt-client/src/test/java/test/BerechnungsartenTester.java gwt-client/src/test/java/test/RunnerCreatorHelper.java gwt-client/src/test/java/test/SimpleRecommendation.java gwt-client/src/test/java/test/SinfoTkhRunner.java
diffstat 5 files changed, 123 insertions(+), 81 deletions(-) [+]
line wrap: on
line diff
--- a/gwt-client/src/test/java/test/AbstractModuleRunner.java	Wed Jul 04 17:13:31 2018 +0200
+++ b/gwt-client/src/test/java/test/AbstractModuleRunner.java	Wed Jul 04 17:14:16 2018 +0200
@@ -74,7 +74,7 @@
     private static final String exportFileDir = "D:" + File.separator;
     private static final String IGNORE_ERSTELLDATUM = "# Datum der Erstellung";
     private static final String IGNORE_FLYS_VERSION = "# FLYS-Version:";
-    private static final String IGNORE_BEARBEITER = "# Bearbeiter:";
+    private static final String IGNORE_BEARBEITER = "NEIN_DOCH_NICHT";// "# Bearbeiter:";
 
     private final String username;
     private final String password;
@@ -183,7 +183,7 @@
         return "";
     }
 
-    private final void feed(final Data[] data) throws ServerException, ConnectionException {
+    protected final void feed(final Data[] data) throws ServerException, ConnectionException {
         final Document feed = ClientProtocolUtils.newFeedDocument(getArtifact().getUuid(), getArtifact().getHash(), createKVP(data));
         final Document description = (Document) this.client.feed(
                 new org.dive4elements.artifacts.httpclient.objects.Artifact(getArtifact().getUuid(), getArtifact().getHash()), feed,
@@ -329,12 +329,17 @@
 
     protected final void export(final boolean exportToFile) throws IOException, ServerException {
         final OutputMode[] modes = getArtifact().getArtifactDescription().getOutputModes();
+        boolean exportFacetCreated = false;
         if (modes != null) {
             for (final OutputMode mode : modes) {
-                if (mode.getDescription().contains("_export"))
+                if (mode.getDescription().contains("_export")) {
                     assertAndWriteToFile(mode.getName(), exportToFile);
+                    exportFacetCreated = true;
+                }
             }
+
         }
+        assert (exportFacetCreated == true);
     }
 
     protected final String getRecommendationPairString(final SimpleRecommendation rec1, final SimpleRecommendation rec2)
--- a/gwt-client/src/test/java/test/BerechnungsartenTester.java	Wed Jul 04 17:13:31 2018 +0200
+++ b/gwt-client/src/test/java/test/BerechnungsartenTester.java	Wed Jul 04 17:14:16 2018 +0200
@@ -1,13 +1,5 @@
 package test;
 
-/*
- * Copyright (c) 2010 by Intevation GmbH
- *
- * This program is free software under the LGPL (>=v2.1)
- * Read the file LGPL.txt coming with the software for details
- * or visit http://www.gnu.org/licenses/ if it does not exist.
- */
-
 import java.io.IOException;
 
 import org.dive4elements.artifacts.httpclient.exceptions.ConnectionException;
@@ -20,11 +12,11 @@
 
 // REMARK: ignored, because maven will auto-test all tests, but this one needs a running river-artifacts
 // For running the JUunit test, the annotation @Ignore has to be disabled
-// @Ignore
+@Ignore
 public class BerechnungsartenTester {
 
     public static enum CalcMode {
-        sinfo_calc_flow_depth, sinfo_calc_flow_depth_development, sinfo_calc_flow_depth_minmax, sinfo_calc_collision, Transportkörperhöhen, sinfo_calc_flood_duration
+        sinfo_calc_flow_depth, sinfo_calc_flow_depth_development, sinfo_calc_flow_depth_minmax, sinfo_calc_collision, sinfo_calc_transport_bodies_heights, sinfo_calc_flood_duration
     };
 
     public static enum River {
@@ -33,14 +25,17 @@
 
     public static enum FilenameMapper {
 
-        HELLO_WORLD_FILE("/sinfo/flowdepthminmax/sinfo_flowdepthminmax_export.csv"), //
+        FT_MINMAX_RHEIN_1_FILE("/sinfo/flowdepthminmax/sinfo_minmaxft_01.csv"), //
+        FT_MINMAX_ELBE_2_FILE("/sinfo/flowdepthminmax/sinfo_minmaxft_02.csv"), //
 
-        // Schäfer-Tests:
         FT_RHEIN_1_FILE("/sinfo/flowdepth/sinfo_ft_01.csv"), //
-        FT_RHEIN_3_FILE("/sinfo/flowdepth/sinfo_ft_03.csv"), //
+        FT_RHEIN_2_FILE("/sinfo/flowdepth/sinfo_ft_02.csv"), //
 
         FTE_ELBE_FILE("/sinfo/flowdepthdevelopment/sinfo_fte_01.csv"), //
-        FTE_RHEIN_FILE("/sinfo/flowdepthdevelopment/sinfo_fte_02.csv");
+        FTE_RHEIN_FILE("/sinfo/flowdepthdevelopment/sinfo_fte_02.csv"),
+
+        TKH_1_ELBE_FILE("/sinfo/flowdepthtkh/sinfo_tkh_01.csv"), //
+        TKH_2_RHEIN_FILE("/sinfo/flowdepthtkh/sinfo_tkh_02.csv");
 
         private final String filename;
 
@@ -57,16 +52,22 @@
         return null;
     }
 
-    /* FLOWDEPTH MIN MAX */
-    @Test
-    public void testHelloWorld() throws ServerException, IOException {
-
-        /* Hello World Test */
-        RunnerCreatorHelper.createSinfoFlowdepthMinMaxTest(FilenameMapper.HELLO_WORLD_FILE, 10, 100, River.Beispielfluss)
-                .runTest(overrideFileExport() != null ? overrideFileExport() : true);
-    }
-
-    /* FLOWDEPTH */
+    /* DO NOT DELETE FLOWDEPTH MIN MAX -used to work */
+    // @Test
+    // public void testFTMINMAX1() throws ServerException, IOException {
+    //
+    // RunnerCreatorHelper.createSinfoFlowdepthMinMaxTest(FilenameMapper.FT_MINMAX_RHEIN_1_FILE, 430, 450, River.Rhein)
+    // .runTest(overrideFileExport() != null ? overrideFileExport() : true);
+    // }
+    //
+    // @Test
+    // public void testFTMINMAX2() throws ServerException, IOException {
+    //
+    // RunnerCreatorHelper.createSinfoFlowdepthMinMaxTest(FilenameMapper.FT_MINMAX_ELBE_2_FILE, 0, 90, River.Elbe)
+    // .runTest(overrideFileExport() != null ? overrideFileExport() : true);
+    // }
+    //
+    /* DO NOT DELETE FLOWDEPTH - used to work */
     @Test
     public void testRhein1FT() throws ConnectionException, ServerException, IOException {
 
@@ -79,48 +80,64 @@
     }
 
     @Test
-    public void testRhein3FT() throws ConnectionException, ServerException, IOException {
+    public void testRhein2FT() throws ConnectionException, ServerException, IOException {
         RunnerCreatorHelper
-                .createSinfoFlowdepthTest(FilenameMapper.FT_RHEIN_3_FILE, 655, 675, River.Rhein, true,
+                .createSinfoFlowdepthTest(FilenameMapper.FT_RHEIN_2_FILE, 655, 675, River.Rhein, true,
                         new SimpleRecommendation("staticwqkms", "fixations-wstv-0-323", "longitudinal_section"),
                         new SimpleRecommendation("bedheight", "bedheight-soundings-92-2004-NIEDERRHEIN_QP-2004_Epoche_NHN", "longitudinal_section"))
                 .runTest(overrideFileExport() != null ? overrideFileExport() : true);
     }
 
-    /* FLOWDEPTH DEVELOPMENT */
-
-    @Test
-    public void testElbeFTE() throws ConnectionException, ServerException, IOException {
-        RunnerCreatorHelper.createSinfoFlowdepthDevelopmentTest(FilenameMapper.FTE_ELBE_FILE, 210, 230, River.Elbe,
-                // current
-                new SimpleRecommendation("staticwqkms", "fixations-wstv-0-196", "longitudinal_section", "05.05.2008"), // sicher
-                new SimpleRecommendation("bedheight", "bedheight-soundings-66-2008-FP-QP-2008",
-                        // "bedheight-single-66-2008-MW-FP-QP-2008",
-                        "longitudinal_section"),
+    /* DO NOT DELETE FLOWDEPTH DEVELOPMENT - used to work */
 
-                // historical
-                new SimpleRecommendation("staticwqkms", "fixations-wstv-0-186", "longitudinal_section", "18.03.1997"), // sicher
-                new SimpleRecommendation("bedheight", "bedheight-soundings-70-1995-QP-1995",
-                        // "bedheight-single-70-1995-MW-QP-1995",
-                        "longitudinal_section"))
-                .runTest(overrideFileExport() != null ? overrideFileExport() : true);
-    }
+    // @Test
+    // public void testElbeFTE() throws ConnectionException, ServerException, IOException {
+    // RunnerCreatorHelper.createSinfoFlowdepthDevelopmentTest(FilenameMapper.FTE_ELBE_FILE, 210, 230, River.Elbe,
+    // // current
+    // new SimpleRecommendation("staticwqkms", "fixations-wstv-0-196", "longitudinal_section", "05.05.2008"), // sicher
+    // new SimpleRecommendation("bedheight", "bedheight-soundings-66-2008-FP-QP-2008",
+    // // "bedheight-single-66-2008-MW-FP-QP-2008",
+    // "longitudinal_section"),
+    //
+    // // historical
+    // new SimpleRecommendation("staticwqkms", "fixations-wstv-0-186", "longitudinal_section", "18.03.1997"), // sicher
+    // new SimpleRecommendation("bedheight", "bedheight-soundings-70-1995-QP-1995",
+    // // "bedheight-single-70-1995-MW-QP-1995",
+    // "longitudinal_section"))
+    // .runTest(overrideFileExport() != null ? overrideFileExport() : true);
+    // }
+    //
+    // @Test
+    // public void testRheinFTE() throws ConnectionException, ServerException, IOException {
+    // RunnerCreatorHelper.createSinfoFlowdepthDevelopmentTest(FilenameMapper.FTE_RHEIN_FILE, 655, 665, River.Rhein,
+    // // current
+    // new SimpleRecommendation("staticwqkms", "fixations-wstv-0-372", "longitudinal_section", "23.09.2009-1"), // sicher
+    // new SimpleRecommendation("bedheight", "bedheight-single-94-2008-MW-NIEDERRHEIN_QP-2008_Epoche_NHN",
+    // // "bedheight-single....",
+    // "longitudinal_section"),
+    //
+    // // historical
+    // new SimpleRecommendation("staticwqkms", "fixations-wstv-0-374", "longitudinal_section", "23.09.1991"), // sicher
+    // new SimpleRecommendation("bedheight", "bedheight-single-89-1991-MW-NIEDERRHEIN_QP-1991_Epoche_NHN",
+    // // "bedheight-soundings-89-1991-NIEDERRHEIN_QP-1991_Epoche_NHN",
+    // "longitudinal_section"))
+    // .runTest(overrideFileExport() != null ? overrideFileExport() : true);
+    // }
 
-    @Test
-    public void testRheinFTE() throws ConnectionException, ServerException, IOException {
-        RunnerCreatorHelper.createSinfoFlowdepthDevelopmentTest(FilenameMapper.FTE_RHEIN_FILE, 655, 665, River.Rhein,
-                // current
-                new SimpleRecommendation("staticwqkms", "fixations-wstv-0-372", "longitudinal_section", "23.09.2009-1"), // sicher
-                new SimpleRecommendation("bedheight", "bedheight-soundings-80-2008-FP-2008_NHN",
-                        // "bedheight-single....",
-                        "longitudinal_section"),
+    /* TKH - works */
 
-                // historical
-                new SimpleRecommendation("staticwqkms", "fixations-wstv-0-374", "longitudinal_section", "18.03.1997"), // sicher
-                new SimpleRecommendation("bedheight", "bedheight-single-89-1991-MW-NIEDERRHEIN_QP-1991_Epoche_NHN",
-                        // "bedheight-soundings-89-1991-NIEDERRHEIN_QP-1991_Epoche_NHN",
-                        "longitudinal_section"))
-                .runTest(overrideFileExport() != null ? overrideFileExport() : true);
-    }
+    // @Test
+    // public void testElbeTKH_1() throws ConnectionException, ServerException, IOException {
+    // RunnerCreatorHelper.createSinfoTkhTest(FilenameMapper.TKH_1_ELBE_FILE, 150, 160, River.Elbe, new double[] { 1520.0 })
+    // .runTest(overrideFileExport() != null ? overrideFileExport() : true);
+    // }
+    //
+    // @Test
+    // public void testRheinTKH_2() throws ConnectionException, ServerException, IOException {
+    // RunnerCreatorHelper.createSinfoTkhTest(FilenameMapper.TKH_2_RHEIN_FILE, 600, 610, River.Rhein, new double[] { 6125,
+    // 6526 })
+    //
+    // .runTest(overrideFileExport() != null ? overrideFileExport() : true);
+    // }
 
 }
\ No newline at end of file
--- a/gwt-client/src/test/java/test/RunnerCreatorHelper.java	Wed Jul 04 17:13:31 2018 +0200
+++ b/gwt-client/src/test/java/test/RunnerCreatorHelper.java	Wed Jul 04 17:14:16 2018 +0200
@@ -60,4 +60,13 @@
         proof.addHistoricalRecommendationPair(rec0_hist, rec1_hist);
         return proof;
     }
+
+    public final static AbstractModuleRunner createSinfoTkhTest(final FilenameMapper file, final double from, final double to, final River river,
+            // final boolean useTkh,
+            final double[] wasserspiegellage) throws ConnectionException, ServerException {
+        final SinfoTkhRunner proof = new SinfoTkhRunner(user, pw, CalcMode.sinfo_calc_transport_bodies_heights, file, from, to, river, wasserspiegellage);
+
+        return proof;
+    }
+
 }
\ No newline at end of file
--- a/gwt-client/src/test/java/test/SimpleRecommendation.java	Wed Jul 04 17:13:31 2018 +0200
+++ b/gwt-client/src/test/java/test/SimpleRecommendation.java	Wed Jul 04 17:14:16 2018 +0200
@@ -69,8 +69,8 @@
         final Recommendation recom2 = new Recommendation(rec2.getFactory(), rec2.getIds(), rec2.getTarget());
         recom2.setDisplayName(rec2.getDisplayName());
         final Artifact[] artifacts = loadMany(new Recommendation[] { recom1, recom2 }, null, collection, serverUrl, locale);
-        final String rec1String = RecommandationUtils.createDataString(artifacts[0].getUuid(), recom1, new NilDatacageTwinPanelInfo("xxxx"));
-        final String rec2String = RecommandationUtils.createDataString(artifacts[1].getUuid(), recom2, new NilDatacageTwinPanelInfo("xxxx"));
+        final String rec1String = RecommandationUtils.createDataString(artifacts[0].getUuid(), recom1, new NilDatacageTwinPanelInfo("xxxx", "yyy"));
+        final String rec2String = RecommandationUtils.createDataString(artifacts[1].getUuid(), recom2, new NilDatacageTwinPanelInfo("xxxx", "yyy"));
         final String combinedIdNeu = rec1String + "#" + rec2String;
         return combinedIdNeu;
 
--- a/gwt-client/src/test/java/test/SinfoTkhRunner.java	Wed Jul 04 17:13:31 2018 +0200
+++ b/gwt-client/src/test/java/test/SinfoTkhRunner.java	Wed Jul 04 17:14:16 2018 +0200
@@ -15,6 +15,7 @@
 import org.dive4elements.river.client.shared.exceptions.ServerException;
 import org.dive4elements.river.client.shared.model.Data;
 import org.dive4elements.river.client.shared.model.DataItem;
+import org.dive4elements.river.client.shared.model.DefaultData;
 import org.dive4elements.river.client.shared.model.DefaultDataItem;
 import org.dive4elements.river.client.shared.model.StringOptionsData;
 
@@ -28,10 +29,12 @@
  */
 public class SinfoTkhRunner extends AbstractModuleRunner {
 
+    private final double[] wasserspiegellage;
+
     public SinfoTkhRunner(final String username, final String password, final CalcMode sinfoCalcFlowDepth, final FilenameMapper file, final double from,
-            final double to, final River river) throws ConnectionException, ServerException {
+            final double to, final River river, final double[] wasserspiegellage) throws ConnectionException, ServerException {
         super(username, password, AbstractModuleRunner.Infotype.sinfo, sinfoCalcFlowDepth, file, from, to, river);
-
+        this.wasserspiegellage = wasserspiegellage;
     }
 
     @Override
@@ -42,26 +45,34 @@
         /* Select CalcMode */
         super.selectCalcMode();
 
-        /* Select Range */
-        // super.selectMaxRange();
+        super.feed(new Data[] {
+                new StringOptionsData("ld_mode", "ld_mode", new DataItem[] { new DefaultDataItem("distance_only", "distance_only", "distance_only") }) }); // leider
+                                                                                                                                                           // wichtig
+                                                                                                                                                           // :-(
 
-        /* Select TRANSPORTKÖRPERHÖHHEN - einziger Unterschied zu FlowdepthMinMax */
-        //
-        // <data name="wq_isq" type="Boolean" />
-        // <data name="wq_isfree" type="Boolean" />
-        // <data name="wq_isrange" type="Boolean" />
-        // <data name="wq_from" type="Double" />
-        // <data name="wq_to" type="Double" />
-        // <data name="wq_step" type="Double" />
-        // <data name="wq_single" type="Double[]" />
+        /* Select Range */
+        super.selectRange();
 
-        feedAndGo(new Data[] {
+        // from Panel: new DefaultDataItem("wq_single", "wq_single", sb.toString());
+        final StringBuilder sb = new StringBuilder();
+        for (final double value : this.wasserspiegellage) {
+            sb.append(Double.toString(value));
+            sb.append(" ");
+        }
 
-                new StringOptionsData("wq_isq", "wq_isq", new DataItem[] { new DefaultDataItem("false", "false", "false") }),
-                new StringOptionsData("wq_isfree", "wq_isfree", new DataItem[] { new DefaultDataItem("false", "false", "false") }),
-                new StringOptionsData("wq_isrange", "wq_isrange", new DataItem[] { new DefaultDataItem("false", "false", "false") }),
+        final DataItem wsplItem = new DefaultDataItem("wq_single", "wq_single", sb.toString());
 
-                new StringOptionsData("wq_single", "wq_single", new DataItem[] { new DefaultDataItem("1059.446", "1059.446", "1059.446") }) }, 0);
+        super.feedAndGo(new Data[] {
+
+                new DefaultData("wq_isq", null, null, new DataItem[] { new DefaultDataItem("wq_isq", "wq_isq", "true") }),
+                new DefaultData("wq_isfree", null, null, new DataItem[] { new DefaultDataItem("wq_isfree", "wq_isfree", "false") }),
+                new DefaultData("wq_isrange", null, null, new DataItem[] { new DefaultDataItem("wq_isrange", "wq_isrange", "false") }),
+                new DefaultData("wq_from", null, null, new DataItem[] { new DefaultDataItem("wq_from", "wq_from", "") }),
+                new DefaultData("wq_to", null, null, new DataItem[] { new DefaultDataItem("wq_to", "wq_to", "") }),
+                new DefaultData("wq_step", null, null, new DataItem[] { new DefaultDataItem("wq_step", "wq_step", "") }),
+
+                new DefaultData("wq_single", null, null, new DataItem[] { wsplItem }) }, //
+                0);// reachable state index
 
         describeCollection();
 

http://dive4elements.wald.intevation.org