-
Notifications
You must be signed in to change notification settings - Fork 5
/
CommonVoltageLevelTest.groovy
60 lines (50 loc) · 2.34 KB
/
CommonVoltageLevelTest.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
/*
* © 2021. TU Dortmund University,
* Institute of Energy Systems, Energy Efficiency and Energy Economics,
* Research group Distribution grid planning and operation
*/
package edu.ie3.datamodel.models
import edu.ie3.datamodel.exceptions.VoltageLevelException
import edu.ie3.datamodel.models.voltagelevels.CommonVoltageLevel
import edu.ie3.util.interval.RightOpenInterval
import spock.lang.Shared
import spock.lang.Specification
import tech.units.indriya.quantity.Quantities
import static edu.ie3.util.quantities.PowerSystemUnits.KILOVOLT
import static tech.units.indriya.unit.Units.VOLT
class CommonVoltageLevelTest extends Specification {
@Shared
CommonVoltageLevel dut = new CommonVoltageLevel(
"Niederspannung",
Quantities.getQuantity(0.4, KILOVOLT),
new HashSet<>(Arrays.asList("lv", "ns")),
new RightOpenInterval<>(
Quantities.getQuantity(0d, KILOVOLT), Quantities.getQuantity(10d, KILOVOLT)))
def "A common voltage level should correctly check, if a valid rated voltage is covered"() {
expect:
dut.covers(Quantities.getQuantity(500d, VOLT)) // May be true
}
def "A common voltage level should correctly check, if a outlying rated voltage is covered"() {
expect:
!dut.covers(Quantities.getQuantity(10d, KILOVOLT)) // May be false
}
def "A common voltage level should correctly check, if the upper boundary of rated voltages is covered"() {
expect:
!dut.covers(Quantities.getQuantity(10d, KILOVOLT)) // May be false, because the interval is right open
}
def "A common voltage level should correctly check, if a valid id / rated voltage combination is covered"() {
expect:
dut.covers("Niederspannung", Quantities.getQuantity(500d, VOLT)) // May be true
}
def "A common voltage level should correctly check, if an invalid id / rated voltage combination is covered"() {
expect:
!dut.covers("HS", Quantities.getQuantity(110d, KILOVOLT)) // May be false
}
def "A common voltage level should thrown an exception, if an inconsistent id / rated voltage combination is checked"() {
when:
dut.covers("HS", Quantities.getQuantity(500d, VOLT)) // May be true
then:
VoltageLevelException ex = thrown()
ex.message == "The provided id \"HS\" and rated voltage \"500 V\" could possibly meet the voltage level \"Niederspannung\" (Interval [0.0 kV, 10 kV)), but are inconsistent."
}
}