-
Notifications
You must be signed in to change notification settings - Fork 5
/
GraphicValidationUtilsTest.groovy
71 lines (57 loc) · 2.53 KB
/
GraphicValidationUtilsTest.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
/*
* © 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.validation
import edu.ie3.datamodel.exceptions.InvalidEntityException
import edu.ie3.test.common.GridTestData
import spock.lang.Specification
class GraphicValidationUtilsTest extends Specification {
def "Smoke Test: Correct graphic input throws no exception"() {
given:
def lineGraphicInput = GridTestData.lineGraphicCtoD
def nodeGraphicInput = GridTestData.nodeGraphicC
when:
ValidationUtils.check(lineGraphicInput)
then:
noExceptionThrown()
when:
ValidationUtils.check(nodeGraphicInput)
then:
noExceptionThrown()
}
def "GraphicValidationUtils.check() recognizes all potential errors for a graphic input"() {
when:
GraphicValidationUtils.check(invalidGraphicInput)
then:
Exception ex = thrown()
ex.class == expectedException.class
ex.message == expectedException.message
where:
invalidGraphicInput || expectedException
GridTestData.lineGraphicCtoD.copy().graphicLayer(null).build() || new InvalidEntityException("Graphic Layer of graphic element is not defined", invalidGraphicInput)
}
def "GraphicValidationUtils.checkLineGraphicInput() recognizes all potential errors for a line graphic input"() {
when:
GraphicValidationUtils.check(invalidLineGraphicInput)
then:
Exception ex = thrown()
ex.class == expectedException.class
ex.message == expectedException.message
where:
invalidLineGraphicInput || expectedException
GridTestData.lineGraphicCtoD.copy().path(null).build() || new InvalidEntityException("Path of line graphic element is not defined", invalidLineGraphicInput)
}
def "GraphicValidationUtils.checkNodeGraphicInput() recognizes all potential errors for a line graphic input"() {
when:
GraphicValidationUtils.check(invalidNodeGraphicInput)
then:
Exception ex = thrown()
ex.class == expectedException.class
ex.message == expectedException.message
where:
invalidNodeGraphicInput || expectedException
GridTestData.nodeGraphicC.copy().point(null).build() || new InvalidEntityException("Point of node graphic is not defined", invalidNodeGraphicInput)
}
}