comparison gwt-client/src/test/java/test/bundu/BunduBezugswstRunner.java @ 9567:86e522bc7f36

jUnit-Tests completed
author gernotbelger
date Mon, 05 Nov 2018 13:21:57 +0100
parents 173f188569c6
children 531a60b7af95
comparison
equal deleted inserted replaced
9566:9826b465b751 9567:86e522bc7f36
8 * documentation coming with Dive4Elements River for details. 8 * documentation coming with Dive4Elements River for details.
9 */ 9 */
10 package test.bundu; 10 package test.bundu;
11 11
12 import java.io.IOException; 12 import java.io.IOException;
13 import java.util.Calendar;
13 import java.util.List; 14 import java.util.List;
15 import java.util.TimeZone;
14 16
15 import org.dive4elements.artifacts.httpclient.exceptions.ConnectionException; 17 import org.dive4elements.artifacts.httpclient.exceptions.ConnectionException;
16 import org.dive4elements.river.client.shared.exceptions.ServerException; 18 import org.dive4elements.river.client.shared.exceptions.ServerException;
17 import org.dive4elements.river.client.shared.model.Data; 19 import org.dive4elements.river.client.shared.model.Data;
18 import org.dive4elements.river.client.shared.model.DataItem; 20 import org.dive4elements.river.client.shared.model.DataItem;
21 import org.dive4elements.river.client.shared.model.IntegerArrayData; 23 import org.dive4elements.river.client.shared.model.IntegerArrayData;
22 import org.dive4elements.river.client.shared.model.StringOptionsData; 24 import org.dive4elements.river.client.shared.model.StringOptionsData;
23 25
24 import test.AbstractBerechnungsartenTester.River; 26 import test.AbstractBerechnungsartenTester.River;
25 import test.AbstractModuleRunner; 27 import test.AbstractModuleRunner;
26 import test.IFilenameMapper;
27 28
28 /** 29 /**
29 * @author Domenico Nardi Tironi 30 * @author Domenico Nardi Tironi
30 * 31 *
31 */ 32 */
43 private final List<Segment> segments; 44 private final List<Segment> segments;
44 private final String qSectorStart; 45 private final String qSectorStart;
45 private final String qSectorEnd; 46 private final String qSectorEnd;
46 private final int[] events; 47 private final int[] events;
47 private final String function; 48 private final String function;
49 private final Double fehlVolFrom;
50 private final Double fehlVolTo;
51 private final boolean preprocessing;
48 52
49 public BunduBezugswstRunner(final IFilenameMapper file, final double from, final double to, final double step, final River river, final int bezugsjahr, 53 public BunduBezugswstRunner(final double from, final double to, final double step, final River river, final int bezugsjahr, final String fixationChoice,
50 final String fixationChoice, final String function, final String abflussklasseFrom, final String abflussklasseTo, final int[] events, 54 final String function, final String abflussklasseFrom, final String abflussklasseTo, final int[] events, final int years_length,
51 final int years_length, final List<Segment> segments, final String calcChoice, final boolean fehlvolumina, final String sounding) 55 final List<Segment> segments, final String calcChoice, final boolean preprocessing, final boolean fehlvolumina, final Double fehlVolFrom,
52 throws ConnectionException, ServerException { 56 final Double fehlVolTo, final String sounding) throws ConnectionException, ServerException {
53 super(AbstractModuleRunner.Infotype.bundu, test.bundu.BunduBerechnungsartenTester.CalcMode.bundu_bezugswst, file, from, to, river); 57 super(AbstractModuleRunner.Infotype.bundu, test.bundu.BunduBerechnungsartenTester.CalcMode.bundu_bezugswst, from, to, river);
54 this.fixationChoice = fixationChoice; 58 this.fixationChoice = fixationChoice;
55 this.qSectorStart = abflussklasseFrom; 59 this.qSectorStart = abflussklasseFrom;
56 this.qSectorEnd = abflussklasseTo; 60 this.qSectorEnd = abflussklasseTo;
57 this.bezugsjahr = bezugsjahr; 61 this.bezugsjahr = bezugsjahr;
58 this.years_length = years_length; 62 this.years_length = years_length;
59 this.fehlvolumina = fehlvolumina; 63 this.fehlvolumina = fehlvolumina;
64 this.fehlVolFrom = fehlVolFrom;
65 this.fehlVolTo = fehlVolTo;
60 this.sounding = sounding; 66 this.sounding = sounding;
61 this.calcChoice = calcChoice; 67 this.calcChoice = calcChoice;
68 this.preprocessing = preprocessing;
62 this.step = step; 69 this.step = step;
63 this.segments = segments; 70 this.segments = segments;
64 this.events = events; 71 this.events = events;
65 this.function = function; 72 this.function = function;
73
66 } 74 }
67 75
68 @Override 76 @Override
69 public void runTest(final boolean exportToFile) throws ServerException, IOException { 77 public void runTest() throws ServerException, IOException {
70 /* Select River */ 78 /* Select River */
71 super.selectRiver(); 79 super.selectRiver();
72 80
73 /* Select ICalcMode */ 81 /* Select ICalcMode */
74 super.selectCalcMode(); 82 super.selectCalcMode();
75 83
76 /* Select Range with step */ 84 /* Select Range with step */
77 final Data[] temp = super.makeFromToData("ld_from", "ld_to"); 85 final Data[] temp = super.makeFromToData("ld_from", "ld_to", this.getFrom(), this.getTo());
78 final String stepStr = String.valueOf(this.step); 86 final String stepStr = String.valueOf(this.step);
79 final Data[] data = super.addItemToExistingData(temp, 87 final Data[] data = super.addItemToExistingData(temp,
80 new StringOptionsData("ld_step", "ld_step", new DataItem[] { new DefaultDataItem(stepStr, stepStr, stepStr) })); 88 new StringOptionsData("ld_step", "ld_step", new DataItem[] { new DefaultDataItem(stepStr, stepStr, stepStr) }));
81 89
82 super.feedAndGo(data, 0); 90 super.feedAndGo(data, 0);
83 91
84 /* bezugsjahr */ 92 /* bezugsjahr */
85 final String bezugsjahr = String.valueOf(this.bezugsjahr); 93 final String bezugsjahr = String.valueOf(this.bezugsjahr);
86 super.feedAndGoSimpleTextInput("singleyear", bezugsjahr); 94
95 final IntDataItem[] eventArray = new IntDataItem[this.events.length];
96 for (int i = 0; i < this.events.length; i++) {
97 eventArray[i] = new IntDataItem("id", "id", this.events[i]);
98 }
99
100 final IntegerArrayData iadTemp = new IntegerArrayData("events_temp", "events_temp", eventArray);
101
102 super.feedAndGo(new Data[] { super.getSimpleTextInput("singleyear", bezugsjahr), iadTemp }, 0);
87 103
88 /* fixierungsauswahl - auto oder manuell */ 104 /* fixierungsauswahl - auto oder manuell */
89 // AUTO: 0, 3 105 // AUTO: 0, 3
90 final Data q1 = super.getSimpleTextInput("q1", this.qSectorStart); 106 final Data q1 = super.getSimpleTextInput("q1", this.qSectorStart);
91 final Data q2 = super.getSimpleTextInput("q2", this.qSectorEnd); 107 final Data q2 = super.getSimpleTextInput("q2", this.qSectorEnd);
92 final Data fixChoice = super.getSimpleTextInput("fix_choice", this.fixationChoice); 108 final Data fixChoice = super.getSimpleTextInput("fix_choice", this.fixationChoice);
109 // start, end (missing)
110 // final DateTimeFormat df = DateTimeFormat.getFormat("dd.MM.yyyy");
111 final Calendar cal = Calendar.getInstance();
112 cal.setTimeZone(TimeZone.getDefault());// TODO: TimeZoneHandling
113 cal.set(Calendar.YEAR, (this.bezugsjahr - 5));
114 cal.set(Calendar.DAY_OF_YEAR, 1);
93 115
94 final IntDataItem[] arr = new IntDataItem[this.events.length]; 116 final Data startData = super.getSimpleTextInput("start", String.valueOf(cal.getTime().getTime()));
95 for (int i = 0; i < this.events.length; i++) { 117 cal.set(Calendar.YEAR, (this.bezugsjahr - 5));
96 arr[i] = new IntDataItem("id", "id", this.events[i]); 118 cal.set(Calendar.DAY_OF_YEAR, 365);
119 final Data endData = super.getSimpleTextInput("end", String.valueOf(cal.getTime().getTime()));
120 final IntegerArrayData iad = new IntegerArrayData("events", "events", eventArray);
121
122 super.feedAndGo(new Data[] { q1, q2, iad, fixChoice, startData, endData }, 0);
123
124 if (this.fixationChoice.equals("state.bundu.wst.fix.manual")) {
125 super.feedAndGo(new Data[] { q1, q2 }, 0); // ein State extra im workflow
97 } 126 }
98 final IntegerArrayData iad = new IntegerArrayData("events", "events", arr);
99
100 super.feedAndGo(new Data[] { q1, q2, iad, fixChoice }, 0);
101
102 // TODO: Automatische ereignisauswahl + Wahl der Abflussklassen im Hintergrund
103 127
104 /* Länge der Abflusszeitreihe */ 128 /* Länge der Abflusszeitreihe */
105 super.feedAndGoSimpleTextInput("year_input_q_series", String.valueOf(this.years_length)); 129 super.feedAndGoSimpleTextInput("year_input_q_series", String.valueOf(this.years_length));
106 130
107 /* (W)Q-Input / UD Input */ 131 /* (W)Q-Input / UD Input */
112 136
113 super.feedAndGo(wqAndMode, // 137 super.feedAndGo(wqAndMode, //
114 0);// reachable state index 138 0);// reachable state index
115 139
116 /* calc_choice */ 140 /* calc_choice */
117 final Data preprocessingData = super.getSimpleTextInput("preprocessing", "false"); 141 final Data preprocessingData = super.getSimpleTextInput("preprocessing", String.valueOf(this.preprocessing));
118 final Data functionData = super.getSimpleTextInput("function", this.function); 142 final Data functionData = super.getSimpleTextInput("function", this.function);
119 final Data calcChoice = super.getSimpleTextInput("calc_choice", this.calcChoice); 143 final Data calcChoice = super.getSimpleTextInput("calc_choice", this.calcChoice);
120 super.feedAndGoData(new Data[] { preprocessingData, functionData, calcChoice }); 144 super.feedAndGo(new Data[] { calcChoice, preprocessingData, functionData }, 0);
121 145
122 // TODO: automaitische Wahl der Berechnungsgrundlagen + Ausreißer (preprocessing) 146 if (this.calcChoice.equals("state.bundu.wst.calc.manual")) {
147 super.feedAndGo(new Data[] { functionData }, 0); // extra states im workflow
148 super.feedAndGo(new Data[] { preprocessingData }, 0);
149 }
123 150
124 /* missing_volume */ 151 /* missing_volume */
125 super.feedAndGoSimpleTextInput("missing_volume", String.valueOf(this.fehlvolumina)); 152 final Data missingVolume = super.getSimpleTextInput("missing_volume", String.valueOf(this.fehlvolumina));
153 super.feedAndGo(new Data[] { missingVolume }, 0);
126 154
127 // TODO: Strecke der FehlVolumina machen 155 if (this.fehlvolumina) {
128 156 super.makeKmRange(this.fehlVolFrom, this.fehlVolTo, "ld_from_part", "ld_to_part");
129 /* Wahl der Peilungen */ 157 super.feedAndGoSimpleTextInput("soundings", this.sounding);
130 158 }
131 super.feedAndGoSimpleTextInput("soundings", this.sounding);
132
133 describeCollection(); 159 describeCollection();
134 160 super.runTests();
135 super.export(exportToFile);
136 } 161 }
137 162
138 } 163 }

http://dive4elements.wald.intevation.org