-
Notifications
You must be signed in to change notification settings - Fork 5
/
SwitchResultFactoryTest.groovy
49 lines (40 loc) · 1.65 KB
/
SwitchResultFactoryTest.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
/*
* © 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.result
import edu.ie3.datamodel.io.factory.FactoryData
import edu.ie3.datamodel.io.factory.SimpleEntityData
import edu.ie3.datamodel.models.result.connector.SwitchResult
import edu.ie3.datamodel.utils.Try
import edu.ie3.test.helper.FactoryTestHelper
import spock.lang.Specification
class SwitchResultFactoryTest extends Specification implements FactoryTestHelper {
def "A SwitchResultFactory should contain all expected classes for parsing"() {
given:
def resultFactory = new SwitchResultFactory()
def expectedClasses = [SwitchResult]
expect:
resultFactory.supportedClasses == Arrays.asList(expectedClasses.toArray())
}
def "A SwitchResultFactory should parse a valid result model correctly"() {
given: "a switch result factory and model data"
def resultFactory = new SwitchResultFactory()
Map<String, String> parameter = [
"time" : "2020-01-30 17:26:44",
"inputModel": "91ec3bcf-1777-4d38-af67-0bf7c9fa73c7",
"closed" : "true"
]
when:
Try<SwitchResult> result = resultFactory.get(new SimpleEntityData(new FactoryData.MapWithRowIndex("-1", parameter), SwitchResult))
then:
result.success
result.data().getClass() == SwitchResult
((SwitchResult) result.data()).with {
assert time == TIME_UTIL.toZonedDateTime(parameter["time"])
assert inputModel == UUID.fromString(parameter["inputModel"])
assert closed == Boolean.parseBoolean(parameter["closed"])
}
}
}