Skip to content

Commit 017dae2

Browse files
committed
Update
1 parent 6245aec commit 017dae2

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

src/test/groovy/edu/ie3/datamodel/io/sink/CsvFileSinkTest.groovy

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,90 @@ class CsvFileSinkTest extends Specification implements TimeSeriesTestData {
113113
csvFileSink.shutdown()
114114
}
115115

116+
def "A valid CsvFileSink should persist provided elements correctly"() {
117+
given:
118+
CsvFileSink csvFileSink = new CsvFileSink(testBaseFolderPath,
119+
new ProcessorProvider([
120+
new ResultEntityProcessor(PvResult),
121+
new ResultEntityProcessor(WecResult),
122+
new ResultEntityProcessor(EvResult),
123+
new ResultEntityProcessor(EvcsResult),
124+
new ResultEntityProcessor(EmResult),
125+
new ResultEntityProcessor(FlexOptionsResult),
126+
new InputEntityProcessor(Transformer2WInput),
127+
new InputEntityProcessor(NodeInput),
128+
new InputEntityProcessor(EvcsInput),
129+
new InputEntityProcessor(Transformer2WTypeInput),
130+
new InputEntityProcessor(LineGraphicInput),
131+
new InputEntityProcessor(NodeGraphicInput),
132+
new InputEntityProcessor(CylindricalStorageInput),
133+
new InputEntityProcessor(ThermalHouseInput),
134+
new InputEntityProcessor(OperatorInput),
135+
new InputEntityProcessor(LineInput),
136+
new InputEntityProcessor(ThermalBusInput),
137+
new InputEntityProcessor(LineTypeInput),
138+
new InputEntityProcessor(LoadInput),
139+
new InputEntityProcessor(EmInput)
140+
], [] as Map),
141+
new FileNamingStrategy(),
142+
",")
143+
144+
UUID uuid = UUID.fromString("22bea5fc-2cb2-4c61-beb9-b476e0107f52")
145+
UUID inputModel = UUID.fromString("22bea5fc-2cb2-4c61-beb9-b476e0107f52")
146+
Quantity<Power> p = Quantities.getQuantity(10, StandardUnits.ACTIVE_POWER_IN)
147+
Quantity<Power> q = Quantities.getQuantity(10, StandardUnits.REACTIVE_POWER_IN)
148+
PvResult pvResult = new PvResult(uuid, TimeUtil.withDefaults.toZonedDateTime("2020-01-30 17:26:44"), inputModel, p, q)
149+
WecResult wecResult = new WecResult(uuid, TimeUtil.withDefaults.toZonedDateTime("2020-01-30 17:26:44"), inputModel, p, q)
150+
EvcsResult evcsResult = new EvcsResult(uuid, TimeUtil.withDefaults.toZonedDateTime("2020-01-30 17:26:44"), inputModel, p, q)
151+
EmResult emResult = new EmResult(uuid, TimeUtil.withDefaults.toZonedDateTime("2020-01-30 17:26:44"), inputModel, p, q)
152+
153+
Quantity<Power> pRef = Quantities.getQuantity(5.1, StandardUnits.ACTIVE_POWER_RESULT)
154+
Quantity<Power> pMin = Quantities.getQuantity(-6, StandardUnits.ACTIVE_POWER_RESULT)
155+
Quantity<Power> pMax = Quantities.getQuantity(6, StandardUnits.ACTIVE_POWER_RESULT)
156+
FlexOptionsResult flexOptionsResult = new FlexOptionsResult(uuid, TimeUtil.withDefaults.toZonedDateTime("2020-01-30 17:26:44"), inputModel, pRef, pMin, pMax)
157+
158+
when:
159+
csvFileSink.persistAll([
160+
pvResult,
161+
wecResult,
162+
evcsResult,
163+
emResult,
164+
flexOptionsResult,
165+
GridTestData.transformerCtoG,
166+
GridTestData.lineGraphicCtoD,
167+
GridTestData.nodeGraphicC,
168+
ThermalUnitInputTestData.cylindricStorageInput,
169+
ThermalUnitInputTestData.thermalHouseInput,
170+
SystemParticipantTestData.evcsInput,
171+
SystemParticipantTestData.loadInput,
172+
SystemParticipantTestData.emInput
173+
])
174+
csvFileSink.shutdown()
175+
176+
then:
177+
new File(testBaseFolderPath).exists()
178+
new File(testBaseFolderPath + File.separator + "wec_res.csv").exists()
179+
new File(testBaseFolderPath + File.separator + "pv_res.csv").exists()
180+
new File(testBaseFolderPath + File.separator + "evcs_res.csv").exists()
181+
new File(testBaseFolderPath + File.separator + "em_res.csv").exists()
182+
new File(testBaseFolderPath + File.separator + "flex_options_res.csv").exists()
183+
new File(testBaseFolderPath + File.separator + "transformer_2_w_type_input.csv").exists()
184+
new File(testBaseFolderPath + File.separator + "node_input.csv").exists()
185+
new File(testBaseFolderPath + File.separator + "transformer_2_w_input.csv").exists()
186+
new File(testBaseFolderPath + File.separator + "operator_input.csv").exists()
187+
new File(testBaseFolderPath + File.separator + "cylindrical_storage_input.csv").exists()
188+
new File(testBaseFolderPath + File.separator + "line_graphic_input.csv").exists()
189+
new File(testBaseFolderPath + File.separator + "line_input.csv").exists()
190+
new File(testBaseFolderPath + File.separator + "operator_input.csv").exists()
191+
new File(testBaseFolderPath + File.separator + "node_graphic_input.csv").exists()
192+
new File(testBaseFolderPath + File.separator + "thermal_bus_input.csv").exists()
193+
new File(testBaseFolderPath + File.separator + "thermal_house_input.csv").exists()
194+
new File(testBaseFolderPath + File.separator + "load_input.csv").exists()
195+
new File(testBaseFolderPath + File.separator + "em_input.csv").exists()
196+
197+
!new File(testBaseFolderPath + File.separator + "ev_res.csv").exists()
198+
}
199+
116200
def "A valid CsvFileSink should persist a time series correctly"() {
117201
given:
118202
TimeSeriesProcessor<IndividualTimeSeries, TimeBasedValue, EnergyPriceValue> timeSeriesProcessor = new TimeSeriesProcessor<>(IndividualTimeSeries, TimeBasedValue, EnergyPriceValue)

0 commit comments

Comments
 (0)