view gwt-client/src/test/java/test/uinfo/UinfoSalixRunner.java @ 9439:ce0a48b93f4b

bundu jUnit test first attempt
author gernotbelger
date Mon, 20 Aug 2018 16:57:25 +0200
parents da19f1f58d72
children e991c4cec0d0
line wrap: on
line source
/** 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.uinfo;

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.AbstractBerechnungsartenTester.River;
import test.AbstractModuleRunner;
import test.IFilenameMapper;
import test.uinfo.UInfoBerechnungsartenTester.CalcMode;

/**
 * @author Domenico Nardi Tironi
 *
 */
class UinfoSalixRunner extends AbstractModuleRunner {

    private final String scenarioChoice;
    private boolean isUseScenario;

    public UinfoSalixRunner(final IFilenameMapper file, final double from, final double to, final River river, final String scenarioChoice)
            throws ConnectionException, ServerException {
        super(AbstractModuleRunner.Infotype.uinfo, CalcMode.uinfo_salix_line, file, from, to, river);
        this.scenarioChoice = scenarioChoice;
        this.isUseScenario = (scenarioChoice != null) ? (this.isUseScenario = true) : (this.isUseScenario = false);
    }

    @Override
    public void runTest(final boolean exportToFile) throws ServerException, IOException {
        /* Select River */
        super.selectRiver();

        /* Select ICalcMode */
        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();

        /* use scenario */
        final String key = "use_scenario";
        final String value = String.valueOf(this.isUseScenario);

        super.feedAndGoSimpleTextInput(key, value);

        if (this.isUseScenario) {
            // TODO: make regional, supraregional, historical
            makeScenario();
        }

        describeCollection();

        super.export(exportToFile);
    }

    protected void makeScenario() throws ConnectionException, ServerException {
        // Override in subs
    }

    protected final String getScenarioChoice() {

        return this.scenarioChoice;
    }
}

http://dive4elements.wald.intevation.org