-
Notifications
You must be signed in to change notification settings - Fork 5
/
CylindricalStorageInputFactoryTest.groovy
62 lines (56 loc) · 2.64 KB
/
CylindricalStorageInputFactoryTest.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
/*
* © 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.factory.input
import edu.ie3.datamodel.io.factory.FactoryData
import edu.ie3.datamodel.models.OperationTime
import edu.ie3.datamodel.models.StandardUnits
import edu.ie3.datamodel.models.input.OperatorInput
import edu.ie3.datamodel.models.input.thermal.CylindricalStorageInput
import edu.ie3.datamodel.models.input.thermal.ThermalBusInput
import edu.ie3.datamodel.utils.Try
import edu.ie3.test.helper.FactoryTestHelper
import spock.lang.Specification
class CylindricalStorageInputFactoryTest extends Specification implements FactoryTestHelper {
def "A CylindricalStorageInputFactory should contain exactly the expected class for parsing"() {
given:
def inputFactory = new CylindricalStorageInputFactory()
def expectedClasses = [CylindricalStorageInput]
expect:
inputFactory.supportedClasses == Arrays.asList(expectedClasses.toArray())
}
def "A CylindricalStorageInputFactory should parse a valid CylindricalStorageInput correctly"() {
given: "a system participant input type factory and model data"
def inputFactory = new CylindricalStorageInputFactory()
Map<String, String> parameter = [
"uuid" : "91ec3bcf-1777-4d38-af67-0bf7c9fa73c7",
"id" : "TestID",
"storagevolumelvl" : "3",
"storagevolumelvlmin": "4",
"inlettemp" : "5",
"returntemp" : "6",
"c" : "7"
]
def inputClass = CylindricalStorageInput
def thermalBusInput = Mock(ThermalBusInput)
when:
Try<CylindricalStorageInput> input = inputFactory.get(new ThermalUnitInputEntityData(new FactoryData.MapWithRowIndex("-1", parameter), inputClass, thermalBusInput))
then:
input.success
input.data().getClass() == inputClass
input.data().with {
assert uuid == UUID.fromString(parameter["uuid"])
assert operationTime == OperationTime.notLimited()
assert operator == OperatorInput.NO_OPERATOR_ASSIGNED
assert id == parameter["id"]
assert thermalBus == thermalBusInput
assert storageVolumeLvl == getQuant(parameter["storagevolumelvl"], StandardUnits.VOLUME)
assert storageVolumeLvlMin == getQuant(parameter["storagevolumelvlmin"], StandardUnits.VOLUME)
assert inletTemp == getQuant(parameter["inlettemp"], StandardUnits.TEMPERATURE)
assert returnTemp == getQuant(parameter["returntemp"], StandardUnits.TEMPERATURE)
assert c == getQuant(parameter["c"], StandardUnits.SPECIFIC_HEAT_CAPACITY)
}
}
}