@@ -4,10 +4,10 @@ import akka.actor.ActorSystem
44import akka.testkit.TestProbe
55import akka.testkit.javadsl.TestKit
66import edu.ie3.simona.api.data.ExtData
7- import edu.ie3.simona.api.simulation.ontology.ActivityStartTrigger
7+ import edu.ie3.simona.api.simulation.ontology.ActivationMessage
88import edu.ie3.simona.api.simulation.ontology.CompletionMessage
99import edu.ie3.simona.api.simulation.ontology.ControlMessageToExt
10- import edu.ie3.simona.api.simulation.ontology.Terminate
10+ import edu.ie3.simona.api.simulation.ontology.TerminationMessage
1111import edu.ie3.simona.api.simulation.ontology.TerminationCompleted
1212import spock.lang.Shared
1313import spock.lang.Specification
@@ -28,22 +28,22 @@ class ExtSimulationSpec extends Specification {
2828 */
2929 private class TestSimulation extends ExtSimulation {
3030
31- private List <Long > initReturnTicks
32- private List <Long > activityReturnTicks
31+ private Optional <Long > initReturnTicks
32+ private Optional <Long > activationReturnTick
3333
34- TestSimulation (List <Long > initReturnTicks , List <Long > activityReturnTicks ) {
35- this . initReturnTicks = initReturnTicks
36- this . activityReturnTicks = activityReturnTicks
34+ TestSimulation (Optional <Long > initReturnTick , Optional <Long > activationReturnTick ) {
35+ this . initReturnTicks = initReturnTick
36+ this . activationReturnTick = activationReturnTick
3737 }
3838
3939 @Override
40- protected List <Long > initialize () {
40+ protected Optional <Long > initialize () {
4141 return this . initReturnTicks
4242 }
4343
4444 @Override
45- protected List <Long > doActivity (long tick ) {
46- return this . activityReturnTicks
45+ protected Optional <Long > doActivity (long tick ) {
46+ return this . activationReturnTick
4747 }
4848 }
4949
@@ -63,39 +63,41 @@ class ExtSimulationSpec extends Specification {
6363 def " An ExtSimulation should handle initialization" () {
6464 given :
6565 def tick = -1L
66- def newTicks = [ 0L ]
66+ def newTick = Optional . of( 0L )
6767 def testProbe = new TestProbe (actorSystem)
6868 def extSimData = new ExtSimAdapterData (testProbe. ref(), new String [0 ])
69- def extSim = new TestSimulation (newTicks, [ -2L ] )
69+ def extSim = new TestSimulation (newTick, Optional . of( -2L ) )
7070 extSim. setup(extSimData, new ArrayList<ExtData > ())
7171
7272 when :
73- extSimData. queueExtMsg(new ActivityStartTrigger (tick))
73+ extSimData. queueExtMsg(new ActivationMessage (tick))
7474 def finishedActual = handleMessage. invoke(extSim)
7575
7676 then :
7777 finishedActual == false
78- testProbe. expectMsg(new CompletionMessage (newTicks ))
78+ testProbe. expectMsg(new CompletionMessage (newTick ))
7979 }
8080
8181 def " An ExtSimulation should handle activation and return given new triggers" () {
8282 given :
8383 def testProbe = new TestProbe (actorSystem)
8484 def extSimData = new ExtSimAdapterData (testProbe. ref(), new String [0 ])
85- def extSim = new TestSimulation ([-2L ], newTicks)
85+ def newTickOpt = newTick. isEmpty() ?
86+ Optional . < Long > empty() : Optional . of(newTick. first())
87+ def extSim = new TestSimulation (Optional . of(-2L ), newTickOpt)
8688 extSim. setup(extSimData, new ArrayList<ExtData > ())
8789
8890 when :
89- extSimData. queueExtMsg(new ActivityStartTrigger (tick))
91+ extSimData. queueExtMsg(new ActivationMessage (tick))
9092 def finishedActual = handleMessage. invoke(extSim)
9193
9294 then :
9395 finishedActual == finished
94- testProbe. expectMsg(new CompletionMessage (newTicks ))
96+ testProbe. expectMsg(new CompletionMessage (newTickOpt ))
9597
9698 where :
97- tick | newTicks || finished
98- 0L | [900L , 1800L ] || false
99+ tick | newTick || finished
100+ 0L | [900L ] || false
99101 3600L | [7200L ] || false
100102 7200L | [] || true
101103 10800L | [] || true
@@ -105,11 +107,11 @@ class ExtSimulationSpec extends Specification {
105107 given :
106108 def testProbe = new TestProbe (actorSystem)
107109 def extSimData = new ExtSimAdapterData (testProbe. ref(), new String [0 ])
108- def extSim = new TestSimulation ([], [] )
110+ def extSim = new TestSimulation (Optional . empty(), Optional . empty() )
109111 extSim. setup(extSimData, new ArrayList<ExtData > ())
110112
111113 when :
112- extSimData. queueExtMsg(new Terminate (simlulationSuccessful))
114+ extSimData. queueExtMsg(new TerminationMessage (simlulationSuccessful))
113115 def finishedActual = handleMessage. invoke(extSim)
114116
115117 then :
@@ -128,7 +130,7 @@ class ExtSimulationSpec extends Specification {
128130 given :
129131 def testProbe = new TestProbe (actorSystem)
130132 def extSimData = new ExtSimAdapterData (testProbe. ref(), new String [0 ])
131- def extSim = new TestSimulation ([], [] )
133+ def extSim = new TestSimulation (Optional . empty(), Optional . empty() )
132134 extSim. setup(extSimData, new ArrayList<ExtData > ())
133135
134136 when :
0 commit comments