-
Notifications
You must be signed in to change notification settings - Fork 5
/
OperatorInputFactoryTest.groovy
46 lines (38 loc) · 1.44 KB
/
OperatorInputFactoryTest.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
/*
* © 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.input
import edu.ie3.datamodel.io.factory.FactoryData
import edu.ie3.datamodel.io.factory.SimpleEntityData
import edu.ie3.datamodel.models.input.OperatorInput
import edu.ie3.datamodel.utils.Try
import spock.lang.Specification
class OperatorInputFactoryTest extends Specification {
def "An OperatorInputFactory should contain exactly the expected class for parsing"() {
given:
def inputFactory = new OperatorInputFactory()
def expectedClasses = [OperatorInput]
expect:
inputFactory.supportedClasses == Arrays.asList(expectedClasses.toArray())
}
def "An OperatorInputFactory should parse a valid OperatorInput correctly"() {
given: "a operator input factory and model data"
def inputFactory = new OperatorInputFactory()
Map<String, String> parameter = [
"uuid": "91ec3bcf-1777-4d38-af67-0bf7c9fa73c7",
"id" : "TestOperatorId",
]
def inputClass = OperatorInput
when:
Try<OperatorInput> input = inputFactory.get(new SimpleEntityData(new FactoryData.MapWithRowIndex("-1", parameter), inputClass))
then:
input.success
input.data().getClass() == inputClass
input.data().with {
assert uuid == UUID.fromString(parameter["uuid"])
assert id == parameter["id"]
}
}
}