-
Notifications
You must be signed in to change notification settings - Fork 5
/
CsvThermalSourceTest.groovy
135 lines (118 loc) · 7.34 KB
/
CsvThermalSourceTest.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
/*
* © 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.io.naming.FileNamingStrategy
import edu.ie3.datamodel.io.source.ThermalSource
import edu.ie3.datamodel.io.source.TypeSource
import edu.ie3.test.common.SystemParticipantTestData as sptd
import edu.ie3.test.common.ThermalUnitInputTestData
import spock.lang.Specification
class CsvThermalSourceTest extends Specification implements CsvTestDataMeta {
def "A CsvThermalSource should return ThermalBuses from valid and invalid input data as expected"() {
given:
def csvTypeSource = new TypeSource(new CsvDataSource(",", typeFolderPath, new FileNamingStrategy()))
def csvThermalSource = new ThermalSource(csvTypeSource, new CsvDataSource(csvSep, thermalFolderPath, fileNamingStrategy))
def operators = csvTypeSource.operators
//test method when no operators are provided as constructor parameters
when:
def resultingThermalBusesWoOperator = csvThermalSource.getThermalBuses()
then:
resultingThermalBusesWoOperator.size() == 1
def thermalBusWoOp = resultingThermalBusesWoOperator.values().first()
thermalBusWoOp.uuid == sptd.thermalBus.uuid
thermalBusWoOp.id == sptd.thermalBus.id
thermalBusWoOp.operator == sptd.thermalBus.operator
thermalBusWoOp.operationTime == sptd.thermalBus.operationTime
//test method when operators are provided as constructor parameters
when:
def resultingThermalBuses = csvThermalSource.getThermalBuses(operators)
then:
resultingThermalBuses.size() == 1
def thermalBus = resultingThermalBuses.values().first()
thermalBus.uuid == sptd.thermalBus.uuid
thermalBus.id == sptd.thermalBus.id
thermalBus.operator == sptd.thermalBus.operator
thermalBus.operationTime == sptd.thermalBus.operationTime
}
def "A CsvThermalSource should return a CylindricalStorageInput from valid and invalid input data as expected"() {
given:
def csvTypeSource = new TypeSource(new CsvDataSource(",", typeFolderPath, new FileNamingStrategy()))
def csvThermalSource = new ThermalSource(csvTypeSource, new CsvDataSource(csvSep, thermalFolderPath, fileNamingStrategy))
def operators = csvTypeSource.operators
def thermalBuses = csvThermalSource.thermalBuses
//test method when operators and thermal buses are not provided as constructor parameters
when:
def resultingCylindricalStorageWoOperator = csvThermalSource.getCylindricalStorages()
then:
resultingCylindricalStorageWoOperator.size() == 1
resultingCylindricalStorageWoOperator.first().uuid == sptd.thermalStorage.uuid
resultingCylindricalStorageWoOperator.first().id == sptd.thermalStorage.id
resultingCylindricalStorageWoOperator.first().operator == sptd.thermalStorage.operator
resultingCylindricalStorageWoOperator.first().operationTime == sptd.thermalStorage.operationTime
resultingCylindricalStorageWoOperator.first().thermalBus == sptd.thermalStorage.thermalBus
resultingCylindricalStorageWoOperator.first().storageVolumeLvl == sptd.storageVolumeLvl
resultingCylindricalStorageWoOperator.first().storageVolumeLvlMin == sptd.storageVolumeLvlMin
resultingCylindricalStorageWoOperator.first().inletTemp == sptd.inletTemp
resultingCylindricalStorageWoOperator.first().returnTemp == sptd.returnTemp
resultingCylindricalStorageWoOperator.first().c == sptd.c
//test method when operators and thermal buses are provided as constructor parameters
when:
def resultingCylindricalStorage = csvThermalSource.getCylindricalStorages(operators, thermalBuses)
then:
resultingCylindricalStorage.size() == 1
resultingCylindricalStorage.first().uuid == sptd.thermalStorage.uuid
resultingCylindricalStorage.first().id == sptd.thermalStorage.id
resultingCylindricalStorage.first().operator == sptd.thermalStorage.operator
resultingCylindricalStorage.first().operationTime == sptd.thermalStorage.operationTime
resultingCylindricalStorage.first().thermalBus == sptd.thermalStorage.thermalBus
resultingCylindricalStorage.first().storageVolumeLvl == sptd.storageVolumeLvl
resultingCylindricalStorage.first().storageVolumeLvlMin == sptd.storageVolumeLvlMin
resultingCylindricalStorage.first().inletTemp == sptd.inletTemp
resultingCylindricalStorage.first().returnTemp == sptd.returnTemp
resultingCylindricalStorage.first().c == sptd.c
}
def "A CsvThermalSource should return a ThermalHouseInput from valid and invalid input data as expected"() {
given:
def csvTypeSource = new TypeSource(new CsvDataSource(",", typeFolderPath, new FileNamingStrategy()))
def csvThermalSource = new ThermalSource(csvTypeSource, new CsvDataSource(csvSep, thermalFolderPath, fileNamingStrategy))
def operators = csvTypeSource.operators
def thermalBuses = csvThermalSource.thermalBuses
//test method when operators and thermal buses are not provided as constructor parameters
when:
def resultingThermalHouseWoOperator = csvThermalSource.getThermalHouses()
then:
resultingThermalHouseWoOperator.size() == 1
def thermalHouseWoOp = resultingThermalHouseWoOperator.values().first()
thermalHouseWoOp.uuid == ThermalUnitInputTestData.thermalHouseInput.uuid
thermalHouseWoOp.id == ThermalUnitInputTestData.thermalHouseInput.id
thermalHouseWoOp.operator == ThermalUnitInputTestData.thermalHouseInput.operator
thermalHouseWoOp.operationTime.isLimited()
thermalHouseWoOp.operationTime == ThermalUnitInputTestData.thermalHouseInput.operationTime
thermalHouseWoOp.thermalBus == ThermalUnitInputTestData.thermalHouseInput.thermalBus
thermalHouseWoOp.ethLosses == ThermalUnitInputTestData.thermalHouseInput.ethLosses
thermalHouseWoOp.ethCapa == ThermalUnitInputTestData.thermalHouseInput.ethCapa
thermalHouseWoOp.targetTemperature == ThermalUnitInputTestData.thermalHouseInput.targetTemperature
thermalHouseWoOp.upperTemperatureLimit == ThermalUnitInputTestData.thermalHouseInput.upperTemperatureLimit
thermalHouseWoOp.lowerTemperatureLimit == ThermalUnitInputTestData.thermalHouseInput.lowerTemperatureLimit
//test method when operators and thermal buses are provided as constructor parameters
when:
def resultingThermalHouse = csvThermalSource.getThermalHouses(operators, thermalBuses)
then:
resultingThermalHouse.size() == 1
def thermalHouse = resultingThermalHouse.values().first()
thermalHouse .uuid == ThermalUnitInputTestData.thermalHouseInput.uuid
thermalHouse.id == ThermalUnitInputTestData.thermalHouseInput.id
thermalHouse.operator == ThermalUnitInputTestData.thermalHouseInput.operator
thermalHouse.operationTime.isLimited()
thermalHouse.operationTime == ThermalUnitInputTestData.thermalHouseInput.operationTime
thermalHouse.thermalBus == ThermalUnitInputTestData.thermalHouseInput.thermalBus
thermalHouse.ethLosses == ThermalUnitInputTestData.thermalHouseInput.ethLosses
thermalHouse.ethCapa == ThermalUnitInputTestData.thermalHouseInput.ethCapa
thermalHouse.targetTemperature == ThermalUnitInputTestData.thermalHouseInput.targetTemperature
thermalHouse.upperTemperatureLimit == ThermalUnitInputTestData.thermalHouseInput.upperTemperatureLimit
thermalHouse.lowerTemperatureLimit == ThermalUnitInputTestData.thermalHouseInput.lowerTemperatureLimit
}
}