-
Notifications
You must be signed in to change notification settings - Fork 5
/
GridAndGeoUtilsTest.groovy
64 lines (50 loc) · 2.05 KB
/
GridAndGeoUtilsTest.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
/*
* © 2021. TU Dortmund University,
* Institute of Energy Systems, Energy Efficiency and Energy Economics,
* Research group Distribution grid planning and operation
*/
package edu.ie3.datamodel.utils
import static edu.ie3.util.quantities.PowerSystemUnits.*
import edu.ie3.test.common.GridTestData
import edu.ie3.util.geo.GeoUtils
import edu.ie3.util.quantities.QuantityUtil
import spock.lang.Shared
import spock.lang.Specification
import tech.units.indriya.quantity.Quantities
class GridAndGeoUtilsTest extends Specification {
@Shared
double testingTolerance = 1E-12
def "Grid and geo utils refuse instantiation"() {
when:
new GridAndGeoUtils()
then:
def e = thrown(IllegalStateException)
e.message == "Utility classes cannot be instantiated."
}
def "The grid and geo utils should calculate distance between two nodes correctly"() {
given:
def nodeA = GridTestData.nodeA
def nodeB = GridTestData.nodeB
def expectedDistance = Quantities.getQuantity(0.91356787076109815268517, KILOMETRE)
when:
def actualDistance = GridAndGeoUtils.distanceBetweenNodes(nodeA, nodeB)
then:
QuantityUtil.isEquivalentAbs(expectedDistance, actualDistance, testingTolerance)
}
def "The grid and geo utils build a correct line string between nodes with disjoint coordinates"() {
given:
def expectedLineString = GeoUtils.buildSafeLineStringBetweenPoints(GridTestData.nodeA.geoPosition, GridTestData.nodeB.geoPosition)
when:
def actualLineString = GridAndGeoUtils.buildSafeLineStringBetweenNodes(GridTestData.nodeA, GridTestData.nodeB)
then:
actualLineString == expectedLineString
}
def "The grid and geo utils build a correct line string between nodes with same coordinates"() {
given:
def expectedLineString = GeoUtils.buildSafeLineStringBetweenPoints(GridTestData.nodeA.geoPosition, GridTestData.nodeA.geoPosition)
when:
def actualLineString = GridAndGeoUtils.buildSafeLineStringBetweenNodes(GridTestData.nodeA, GridTestData.nodeA)
then:
actualLineString == expectedLineString
}
}