view gwt-client/src/test/java/test/SinfoTest.java @ 9031:efd2de78d158

work on unit testing
author gernotbelger
date Fri, 27 Apr 2018 11:34:04 +0200
parents
children
line wrap: on
line source
package test;

/** 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.
 */

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.OutputMode;
import org.dive4elements.river.client.shared.model.StringOptionsData;

/**
 * @author Domenico Nardi Tironi
 *
 */
public class SinfoTest extends SuperTest {

    private final String calcMode;

    public SinfoTest(final String username, final String password, final String infotype, final String calcmode) throws ConnectionException, ServerException {
        super(username, password, infotype);
        this.calcMode = calcmode;
    }

    @Override
    public void runTest(final boolean exportToFile) throws ServerException, IOException {
        // TODO Auto-generated method stub
        /* Select River */
        final Data data = new StringOptionsData("river", "river", new DataItem[] { new DefaultDataItem("Beispielfluss", "Beispielfluss", "Beispielfluss") });
        feedAndGo(new Data[] { data }, 0);

        /* Select CalcMode */
        // final DataList calcModes = getArtifact().getArtifactDescription().getCurrentData(); // AUSWAHL-Möglichkeiten
        // final DataItem minMaxFlowdepth = calcModes.get(0).getItems()[2]; // CalcMode
        final Data dataCalcMode = new StringOptionsData("calculation_mode", "calculation_mode",
                new DataItem[] { new DefaultDataItem(this.calcMode, this.calcMode, this.calcMode) });
        feedAndGo(new Data[] { dataCalcMode }, 0);

        /* Select Range */

        // entweder eine bestimmte Range
        final Data dataFrom = new StringOptionsData("ld_from", "ld_from", new DataItem[] { new DefaultDataItem("10", "10", "10") });
        final Data dataTo = new StringOptionsData("ld_to", "ld_to", new DataItem[] { new DefaultDataItem("100", "100", "100") });
        final Data[] rangeFromToDetermined = new Data[] { dataFrom, dataTo };

        // oder die maxRange
        // final DataList list = getArtifact().getArtifactDescription().getCurrentData();
        // final Data[] rangeMax = new Data[] { list.get(0), list.get(1) };

        feedAndGo(rangeFromToDetermined, 0);

        /* Select Fixpunkte */
        feedAndGo(super.getPairData(), 0);

        // Describe collection
        describeCollection(); // wichtig, damit die Facets erzeugt werden

        // /* Export calculation */
        final OutputMode[] modes = getArtifact().getArtifactDescription().getOutputModes();
        if (modes != null) {
            final OutputMode mode = modes[1]; // output.sinfo_flowdepthminmax_export
            doGet(mode.getName(), exportToFile);
        }
    }

}

http://dive4elements.wald.intevation.org