diff gwt-client/src/test/java/test/bundu/BunduBezugswstRunner.java @ 9439:ce0a48b93f4b

bundu jUnit test first attempt
author gernotbelger
date Mon, 20 Aug 2018 16:57:25 +0200
parents
children 173f188569c6
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gwt-client/src/test/java/test/bundu/BunduBezugswstRunner.java	Mon Aug 20 16:57:25 2018 +0200
@@ -0,0 +1,136 @@
+/** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde
+ * Software engineering by
+ *  Björnsen Beratende Ingenieure GmbH
+ *  Dr. Schumacher Ingenieurbüro für Wasser und Umwelt
+ *
+ * This file is Free Software under the GNU AGPL (>=v3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out the
+ * documentation coming with Dive4Elements River for details.
+ */
+package test.bundu;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.dive4elements.artifacts.httpclient.exceptions.ConnectionException;
+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.DefaultDataItem;
+import org.dive4elements.river.client.shared.model.IntDataItem;
+import org.dive4elements.river.client.shared.model.IntegerArrayData;
+import org.dive4elements.river.client.shared.model.StringOptionsData;
+
+import test.AbstractBerechnungsartenTester.River;
+import test.AbstractModuleRunner;
+import test.IFilenameMapper;
+
+/**
+ * @author Domenico Nardi Tironi
+ *
+ */
+class BunduBezugswstRunner extends AbstractModuleRunner {
+
+    private final String fixationChoice;
+    private final int bezugsjahr;
+    private final int years_length;
+
+    private final boolean fehlvolumina;
+    private final String sounding;
+
+    private final String calcChoice;
+    private final double step;
+    private final List<Segment> segments;
+    private final int qSectorStart;
+    private final int qSectorEnd;
+    private final int[] events;
+
+    public BunduBezugswstRunner(final IFilenameMapper file, final double from, final double to, final double step, final River river, final int bezugsjahr,
+            final String fixationChoice, final int gaugeRangeQsectorStart_q1, final int gaugeRangeQsectorEnd_q2, final int[] events, final int years_length,
+            final List<Segment> segments, final String calcChoice, final boolean fehlvolumina, final String sounding)
+            throws ConnectionException, ServerException {
+        super(AbstractModuleRunner.Infotype.bundu, test.bundu.BunduBerechnungsartenTester.CalcMode.bundu_bezugswst, file, from, to, river);
+        this.fixationChoice = fixationChoice;
+        this.qSectorStart = gaugeRangeQsectorStart_q1;
+        this.qSectorEnd = gaugeRangeQsectorEnd_q2;
+        this.bezugsjahr = bezugsjahr;
+        this.years_length = years_length;
+        this.fehlvolumina = fehlvolumina;
+        this.sounding = sounding;
+        this.calcChoice = calcChoice;
+        this.step = step;
+        this.segments = segments;
+        this.events = events;
+    }
+
+    @Override
+    public void runTest(final boolean exportToFile) throws ServerException, IOException {
+        /* Select River */
+        super.selectRiver();
+
+        /* Select ICalcMode */
+        super.selectCalcMode();
+
+        /* Select Range with step */
+        final Data[] temp = super.makeFromToData("ld_from", "ld_to");
+        final String stepStr = String.valueOf(this.step);
+        final Data[] data = super.addItemToExistingData(temp,
+                new StringOptionsData("ld_step", "ld_step", new DataItem[] { new DefaultDataItem(stepStr, stepStr, stepStr) }));
+
+        super.feedAndGo(data, 0);
+
+        /* bezugsjahr */
+        final String bezugsjahr = String.valueOf(this.bezugsjahr);
+        super.feedAndGoSimpleTextInput("singleyear", bezugsjahr);
+
+        /* fixierungsauswahl - auto oder manuell */
+        // AUTO: 0, 3
+        final Data q1 = super.getSimpleTextInput("q1", String.valueOf(this.qSectorStart));
+        final Data q2 = super.getSimpleTextInput("q2", String.valueOf(this.qSectorEnd));
+        final Data fixChoice = super.getSimpleTextInput("fix_choice", this.fixationChoice);
+
+        final IntDataItem[] arr = new IntDataItem[this.events.length];
+        for (int i = 0; i < this.events.length; i++) {
+            arr[i] = new IntDataItem("id", "id", this.events[i]);
+        }
+        final IntegerArrayData iad = new IntegerArrayData("events", "events", arr);
+
+        super.feedAndGo(new Data[] { q1, q2, iad, fixChoice }, 0);
+
+        // TODO: Automatische ereignisauswahl + Wahl der Abflussklassen im Hintergrund
+
+        /* Länge der Abflusszeitreihe */
+        super.feedAndGoSimpleTextInput("year_input_q_series", String.valueOf(this.years_length));
+
+        /* (W)Q-Input / UD Input */
+
+        final Data[] wqData = Segment.getDataforFeed("wq_values", this.segments);
+        final Data[] wqAndMode = super.addItemToExistingData(wqData,
+                new StringOptionsData("bundu.wst.mode", "bundu.wst.mode", new DataItem[] { new DefaultDataItem("Q", "Q", "Q") }));
+
+        super.feedAndGo(wqAndMode, //
+                0);// reachable state index
+
+        /* calc_choice */
+        final Data preprocessingData = super.getSimpleTextInput("preprocessing", "false");
+        final Data functionData = super.getSimpleTextInput("function", "log");
+        final Data calcChoice = super.getSimpleTextInput("calc_choice", this.calcChoice);
+        super.feedAndGoData(new Data[] { preprocessingData, functionData, calcChoice });
+
+        // TODO: automaitische Wahl der Berechnungsgrundlagen + Ausreißer (preprocessing)
+
+        /* missing_volume */
+        super.feedAndGoSimpleTextInput("missing_volume", String.valueOf(this.fehlvolumina));
+
+        // TODO: Strecke der FehlVolumina machen
+
+        /* Wahl der Peilungen */
+
+        super.feedAndGoSimpleTextInput("soundings", this.sounding);
+
+        describeCollection();
+
+        super.export(exportToFile);
+    }
+
+}

http://dive4elements.wald.intevation.org