changeset 9228:dba14da43f23

JUnit-Tests finish
author gernotbelger
date Thu, 05 Jul 2018 13:46:36 +0200
parents 84397da33d17
children 0dcd1cd41915
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
diffstat 3 files changed, 107 insertions(+), 81 deletions(-) [+]
line wrap: on
line diff
--- a/gwt-client/src/test/java/test/AbstractModuleRunner.java	Wed Jul 04 18:28:08 2018 +0200
+++ b/gwt-client/src/test/java/test/AbstractModuleRunner.java	Thu Jul 05 13:46:36 2018 +0200
@@ -200,14 +200,16 @@
     }
 
     protected final Data[] extractPairData(final List<String> pairIds, final String dataName) {
-        final Data[] data = new Data[pairIds.size()];
+        final DataItem[] items = new DataItem[pairIds.size()];
         int i = 0;
+        final StringBuilder builder = new StringBuilder();
         for (final String pairId : pairIds) {
-            final Data pair = new StringOptionsData(dataName, dataName, new DataItem[] { new DefaultDataItem(pairId, pairId, pairId) });
-            data[i] = pair;
+            builder.append(pairId).append("#");
             i++;
         }
-        return data;
+        final String allPairIds = builder.delete(builder.length() - 1, builder.length()).toString(); // letztes Gatter entfernen
+        final DataItem[] item = new DataItem[] { new DefaultDataItem(allPairIds, allPairIds, allPairIds) };
+        return new Data[] { new StringOptionsData(dataName, dataName, item) };
     }
 
     private final String[][] createKVP(final Data[] data) {
--- a/gwt-client/src/test/java/test/BerechnungsartenTester.java	Wed Jul 04 18:28:08 2018 +0200
+++ b/gwt-client/src/test/java/test/BerechnungsartenTester.java	Thu Jul 05 13:46:36 2018 +0200
@@ -4,6 +4,7 @@
 
 import org.dive4elements.artifacts.httpclient.exceptions.ConnectionException;
 import org.dive4elements.river.client.shared.exceptions.ServerException;
+import org.junit.Ignore;
 import org.junit.Test;
 
 /**
@@ -35,7 +36,9 @@
         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");
+        TKH_2_RHEIN_FILE("/sinfo/flowdepthtkh/sinfo_tkh_02.csv"),
+
+        TKH_TKH_RHEIN_FILE("/sinfo/tkh/sinfo_tkh_export.csv");
 
         private final String filename;
 
@@ -52,29 +55,38 @@
         return null;
     }
 
-    /* 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 */
+    /* FLOWDEPTH MIN MAX */
+    @Test
+    public void testFTMINMAX1() throws ServerException, IOException {
+
+        RunnerCreatorHelper.createSinfoFlowdepthMinMaxTest(FilenameMapper.FT_MINMAX_RHEIN_1_FILE, 430, 450, River.Rhein,
+                new SimpleRecommendation("bedheight", "bedheight-single-79-2004-MW-DGM-2004_Epoche_NHN", "longitudinal_section"),
+                new SimpleRecommendation("staticwqkms", "additionals-wstv-0-269", "longitudinal_section", "Amtl.Festlegung_GlQ(2002)")
+
+        ).runTest(overrideFileExport() != null ? overrideFileExport() : true);
+    }
+
+    @Test
+    public void testFTMINMAX2() throws ConnectionException, ServerException, IOException {
+        RunnerCreatorHelper.createSinfoFlowdepthMinMaxTest(FilenameMapper.FT_MINMAX_ELBE_2_FILE, 0, 90, River.Elbe,
+                // first
+                new SimpleRecommendation("bedheight", "bedheight-single-58-2015-MW-FP-2015_0-502", "longitudinal_section", "FP-2015_0-502"),
+                new SimpleRecommendation("staticwqkms", "fixations-wstv-0-156", "longitudinal_section", "02.09.2004"),
+
+                // second
+                new SimpleRecommendation("bedheight", "bedheight-single-58-2015-MW-FP-2015_0-502", "longitudinal_section", "FP-2015_0-502"),
+                new SimpleRecommendation("staticwqkms", "fixations-wstv-1-156", "longitudinal_section", "03.09.2004"))
+                .runTest(overrideFileExport() != null ? overrideFileExport() : true);
+    }
+
+    /* FLOWDEPTH */
     @Test
     public void testRhein1FT() throws ConnectionException, ServerException, IOException {
 
-        RunnerCreatorHelper
-                .createSinfoFlowdepthTest(FilenameMapper.FT_RHEIN_1_FILE, 350, 380, River.Rhein, false,
-                        new SimpleRecommendation("staticwqkms", "additionals-wstv-0-415", "longitudinal_section"),
-                        new SimpleRecommendation("bedheight", "bedheight-soundings-79-2004-DGM-2004_Epoche_NHN", "longitudinal_section"))
+        RunnerCreatorHelper.createSinfoFlowdepthTest(FilenameMapper.FT_RHEIN_1_FILE, 350, 380, River.Rhein, false,
+
+                new SimpleRecommendation("bedheight", "bedheight-soundings-79-2004-DGM-2004_Epoche_NHN", "longitudinal_section"),
+                new SimpleRecommendation("staticwqkms", "additionals-wstv-0-415", "longitudinal_section"))
                 .runTest(overrideFileExport() != null ? overrideFileExport() : true);
 
     }
@@ -83,61 +95,66 @@
     public void testRhein2FT() throws ConnectionException, ServerException, IOException {
         RunnerCreatorHelper
                 .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"))
+                        new SimpleRecommendation("bedheight", "bedheight-soundings-92-2004-NIEDERRHEIN_QP-2004_Epoche_NHN", "longitudinal_section"),
+                        new SimpleRecommendation("staticwqkms", "fixations-wstv-0-323", "longitudinal_section"))
+
                 .runTest(overrideFileExport() != null ? overrideFileExport() : true);
     }
 
-    /* DO NOT DELETE FLOWDEPTH DEVELOPMENT - used to work */
+    /* 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"),
-    //
-    // // 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 testElbeFTE() throws ConnectionException, ServerException, IOException {
+        RunnerCreatorHelper.createSinfoFlowdepthDevelopmentTest(FilenameMapper.FTE_ELBE_FILE, 210, 230, River.Elbe,
+                // current
+                new SimpleRecommendation("bedheight", "bedheight-soundings-66-2008-FP-QP-2008",
+                        // "bedheight-single-66-2008-MW-FP-QP-2008",
+                        "longitudinal_section"),
+                new SimpleRecommendation("staticwqkms", "fixations-wstv-0-196", "longitudinal_section", "05.05.2008"), // sicher
 
-    /* TKH - works */
+                // historical
+                new SimpleRecommendation("bedheight", "bedheight-soundings-70-1995-QP-1995",
+                        // "bedheight-single-70-1995-MW-QP-1995",
+                        "longitudinal_section"),
+                new SimpleRecommendation("staticwqkms", "fixations-wstv-0-186", "longitudinal_section", "18.03.1997")// sicher
+        ).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);
-    // }
+    @Test
+    public void testRheinFTE() throws ConnectionException, ServerException, IOException {
+        RunnerCreatorHelper.createSinfoFlowdepthDevelopmentTest(FilenameMapper.FTE_RHEIN_FILE, 655, 665, River.Rhein,
+                // current
+                new SimpleRecommendation("bedheight", "bedheight-single-94-2008-MW-NIEDERRHEIN_QP-2008_Epoche_NHN",
+                        // "bedheight-single....",
+                        "longitudinal_section"),
+                new SimpleRecommendation("staticwqkms", "fixations-wstv-0-372", "longitudinal_section", "23.09.2009-1"), // sicher
+
+                // historical
+                new SimpleRecommendation("bedheight", "bedheight-single-89-1991-MW-NIEDERRHEIN_QP-1991_Epoche_NHN",
+                        // "bedheight-soundings-89-1991-NIEDERRHEIN_QP-1991_Epoche_NHN",
+                        "longitudinal_section"),
+                new SimpleRecommendation("staticwqkms", "fixations-wstv-0-374", "longitudinal_section", "23.09.1991") // sicher
+        ).runTest(overrideFileExport() != null ? overrideFileExport() : true);
+    }
+
+    /* TKH */
+
+    @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);
+    }
+
+    @Test
+    public void testTKhTkh() throws ConnectionException, ServerException, IOException {
+        RunnerCreatorHelper.createSinfoTkhTest(FilenameMapper.TKH_TKH_RHEIN_FILE, 0, 182.4, River.Beispielfluss, new double[] { 1059.446 })
+                .runTest(overrideFileExport() != null ? overrideFileExport() : true);
+    }
 
 }
\ No newline at end of file
--- a/gwt-client/src/test/java/test/RunnerCreatorHelper.java	Wed Jul 04 18:28:08 2018 +0200
+++ b/gwt-client/src/test/java/test/RunnerCreatorHelper.java	Thu Jul 05 13:46:36 2018 +0200
@@ -32,17 +32,24 @@
 
     // HELPER-Methods:
 
-    public final static AbstractModuleRunner createSinfoFlowdepthMinMaxTest(final FilenameMapper helloWorldFile, final double from, final double to,
-            final River beispielfluss) throws ConnectionException, ServerException {
+    public final static AbstractModuleRunner createSinfoFlowdepthMinMaxTest(final FilenameMapper file, final double from, final double to,
+            final River beispielfluss, final SimpleRecommendation rec0, final SimpleRecommendation rec1) throws ConnectionException, ServerException {
         // TODO: make recommendationPair to method parameter if needed
-        final SinfoFlowdepthMinMaxRunner proof = new SinfoFlowdepthMinMaxRunner(user, pw, CalcMode.sinfo_calc_flow_depth_minmax, helloWorldFile, from, to,
-                beispielfluss);
-        proof.addRecommendationPair(new SimpleRecommendation("staticwqkms", "additionals-wstv-0-103", "sinfo_flowdepth_waterlevels"),
-                new SimpleRecommendation("bedheight", "bedheight-single-36-2015-FP-2015_0-502", "sinfo_flowdepthminmax_heights"));
+        final SinfoFlowdepthMinMaxRunner proof = new SinfoFlowdepthMinMaxRunner(user, pw, CalcMode.sinfo_calc_flow_depth_minmax, file, from, to, beispielfluss);
+        proof.addRecommendationPair(rec0, rec1);
 
         return proof;
     }
 
+    public static AbstractModuleRunner createSinfoFlowdepthMinMaxTest(final FilenameMapper file, final int from, final int to, final River river,
+            final SimpleRecommendation simpleRecommendation0, final SimpleRecommendation simpleRecommendation1,
+            final SimpleRecommendation simpleRecommendation2, final SimpleRecommendation simpleRecommendation3) throws ConnectionException, ServerException {
+        final SinfoFlowdepthMinMaxRunner proof = (SinfoFlowdepthMinMaxRunner) createSinfoFlowdepthMinMaxTest(file, from, to, river, simpleRecommendation0,
+                simpleRecommendation1);
+        proof.addRecommendationPair(simpleRecommendation2, simpleRecommendation3);
+        return proof;
+    }
+
     public final static AbstractModuleRunner createSinfoFlowdepthTest(final FilenameMapper file, final double from, final double to, final River river,
             final boolean useTkh, final SimpleRecommendation rec0, final SimpleRecommendation rec1) throws ConnectionException, ServerException {
         final SinfoFlowdepthRunner proof = new SinfoFlowdepthRunner(user, pw, CalcMode.sinfo_calc_flow_depth, file, from, to, river, useTkh);

http://dive4elements.wald.intevation.org