-
Notifications
You must be signed in to change notification settings - Fork 5
/
Transformer3WTypeInputFactoryTest.groovy
84 lines (76 loc) · 3.26 KB
/
Transformer3WTypeInputFactoryTest.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
/*
* © 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.typeinput
import edu.ie3.test.helper.FactoryTestHelper
import edu.ie3.datamodel.io.factory.SimpleEntityData
import edu.ie3.datamodel.models.StandardUnits
import edu.ie3.datamodel.models.input.connector.type.Transformer3WTypeInput
import spock.lang.Specification
class Transformer3WTypeInputFactoryTest extends Specification implements FactoryTestHelper {
def "A Transformer3WTypeInputFactory should contain exactly the expected class for parsing"() {
given:
def typeInputFactory = new Transformer3WTypeInputFactory()
def expectedClasses = [Transformer3WTypeInput]
expect:
typeInputFactory.supportedClasses == Arrays.asList(expectedClasses.toArray())
}
def "A Transformer3WTypeInputFactory should parse a valid Transformer2WTypeInput correctly"() {
given: "a system participant input type factory and model data"
def typeInputFactory = new Transformer3WTypeInputFactory()
Map<String, String> parameter = [
"uuid": "91ec3bcf-1777-4d38-af67-0bf7c9fa73c7",
"id": "blablub",
"srateda": "3",
"sratedb": "4",
"sratedc": "5",
"vrateda": "6",
"vratedb": "7",
"vratedc": "8",
"rsca": "9",
"rscb": "10",
"rscc": "11",
"xsca": "12",
"xscb": "13",
"xscc": "14",
"gm": "15",
"bm": "16",
"dv": "17",
"dphi": "18",
"tapneutr": "19",
"tapmin": "20",
"tapmax": "21"
]
def typeInputClass = Transformer3WTypeInput
when:
Optional<Transformer3WTypeInput> typeInput = typeInputFactory.get(new SimpleEntityData(parameter, typeInputClass))
then:
typeInput.present
typeInput.get().getClass() == typeInputClass
typeInput.get().with {
assert uuid == UUID.fromString(parameter["uuid"])
assert id == parameter["id"]
assert sRatedA == getQuant(parameter["srateda"], StandardUnits.S_RATED)
assert sRatedB == getQuant(parameter["sratedb"], StandardUnits.S_RATED)
assert sRatedC == getQuant(parameter["sratedc"], StandardUnits.S_RATED)
assert vRatedA == getQuant(parameter["vrateda"], StandardUnits.RATED_VOLTAGE_MAGNITUDE)
assert vRatedB == getQuant(parameter["vratedb"], StandardUnits.RATED_VOLTAGE_MAGNITUDE)
assert vRatedC == getQuant(parameter["vratedc"], StandardUnits.RATED_VOLTAGE_MAGNITUDE)
assert rScA == getQuant(parameter["rsca"], StandardUnits.RESISTANCE)
assert rScB == getQuant(parameter["rscb"], StandardUnits.RESISTANCE)
assert rScC == getQuant(parameter["rscc"], StandardUnits.RESISTANCE)
assert xScA == getQuant(parameter["xsca"], StandardUnits.REACTANCE)
assert xScB == getQuant(parameter["xscb"], StandardUnits.REACTANCE)
assert xScC == getQuant(parameter["xscc"], StandardUnits.REACTANCE)
assert gM == getQuant(parameter["gm"], StandardUnits.CONDUCTANCE)
assert bM == getQuant(parameter["bm"], StandardUnits.SUSCEPTANCE)
assert dV == getQuant(parameter["dv"], StandardUnits.DV_TAP)
assert dPhi == getQuant(parameter["dphi"], StandardUnits.DPHI_TAP)
assert tapNeutr == Integer.parseInt(parameter["tapneutr"])
assert tapMin == Integer.parseInt(parameter["tapmin"])
assert tapMax == Integer.parseInt(parameter["tapmax"])
}
}
}