Mercurial > dive4elements > river
diff gwt-client/src/test/java/test/SinfoCollisionRunner.java @ 9417:46e3e23cca0b
sinfo.collision jUnit-Test
author | gernotbelger |
---|---|
date | Thu, 16 Aug 2018 17:32:05 +0200 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gwt-client/src/test/java/test/SinfoCollisionRunner.java Thu Aug 16 17:32:05 2018 +0200 @@ -0,0 +1,79 @@ +/** 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; + +import java.io.IOException; + +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.StringOptionsData; + +import test.BerechnungsartenTester.CalcMode; +import test.BerechnungsartenTester.FilenameMapper; +import test.BerechnungsartenTester.River; + +/** + * @author Domenico Nardi Tironi + * + */ +public class SinfoCollisionRunner extends AbstractModuleRunner { + + private final int[] years; + private final String epochs; + private boolean isYears; // cannot be final because of the ternary expression + + public SinfoCollisionRunner(final String username, final String password, final FilenameMapper file, final double from, final double to, final River river, + final int[] years, final String epochs) throws ConnectionException, ServerException { + super(username, password, AbstractModuleRunner.Infotype.sinfo, CalcMode.sinfo_calc_collision, file, from, to, river); + this.years = years; + this.epochs = epochs; + this.isYears = (years != null) ? (this.isYears = true) : (this.isYears = false); + } + + @Override + public void runTest(final boolean exportToFile) throws ServerException, IOException { + /* Select River */ + super.selectRiver(); + + /* Select CalcMode */ + super.selectCalcMode(); + + super.feed(new Data[] { + new StringOptionsData("ld_mode", "ld_mode", new DataItem[] { new DefaultDataItem("distance_only", "distance_only", "distance_only") }) }); // ggf + + /* Select Range */ + super.selectRange(); + + /* Year or Epoch? eigentlich vermutlich überflüssig */ + final String yeSelectStr = this.isYears ? "state.sinfo.year" : "state.sinfo.epoch"; + final Data yearEpochSelect = new StringOptionsData("ye_select", "ye_select", + new DataItem[] { new DefaultDataItem(yeSelectStr, yeSelectStr, yeSelectStr) }); + feedAndGo(new Data[] { yearEpochSelect }, 0); + + if (this.years != null) { + final StringBuilder sb = new StringBuilder(); + for (final int value : this.years) { + sb.append(String.valueOf(value)); + sb.append(" "); + } + final Data yearsData = new StringOptionsData("years", "years", new DataItem[] { new DefaultDataItem("years", "years", sb.toString()) }); + feedAndGo(new Data[] { yearsData }, 0); + } else if (this.epochs != null) { + final Data data = new StringOptionsData("epochs", "epochs", new DataItem[] { new DefaultDataItem("epochs", "epochs", this.epochs) }); + feedAndGo(new Data[] { data }, 0); + } + describeCollection(); + + super.export(exportToFile); + } +}