-
Notifications
You must be signed in to change notification settings - Fork 5
/
CsvSystemParticipantSourceTest.groovy
484 lines (420 loc) · 25.3 KB
/
CsvSystemParticipantSourceTest.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
/*
* © 2021. TU Dortmund University,
* Institute of Energy Systems, Energy Efficiency and Energy Economics,
* Research group Distribution grid planning and operation
*/
package edu.ie3.datamodel.io.source.csv
import edu.ie3.datamodel.exceptions.SourceException
import edu.ie3.datamodel.exceptions.SystemParticipantsException
import edu.ie3.datamodel.io.factory.input.NodeAssetInputEntityData
import edu.ie3.datamodel.io.factory.input.participant.ChpInputEntityData
import edu.ie3.datamodel.io.factory.input.participant.HpInputEntityData
import edu.ie3.datamodel.io.factory.input.participant.SystemParticipantTypedEntityData
import edu.ie3.datamodel.io.source.RawGridSource
import edu.ie3.datamodel.io.source.SystemParticipantSource
import edu.ie3.datamodel.io.source.ThermalSource
import edu.ie3.datamodel.io.source.TypeSource
import edu.ie3.datamodel.models.input.NodeInput
import edu.ie3.datamodel.models.input.OperatorInput
import edu.ie3.datamodel.models.input.system.BmInput
import edu.ie3.datamodel.models.input.system.ChpInput
import edu.ie3.datamodel.models.input.system.EvInput
import edu.ie3.datamodel.models.input.system.EvcsInput
import edu.ie3.datamodel.models.input.system.FixedFeedInInput
import edu.ie3.datamodel.models.input.system.HpInput
import edu.ie3.datamodel.models.input.system.LoadInput
import edu.ie3.datamodel.models.input.system.PvInput
import edu.ie3.datamodel.models.input.system.StorageInput
import edu.ie3.datamodel.models.input.system.WecInput
import edu.ie3.datamodel.models.input.thermal.ThermalBusInput
import edu.ie3.datamodel.models.input.thermal.ThermalStorageInput
import edu.ie3.datamodel.utils.Try
import edu.ie3.test.common.SystemParticipantTestData as sptd
import spock.lang.Specification
class CsvSystemParticipantSourceTest extends Specification implements CsvTestDataMeta {
def "A SystemParticipantSource with csv input should provide an instance of SystemParticipants based on valid input data correctly"() {
given:
def typeSource = new TypeSource(new CsvDataSource(csvSep, typeFolderPath, fileNamingStrategy))
def thermalSource = new ThermalSource(typeSource, new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy))
def rawGridSource = new RawGridSource(typeSource, new CsvDataSource(csvSep, gridDefaultFolderPath, fileNamingStrategy))
def csvSystemParticipantSource = new SystemParticipantSource(
typeSource,
thermalSource,
rawGridSource,
new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy))
when:
def systemParticipants = csvSystemParticipantSource.systemParticipants
then:
systemParticipants.allEntitiesAsList().size() == 10
systemParticipants.pvPlants.first().uuid == sptd.pvInput.uuid
systemParticipants.bmPlants.first().uuid == sptd.bmInput.uuid
systemParticipants.chpPlants.first().uuid == sptd.chpInput.uuid
systemParticipants.evs.first().uuid == sptd.evInput.uuid
systemParticipants.fixedFeedIns.first().uuid == sptd.fixedFeedInInput.uuid
systemParticipants.heatPumps.first().uuid == sptd.hpInput.uuid
systemParticipants.loads.first().uuid == sptd.loadInput.uuid
systemParticipants.wecPlants.first().uuid == sptd.wecInput.uuid
systemParticipants.storages.first().uuid == sptd.storageInput.uuid
systemParticipants.evcs.first().uuid == sptd.evcsInput.uuid
}
def "A SystemParticipantSource with csv input should process invalid input data as expected when requested to provide an instance of SystemParticipants"() {
given:
def typeSource = new TypeSource(new CsvDataSource(csvSep, typeFolderPath, fileNamingStrategy))
def thermalSource = new ThermalSource(typeSource, new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy))
def rawGridSource = Spy(RawGridSource, constructorArgs: [
typeSource,
new CsvDataSource(csvSep, gridDefaultFolderPath, fileNamingStrategy)
]) {
// partly fake the return method of the csv raw grid source to always return empty node sets
// -> elements to build NodeGraphicInputs are missing
getNodes() >> new HashSet<NodeInput>()
getNodes(_) >> new HashSet<NodeInput>()
} as RawGridSource
def csvSystemParticipantSource = new SystemParticipantSource(
typeSource,
thermalSource,
rawGridSource,
new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy))
when:
def systemParticipants = Try.of(() -> csvSystemParticipantSource.systemParticipants, SystemParticipantsException)
then:
systemParticipants.failure
systemParticipants.data == Optional.empty()
Exception ex = systemParticipants.exception.get()
ex.class == SystemParticipantsException
ex.message.startsWith("10 error(s) occurred while initializing system participants. " +
"edu.ie3.datamodel.exceptions.FailureException: 1 exception(s) occurred within \"FixedFeedInInput\" data, one is: " +
"edu.ie3.datamodel.exceptions.FactoryException: edu.ie3.datamodel.exceptions.SourceException: " +
"Failure due to: Skipping FixedFeedInInput with uuid ")
}
def "A SystemParticipantSource with csv input should build typed entity from valid and invalid input data as expected"() {
given:
def csvSystemParticipantSource = new SystemParticipantSource(
Mock(TypeSource),
Mock(ThermalSource),
Mock(RawGridSource),
new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy))
def nodeAssetInputEntityData = new NodeAssetInputEntityData(fieldsToAttributes, clazz, operator, node)
when:
def typedEntityDataOpt = csvSystemParticipantSource.buildTypedEntityData(nodeAssetInputEntityData, types)
then:
typedEntityDataOpt.success == resultIsPresent
typedEntityDataOpt.data.ifPresent({ typedEntityData ->
assert (typedEntityData == resultData)
})
where:
types | node | operator | fieldsToAttributes | clazz || resultIsPresent || resultData
[]| sptd.chpInput.node | sptd.chpInput.operator | ["type": "5ebd8f7e-dedb-4017-bb86-6373c4b68eb8"] | ChpInput || false || null
[sptd.chpTypeInput] | sptd.chpInput.node | sptd.chpInput.operator | ["bla": "foo"] | ChpInput || false || null
[sptd.chpTypeInput] | sptd.chpInput.node | sptd.chpInput.operator | [:] | ChpInput || false || null
[sptd.chpTypeInput] | sptd.chpInput.node | sptd.chpInput.operator | ["type": "5ebd8f7e-dedb-4017-bb86-6373c4b68eb9"] | ChpInput || false || null
[sptd.chpTypeInput] | sptd.chpInput.node | sptd.chpInput.operator | ["type": "5ebd8f7e-dedb-4017-bb86-6373c4b68eb8"] | ChpInput || true || new SystemParticipantTypedEntityData<>([:], clazz, operator, node, sptd.chpTypeInput)
}
def "A SystemParticipantSource with csv input should build hp input entity from valid and invalid input data as expected"() {
given:
def csvSystemParticipantSource = new SystemParticipantSource(
Mock(TypeSource),
Mock(ThermalSource),
Mock(RawGridSource),
new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy))
def sysPartTypedEntityData = new SystemParticipantTypedEntityData<>(fieldsToAttributes, HpInput, sptd.hpInput.operator, sptd.hpInput.node, sptd.hpTypeInput)
when:
def hpInputEntityDataOpt = csvSystemParticipantSource.buildHpEntityData(sysPartTypedEntityData, thermalBuses)
then:
hpInputEntityDataOpt.success == resultIsPresent
hpInputEntityDataOpt.data.ifPresent({ hpInputEntityData ->
assert (hpInputEntityData == resultData)
})
where:
thermalBuses | fieldsToAttributes || resultIsPresent || resultData
[] | ["thermalBus": "0d95d7f2-49fb-4d49-8636-383a5220384e"] || false || null
[sptd.hpInput.thermalBus] | ["bla": "foo"] || false || null
[sptd.hpInput.thermalBus] | [:] || false || null
[sptd.hpInput.thermalBus] | ["thermalBus": "0d95d7f2-49fb-4d49-8636-383a5220384f"] || false || null
[sptd.hpInput.thermalBus] | ["thermalBus": "0d95d7f2-49fb-4d49-8636-383a5220384e"] || true || new HpInputEntityData([:], sptd.hpInput.operator, sptd.hpInput.node, sptd.hpTypeInput, sptd.hpInput.thermalBus)
}
def "A SystemParticipantSource with csv input should build chp input entity from valid and invalid input data as expected"(List<ThermalStorageInput> thermalStorages, List<ThermalBusInput> thermalBuses, Map<String, String> fieldsToAttributes, boolean resultIsPresent, ChpInputEntityData resultData) {
given:
def csvSystemParticipantSource = new SystemParticipantSource(
Mock(TypeSource),
Mock(ThermalSource),
Mock(RawGridSource),
new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy))
def sysPartTypedEntityData = new SystemParticipantTypedEntityData<>(fieldsToAttributes, ChpInput, sptd.chpInput.operator, sptd.chpInput.node, sptd.chpTypeInput)
when:
def hpInputEntityDataOpt = csvSystemParticipantSource.buildChpEntityData(sysPartTypedEntityData, thermalStorages, thermalBuses)
then:
hpInputEntityDataOpt.success == resultIsPresent
hpInputEntityDataOpt.data.ifPresent({ hpInputEntityData ->
assert (hpInputEntityData == resultData)
})
where:
thermalStorages | thermalBuses | fieldsToAttributes || resultIsPresent | resultData
[] as List | [] as List | ["thermalBus": "0d95d7f2-49fb-4d49-8636-383a5220384e", "thermalStorage": "8851813b-3a7d-4fee-874b-4df9d724e4b3"] || false | null
[
sptd.chpInput.thermalStorage
] as List | [sptd.chpInput.thermalBus] as List | ["bla": "foo"] || false | null
[
sptd.chpInput.thermalStorage
] as List | [sptd.chpInput.thermalBus] as List | [:] || false | null
[
sptd.chpInput.thermalStorage
] as List | [sptd.chpInput.thermalBus] as List | ["thermalBus": "0d95d7f2-49fb-4d49-8636-383a5220384e", "thermalStorage": "8851813b-3a7d-4fee-874b-4df9d724e4b3"] || true | new ChpInputEntityData([:], sptd.chpInput.operator, sptd.chpInput.node, sptd.chpTypeInput, sptd.chpInput.thermalBus, sptd.chpInput.thermalStorage)
}
def "A SystemParticipantSource with csv input should return data from a valid heat pump input file as expected"() {
given:
def csvSystemParticipantSource = new SystemParticipantSource(
Mock(TypeSource),
Mock(ThermalSource),
Mock(RawGridSource),
new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy))
expect:
def heatPumps = Try.of(() -> csvSystemParticipantSource.getHeatPumps(nodes as Set, operators as Set, types as Set, thermalBuses as Set), SourceException)
if (heatPumps.success) {
heatPumps.data.get().size() == resultingSize
heatPumps.data.get() == resultingSet as Set
} else {
heatPumps.exception.get().class == SourceException
}
where:
nodes | operators | types | thermalBuses || resultingSize || resultingSet
[sptd.hpInput.node] | [sptd.hpInput.operator] | [sptd.hpInput.type] | [sptd.hpInput.thermalBus] || 1 || [sptd.hpInput]
[sptd.hpInput.node] | [] | [sptd.hpInput.type] | [sptd.hpInput.thermalBus] || 1 || [
new HpInput(sptd.hpInput.uuid, sptd.hpInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.hpInput.operationTime, sptd.hpInput.node, sptd.hpInput.thermalBus, sptd.hpInput.qCharacteristics, sptd.hpInput.type)
]
[] | [] | [] | [] || 0 || []
[sptd.hpInput.node] | [] | [] | [] || 0 || []
[sptd.hpInput.node] | [sptd.hpInput.operator] | [] | [] || 0 || []
[sptd.hpInput.node] | [sptd.hpInput.operator] | [sptd.hpInput.type] | [] || 0 || []
}
def "A SystemParticipantSource with csv input should return data from a valid chp input file as expected"() {
given:
def csvSystemParticipantSource = new SystemParticipantSource(
Mock(TypeSource),
Mock(ThermalSource),
Mock(RawGridSource),
new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy))
expect:
def chpUnits = Try.of(() -> csvSystemParticipantSource.getChpPlants(nodes as Set, operators as Set, types as Set, thermalBuses as Set, thermalStorages as Set), SourceException)
if (chpUnits.success) {
chpUnits.data.get().size() == resultingSize
chpUnits.data.get() == resultingSet as Set
} else {
chpUnits.exception.get().class == SourceException
}
where:
nodes | operators | types | thermalBuses | thermalStorages || resultingSize || resultingSet
[sptd.chpInput.node]| [sptd.chpInput.operator]| [sptd.chpInput.type]| [sptd.chpInput.thermalBus]| [
sptd.chpInput.thermalStorage
] as List || 1 || [sptd.chpInput]
[sptd.chpInput.node]| []| [sptd.chpInput.type]| [sptd.chpInput.thermalBus]| [
sptd.chpInput.thermalStorage
] as List || 1 || [
new ChpInput(sptd.chpInput.uuid, sptd.chpInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.chpInput.operationTime, sptd.chpInput.node, sptd.chpInput.thermalBus, sptd.chpInput.qCharacteristics, sptd.chpInput.type, sptd.chpInput.thermalStorage, sptd.chpInput.marketReaction)
]
[] | [] | [] | [] | [] as List || 0 || []
[sptd.chpInput.node] | [] | [] | [] | [] as List || 0 || []
[sptd.chpInput.node] | [sptd.chpInput.operator] | [] | [] | [] as List || 0 || []
[sptd.chpInput.node] | [sptd.chpInput.operator] | [sptd.chpInput.type] | [] | [] as List || 0 || []
}
def "A SystemParticipantSource with csv input should return data from valid ev input file as expected"() {
given:
def csvSystemParticipantSource = new SystemParticipantSource(
Mock(TypeSource),
Mock(ThermalSource),
Mock(RawGridSource),
new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy))
expect:
def sysParts = Try.of(() -> csvSystemParticipantSource.getEvs(nodes as Set, operators as Set, types as Set), SourceException)
if (sysParts.success) {
sysParts.data.get().size() == resultingSize
sysParts.data.get() == resultingSet as Set
} else {
sysParts.exception.get().class == SourceException
}
where:
nodes | operators | types || resultingSize || resultingSet
[sptd.evInput.node] | [sptd.evInput.operator] | [sptd.evInput.type] || 1 || [sptd.evInput]
[sptd.evInput.node] | [] | [sptd.evInput.type] || 1 || [
new EvInput(sptd.evInput.uuid, sptd.evInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.evInput.operationTime, sptd.evInput.node, sptd.evInput.qCharacteristics, sptd.evInput.type)
]
[sptd.evInput.node] | [sptd.evInput.operator] | [] || 0 || []
[sptd.evInput.node] | [] | [] || 0 || []
[] | [] | [] || 0 || []
}
def "A SystemParticipantSource with csv input should return data from valid wec input file as expected"() {
given:
def csvSystemParticipantSource = new SystemParticipantSource(
Mock(TypeSource),
Mock(ThermalSource),
Mock(RawGridSource),
new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy))
expect:
def sysParts = Try.of(() -> csvSystemParticipantSource.getWecPlants(nodes as Set, operators as Set, types as Set), SourceException)
if (sysParts.success) {
sysParts.data.get().size() == resultingSize
sysParts.data.get() == resultingSet as Set
} else {
sysParts.exception.get().class == SourceException
}
where:
nodes | operators | types || resultingSize || resultingSet
[sptd.wecInput.node] | [sptd.wecInput.operator] | [sptd.wecInput.type] || 1 || [sptd.wecInput]
[sptd.wecInput.node] | [] | [sptd.wecInput.type] || 1 || [
new WecInput(sptd.wecInput.uuid, sptd.wecInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.wecInput.operationTime, sptd.wecInput.node, sptd.wecInput.qCharacteristics, sptd.wecInput.type, sptd.wecInput.marketReaction)
]
[sptd.wecInput.node] | [sptd.wecInput.operator] | [] || 0 || []
[sptd.wecInput.node] | [] | [] || 0 || []
[] | [] | [] || 0 || []
}
def "A SystemParticipantSource with csv input should return data from valid storage input file as expected"() {
given:
def csvSystemParticipantSource = new SystemParticipantSource(
Mock(TypeSource),
Mock(ThermalSource),
Mock(RawGridSource),
new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy))
expect:
def sysParts = Try.of(() -> csvSystemParticipantSource.getStorages(nodes as Set, operators as Set, types as Set), SourceException)
if (sysParts.success) {
sysParts.data.get().size() == resultingSize
sysParts.data.get() == resultingSet as Set
} else {
sysParts.exception.get().class == SourceException
}
where:
nodes | operators | types || resultingSize || resultingSet
[sptd.storageInput.node] | [sptd.storageInput.operator] | [sptd.storageInput.type] || 1 || [sptd.storageInput]
[sptd.storageInput.node] | [] | [sptd.storageInput.type] || 1 || [
new StorageInput(sptd.storageInput.uuid, sptd.storageInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.storageInput.operationTime, sptd.storageInput.node, sptd.storageInput.qCharacteristics, sptd.storageInput.type)
]
[sptd.storageInput.node] | [sptd.storageInput.operator] | [] || 0 || []
[sptd.storageInput.node] | [] | [] || 0 || []
[] | [] | [] || 0 || []
}
def "A SystemParticipantSource with csv input should return data from valid bm input file as expected"() {
given:
def csvSystemParticipantSource = new SystemParticipantSource(
Mock(TypeSource),
Mock(ThermalSource),
Mock(RawGridSource),
new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy))
expect:
def sysParts = Try.of(() -> csvSystemParticipantSource.getBmPlants(nodes as Set, operators as Set, types as Set), SourceException)
if (sysParts.success) {
sysParts.data.get().size() == resultingSize
sysParts.data.get() == resultingSet as Set
} else {
sysParts.exception.get().class == SourceException
}
where:
nodes | operators | types || resultingSize || resultingSet
[sptd.bmInput.node] | [sptd.bmInput.operator] | [sptd.bmInput.type] || 1 || [sptd.bmInput]
[sptd.bmInput.node] | [] | [sptd.bmInput.type] || 1 || [
new BmInput(sptd.bmInput.uuid, sptd.bmInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.bmInput.operationTime, sptd.bmInput.node, sptd.bmInput.qCharacteristics, sptd.bmInput.type, sptd.bmInput.marketReaction, sptd.bmInput.costControlled, sptd.bmInput.feedInTariff)
]
[sptd.bmInput.node] | [sptd.bmInput.operator] | [] || 0 || []
[sptd.bmInput.node] | [] | [] || 0 || []
[] | [] | [] || 0 || []
}
def "A SystemParticipantSource with csv input should return data from valid ev charging station input file as expected"() {
given:
def csvSystemParticipantSource = new SystemParticipantSource(
Mock(TypeSource),
Mock(ThermalSource),
Mock(RawGridSource),
new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy))
expect:
def sysParts = Try.of(() -> csvSystemParticipantSource.getEvCS(nodes as Set, operators as Set), SourceException)
if (sysParts.success) {
sysParts.data.get().size() == resultingSize
sysParts.data.get() == resultingSet as Set
} else {
sysParts.exception.get().class == SourceException
}
where:
nodes | operators || resultingSize || resultingSet
[sptd.evcsInput.node] | [sptd.evcsInput.operator] || 1 || [sptd.evcsInput]
[sptd.evcsInput.node] | [] || 1 || [
new EvcsInput(sptd.evcsInput.uuid, sptd.evcsInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.evcsInput.operationTime, sptd.evcsInput.node, sptd.evcsInput.qCharacteristics, sptd.evcsInput.type, sptd.evcsInput.chargingPoints, sptd.evcsInput.cosPhiRated, sptd.evcsInput.locationType, sptd.evcsInput.v2gSupport)
]
[]| [sptd.evcsInput.operator]|| 0 || []
[]| []|| 0 || []
}
def "A SystemParticipantSource with csv input should return data from valid load input file as expected"() {
given:
def csvSystemParticipantSource = new SystemParticipantSource(
Mock(TypeSource),
Mock(ThermalSource),
Mock(RawGridSource),
new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy))
expect:
def sysParts = Try.of(() -> csvSystemParticipantSource.getLoads(nodes as Set, operators as Set), SourceException)
if (sysParts.success) {
sysParts.data.get().size() == resultingSize
sysParts.data.get() == resultingSet as Set
} else {
sysParts.exception.get().class == SourceException
}
where:
nodes | operators || resultingSize || resultingSet
[sptd.loadInput.node] | [sptd.loadInput.operator] || 1 || [sptd.loadInput]
[sptd.loadInput.node] | [] || 1 || [
new LoadInput(sptd.loadInput.uuid, sptd.loadInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.loadInput.operationTime, sptd.loadInput.node, sptd.loadInput.qCharacteristics, sptd.loadInput.loadProfile, sptd.loadInput.dsm, sptd.loadInput.eConsAnnual, sptd.loadInput.sRated, sptd.loadInput.cosPhiRated)
]
[] | [sptd.loadInput.operator] || 0 || []
[] | [] || 0 || []
}
def "A SystemParticipantSource with csv input should return data from valid pv input file as expected"() {
given:
def csvSystemParticipantSource = new SystemParticipantSource(
Mock(TypeSource),
Mock(ThermalSource),
Mock(RawGridSource),
new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy))
expect:
def sysParts = Try.of(() -> csvSystemParticipantSource.getPvPlants(nodes as Set, operators as Set), SourceException)
if (sysParts.success) {
sysParts.data.get().size() == resultingSize
sysParts.data.get() == resultingSet as Set
} else {
sysParts.exception.get().class == SourceException
}
where:
nodes | operators || resultingSize || resultingSet
[sptd.pvInput.node] | [sptd.pvInput.operator] || 1 || [sptd.pvInput]
[sptd.pvInput.node] | [] || 1 || [
new PvInput(sptd.pvInput.uuid, sptd.pvInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.pvInput.operationTime, sptd.pvInput.node, sptd.pvInput.qCharacteristics, sptd.pvInput.albedo, sptd.pvInput.azimuth, sptd.pvInput.etaConv, sptd.pvInput.elevationAngle, sptd.pvInput.kG, sptd.pvInput.kT, sptd.pvInput.marketReaction, sptd.pvInput.sRated, sptd.pvInput.cosPhiRated)
]
[] | [sptd.pvInput.operator] || 0 || []
[] | [] || 0 || []
}
def "A SystemParticipantSource with csv input should return data from valid fixedFeedIn input file as expected"() {
given:
def csvSystemParticipantSource = new SystemParticipantSource(
Mock(TypeSource),
Mock(ThermalSource),
Mock(RawGridSource),
new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy))
expect:
def sysParts = Try.of(() -> csvSystemParticipantSource.getFixedFeedIns(nodes as Set, operators as Set), SourceException)
if (sysParts.success) {
sysParts.data.get().size() == resultingSize
sysParts.data.get() == resultingSet as Set
} else {
sysParts.exception.get().class == SourceException
}
where:
nodes | operators || resultingSize || resultingSet
[sptd.fixedFeedInInput.node] | [
sptd.fixedFeedInInput.operator
] as List || 1 || [sptd.fixedFeedInInput]
[sptd.fixedFeedInInput.node] | [] as List || 1 || [
new FixedFeedInInput(sptd.fixedFeedInInput.uuid, sptd.fixedFeedInInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.fixedFeedInInput.operationTime, sptd.fixedFeedInInput.node, sptd.fixedFeedInInput.qCharacteristics, sptd.fixedFeedInInput.sRated, sptd.fixedFeedInInput.cosPhiRated)
]
[] | [
sptd.fixedFeedInInput.operator
] as List || 0 || []
[] | [] as List || 0 || []
}
}