# HG changeset patch # User gernotbelger # Date 1534433525 -7200 # Node ID 46e3e23cca0b2b00570135a59b95694536a5ac25 # Parent 05405292a7ca99504615e74938b355062914943b sinfo.collision jUnit-Test diff -r 05405292a7ca -r 46e3e23cca0b gwt-client/src/test/java/test/BerechnungsartenTester.java --- a/gwt-client/src/test/java/test/BerechnungsartenTester.java Thu Aug 16 16:28:03 2018 +0200 +++ b/gwt-client/src/test/java/test/BerechnungsartenTester.java Thu Aug 16 17:32:05 2018 +0200 @@ -4,7 +4,6 @@ import org.dive4elements.artifacts.httpclient.exceptions.ConnectionException; import org.dive4elements.river.client.shared.exceptions.ServerException; -import org.junit.Ignore; import org.junit.Test; /** @@ -13,7 +12,7 @@ // 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 + public class BerechnungsartenTester { public static enum CalcMode { @@ -38,8 +37,10 @@ TKH_1_ELBE_FILE("/sinfo/flowdepthtkh/sinfo_tkh_01.csv"), // TKH_2_RHEIN_FILE("/sinfo/flowdepthtkh/sinfo_tkh_02.csv"), - TKH_TKH_RHEIN_FILE("/sinfo/tkh/sinfo_tkh_export.csv"); + TKH_TKH_RHEIN_FILE("/sinfo/tkh/sinfo_tkh_export.csv"), // + COLLISION_RHEIN_HELLO_WORLD_FILE("/sinfo/collision/sinfo_collision_export.csv"), // + COLLISION_RHEIN_EPOCH_HELLO_WORLD_FILE("/sinfo/collision/sinfo_collision_epoch_export.csv"); private final String filename; FilenameMapper(final String filename) { @@ -157,4 +158,16 @@ .runTest(overrideFileExport() != null ? overrideFileExport() : true); } + @Test + public void testCollision() throws ConnectionException, ServerException, IOException { + RunnerCreatorHelper.createSinfoCollisionYearsTest(FilenameMapper.COLLISION_RHEIN_HELLO_WORLD_FILE, 336.2, 866.3, River.Rhein, new int[] { 2006, 2008 }) + .runTest(overrideFileExport() != null ? overrideFileExport() : true); + } + + @Test + public void testCollisionEpochs() throws ConnectionException, ServerException, IOException { + RunnerCreatorHelper.createSinfoCollisionEpochsTest(FilenameMapper.COLLISION_RHEIN_EPOCH_HELLO_WORLD_FILE, 336.2, 866.3, River.Rhein, "2006,2008;") + .runTest(overrideFileExport() != null ? overrideFileExport() : true); + } + } \ No newline at end of file diff -r 05405292a7ca -r 46e3e23cca0b gwt-client/src/test/java/test/RunnerCreatorHelper.java --- a/gwt-client/src/test/java/test/RunnerCreatorHelper.java Thu Aug 16 16:28:03 2018 +0200 +++ b/gwt-client/src/test/java/test/RunnerCreatorHelper.java Thu Aug 16 17:32:05 2018 +0200 @@ -76,4 +76,17 @@ return proof; } + public final static AbstractModuleRunner createSinfoCollisionYearsTest(final FilenameMapper file, final double from, final double to, final River river, + final int[] years) throws ConnectionException, ServerException { + final SinfoCollisionRunner proof = new SinfoCollisionRunner(user, pw, file, from, to, river, years, null); + + return proof; + } + + public final static AbstractModuleRunner createSinfoCollisionEpochsTest(final FilenameMapper file, final double from, final double to, final River river, + final String epochs) throws ConnectionException, ServerException { + final SinfoCollisionRunner proof = new SinfoCollisionRunner(user, pw, file, from, to, river, null, epochs); + + return proof; + } } \ No newline at end of file diff -r 05405292a7ca -r 46e3e23cca0b gwt-client/src/test/java/test/SinfoCollisionRunner.java --- /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); + } +} diff -r 05405292a7ca -r 46e3e23cca0b gwt-client/src/test/resources/sinfo/collision/sinfo_collision_epoch_export.csv --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gwt-client/src/test/resources/sinfo/collision/sinfo_collision_epoch_export.csv Thu Aug 16 17:32:05 2018 +0200 @@ -0,0 +1,109 @@ +"##Ergebnisausgabe - Rhein - Grundberührungen" +"# FLYS-Version: 3.3.0" +"# Bearbeiter: belger" +"# Datum der Erstellung: 16.08.18" +"# Gewässer: Rhein" +"# Höhensystem des Flusses: Wasssers[NN " +"# Bereich (km): 336,200 - 866,300" +"# Jahr/Zeitraum: 2006-2008" +"" +"Titel: Häufigkeiten";; +"Fluss-km";"Jahr/Zeitraum";"Anzahl der Grundberührungen" +"" +"373,000";"2006-2008";"1" +"374,000";"2006-2008";"1" +"375,000";"2006-2008";"1" +"377,000";"2006-2008";"1" +"380,000";"2006-2008";"1" +"428,000";"2006-2008";"1" +"432,000";"2006-2008";"1" +"444,000";"2006-2008";"1" +"474,000";"2006-2008";"1" +"494,000";"2006-2008";"6" +"517,000";"2006-2008";"1" +"518,000";"2006-2008";"1" +"519,000";"2006-2008";"3" +"521,000";"2006-2008";"1" +"525,000";"2006-2008";"1" +"537,000";"2006-2008";"1" +"538,000";"2006-2008";"1" +"540,000";"2006-2008";"1" +"542,000";"2006-2008";"1" +"543,000";"2006-2008";"3" +"550,000";"2006-2008";"1" +"553,000";"2006-2008";"1" +"557,000";"2006-2008";"1" +"588,000";"2006-2008";"1" +"609,000";"2006-2008";"1" +"640,000";"2006-2008";"2" +"660,000";"2006-2008";"1" +"661,000";"2006-2008";"1" +"668,000";"2006-2008";"1" +"669,000";"2006-2008";"1" +"682,000";"2006-2008";"2" +"687,000";"2006-2008";"1" +"692,000";"2006-2008";"1" +"699,000";"2006-2008";"1" +"706,000";"2006-2008";"1" +"745,000";"2006-2008";"1" +"747,000";"2006-2008";"1" +"748,000";"2006-2008";"1" +"749,000";"2006-2008";"1" +"750,000";"2006-2008";"1" +"856,000";"2006-2008";"1" +"" +"Titel: Abfluss/Abflusszustand";;;;; +"Fluss-km";"Datum";"Pegelstand [cm]";"Bezugspegel [cm]";"Abfluss [m³/s]";"Abflusszustand" +"" +"372,800";"04.05.2006";"567";"Maxau";"1.540";"MQ-HQ1" +"373,600";"14.11.2007";"435";"Maxau";"869";"GlQ-MQ" +"374,900";"18.02.2008";"384";"Maxau";"661";"≈GlQ" +"376,600";"14.11.2007";"444";"Maxau";"910";"GlQ-MQ" +"380,200";"21.01.2006";"378";"Maxau";"640";"≈GlQ" +"428,500";"15.02.2006";"107";"Mannheim";"836";"MNQ-MQ" +"431,700";"27.07.2006";"197";"Mannheim";"1.290";"MNQ-MQ" +"444,400";"13.05.2007";"156";"Worms";"1.080";"MNQ-MQ" +"474,200";"13.02.2006";"36";"Worms";"546";"