-
Notifications
You must be signed in to change notification settings - Fork 5
/
EmInputTest.groovy
92 lines (78 loc) · 2.73 KB
/
EmInputTest.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
/*
* © 2022. TU Dortmund University,
* Institute of Energy Systems, Energy Efficiency and Energy Economics,
* Research group Distribution grid planning and operation
*/
package edu.ie3.datamodel.models.input.system
import edu.ie3.datamodel.models.input.EmInput
import edu.ie3.test.common.SystemParticipantTestData
import spock.lang.Specification
class EmInputTest extends Specification {
def "The EmInput constructors work as expected"() {
when:
def emInput = new EmInput(
UUID.fromString("977157f4-25e5-4c72-bf34-440edc778792"),
"test_emInput",
SystemParticipantTestData.emControlStrategy,
SystemParticipantTestData.parentEm
)
then:
emInput.with {
assert uuid == UUID.fromString("977157f4-25e5-4c72-bf34-440edc778792")
assert id == "test_emInput"
assert controlStrategy == SystemParticipantTestData.emControlStrategy
}
}
def "EmInputs are comparable"() {
given:
def emInputA = SystemParticipantTestData.emInput
expect:
(emInputA == emInputB) == isEqual
where:
emInputB || isEqual
SystemParticipantTestData.emInput || true
SystemParticipantTestData.emInput.copy().build() || true
SystemParticipantTestData.emInput.copy().id("otherId").build() || false
}
def "The EmInput to String method work as expected"() {
given:
def emInputToString = SystemParticipantTestData.emInput.toString()
expect:
emInputToString == "EmInput{" +
"uuid=" +
SystemParticipantTestData.emInput.uuid +
", id='" +
SystemParticipantTestData.emInput.id +
"', operator=" +
SystemParticipantTestData.emInput.operator.uuid +
", operationTime=" +
SystemParticipantTestData.emInput.operationTime +
", controlStrategy=" +
SystemParticipantTestData.emInput.controlStrategy +
", controllingEm=" +
SystemParticipantTestData.parentEm.uuid +
"}"
}
def "A EmInput copy method should work as expected"() {
given:
def emInput = SystemParticipantTestData.emInput
def newStrat = "new_strat"
def givenParentEm = new EmInput(
UUID.fromString("cfc0639b-65bc-47e5-a8e5-82703de3c650"),
"testParent",
"controlStrat",
null
)
when:
def alteredUnit = emInput.copy().controlStrategy(newStrat).parentEm(givenParentEm).build()
then:
alteredUnit.with {
assert uuid == emInput.uuid
assert operationTime == emInput.operationTime
assert operator == emInput.operator
assert id == emInput.id
assert controlStrategy == newStrat
assert controllingEm == Optional.of(givenParentEm)
}
}
}