@@ -48,7 +48,7 @@ func TestEmptyWorkflow(t *testing.T) {
4848 u .AssertNonNil (t , wflow .Start )
4949 u .AssertNonNil (t , wflow .End )
5050 u .AssertNonNil (t , wflow .Tasks )
51- u .AssertEquals (t , wflow .Start .Next , wflow .End .GetId ())
51+ u .AssertEquals (t , wflow .Start .GetNext ()[ 0 ] , wflow .End .GetId ())
5252}
5353
5454// TestSimpleWorkflow creates a simple Workflow with one StartTask, two SimpleTask and one EndTask, executes it and gets the result.
@@ -72,7 +72,7 @@ func TestSimpleWorkflow(t *testing.T) {
7272 u .AssertEquals (t , len (wflow .Tasks )- 2 , length )
7373
7474 // tasks := workflow.NewNodeSetFrom(workflow.Tasks)
75- _ , found := wflow .Find (wflow .Start .Next )
75+ _ , found := wflow .Find (wflow .Start .GetNext ()[ 0 ] )
7676 u .AssertTrue (t , found )
7777 end := false
7878 var prevNode workflow.Task = wflow .Start
@@ -82,13 +82,13 @@ func TestSimpleWorkflow(t *testing.T) {
8282 case * workflow.StartTask :
8383 nextNodeId := prevNode .GetNext ()[0 ]
8484 currentNode , _ = wflow .Find (nextNodeId )
85- u .AssertEquals (t , prevNode .( * workflow. StartTask ). Next , currentNode .GetId ())
85+ u .AssertEquals (t , prevNode .GetNext ()[ 0 ] , currentNode .GetId ())
8686 case * workflow.EndTask :
8787 end = true
8888 default : // currentNode = simple node
8989 nextNodeId := prevNode .GetNext ()[0 ]
9090 currentNode , _ = wflow .Find (nextNodeId )
91- u .AssertEquals (t , prevNode .( * workflow. SimpleTask ). OutputTo , currentNode .GetId ())
91+ u .AssertEquals (t , prevNode .GetNext ()[ 0 ] , currentNode .GetId ())
9292 u .AssertTrue (t , prevNode .(* workflow.SimpleTask ).Func == f .Name )
9393 }
9494 prevNode = currentNode
@@ -118,17 +118,17 @@ func TestChoiceWorkflow(t *testing.T) {
118118 // u.AssertEquals(t, width+1, len(workflow.Tasks))
119119
120120 //tasks := workflow.NewNodeSetFrom(workflow.Tasks)
121- choiceWorkflow , found := wflow .Find (wflow .Start .Next )
121+ choiceWorkflow , found := wflow .Find (wflow .Start .GetNext ()[ 0 ] )
122122 choice := choiceWorkflow .(* workflow.ChoiceTask )
123123 u .AssertTrue (t , found )
124124 for _ , n := range wflow .Tasks {
125125 switch n .(type ) {
126126 case * workflow.ChoiceTask :
127- u .AssertEquals (t , len (choice .Conditions ), len (choice .Alternatives ))
128- for _ , s := range choice .Alternatives {
127+ u .AssertEquals (t , len (choice .Conditions ), len (choice .NextTasks ))
128+ for _ , s := range choice .NextTasks {
129129 simple , foundS := wflow .Find (s )
130130 u .AssertTrue (t , foundS )
131- u .AssertEquals (t , simple .( * workflow. SimpleTask ). OutputTo , wflow .End .GetId ())
131+ u .AssertEquals (t , simple .GetNext ()[ 0 ] , wflow .End .GetId ())
132132 }
133133 case * workflow.SimpleTask :
134134 u .AssertTrue (t , n .(* workflow.SimpleTask ).Func == f .Name )
@@ -156,7 +156,12 @@ func TestChoiceWorkflow_BuiltWithNextBranch(t *testing.T) {
156156 NextBranch (CreateSequenceWorkflow (fArr ... )).
157157 EndChoiceAndBuild ()
158158
159- choiceWorkflow , foundStartNext := wflow .Find (wflow .Start .Next )
159+ if err != nil {
160+ fmt .Println (err )
161+ t .FailNow ()
162+ }
163+
164+ choiceWorkflow , foundStartNext := wflow .Find (wflow .Start .GetNext ()[0 ])
160165 choice := choiceWorkflow .(* workflow.ChoiceTask )
161166
162167 u .AssertNil (t , err )
@@ -171,12 +176,12 @@ func TestChoiceWorkflow_BuiltWithNextBranch(t *testing.T) {
171176 for _ , n := range wflow .Tasks {
172177 switch node := n .(type ) {
173178 case * workflow.ChoiceTask :
174- u .AssertEquals (t , len (choice .Conditions ), len (choice .Alternatives ))
175- for _ , s := range choice .Alternatives {
179+ u .AssertEquals (t , len (choice .Conditions ), len (choice .NextTasks ))
180+ for _ , s := range choice .NextTasks {
176181 simple , foundS := wflow .Find (s )
177182 u .AssertTrue (t , foundS )
178183 if length == 1 {
179- u .AssertEquals (t , simple .( * workflow. SimpleTask ). OutputTo , wflow .End .GetId ())
184+ u .AssertEquals (t , simple .GetNext ()[ 0 ] , wflow .End .GetId ())
180185 }
181186 }
182187 case * workflow.SimpleTask :
@@ -206,23 +211,23 @@ func TestBroadcastWorkflow(t *testing.T) {
206211 u .AssertEquals (t , length * width + 4 , len (wflow .Tasks )) // 1 (fanOut) + 1 (fanIn) + width * length (simpleNodes) + 1 start + 1 end
207212
208213 // tasks := workflow.NewNodeSetFrom(workflow.Tasks)
209- _ , foundStartNext := wflow .Find (wflow .Start .Next )
214+ _ , foundStartNext := wflow .Find (wflow .Start .GetNext ()[ 0 ] )
210215 u .AssertTrue (t , foundStartNext )
211216
212217 for _ , n := range wflow .Tasks {
213218 switch n .(type ) {
214219 case * workflow.FanOutTask :
215220 fanOut := n .(* workflow.FanOutTask )
216- u .AssertEquals (t , len (fanOut .OutputTo ), fanOut .FanOutDegree )
221+ u .AssertEquals (t , len (fanOut .NextTasks ), fanOut .FanOutDegree )
217222 u .AssertEquals (t , width , fanOut .FanOutDegree )
218- for _ , s := range fanOut .OutputTo {
223+ for _ , s := range fanOut .NextTasks {
219224 _ , found := wflow .Find (s )
220225 u .AssertTrue (t , found )
221226 }
222227 case * workflow.FanInTask :
223228 fanIn := n .(* workflow.FanInTask )
224229 u .AssertEquals (t , width , fanIn .FanInDegree )
225- u .AssertEquals (t , wflow .End .GetId (), fanIn .OutputTo )
230+ u .AssertEquals (t , wflow .End .GetId (), fanIn .NextTasks [ 0 ] )
226231 case * workflow.SimpleTask :
227232 u .AssertTrue (t , n .(* workflow.SimpleTask ).Func == f .Name )
228233 default :
@@ -246,7 +251,7 @@ func TestScatterWorkflow(t *testing.T) {
246251 u .AssertEquals (t , width + 4 , len (wflow .Tasks )) // 1 (fanOut) + 1 (fanIn) + width (simpleNodes) + 1 start + 1 end
247252
248253 // tasks := workflow.NewNodeSetFrom(workflow.Tasks)
249- startNext , startNextFound := wflow .Find (wflow .Start .Next )
254+ startNext , startNextFound := wflow .Find (wflow .Start .GetNext ()[ 0 ] )
250255 u .AssertTrue (t , startNextFound )
251256 _ , ok := startNext .(* workflow.FanOutTask )
252257 u .AssertTrue (t , ok )
@@ -255,19 +260,19 @@ func TestScatterWorkflow(t *testing.T) {
255260 switch node := n .(type ) {
256261 case * workflow.FanOutTask :
257262 fanOut := node
258- u .AssertEquals (t , len (fanOut .OutputTo ), fanOut .FanOutDegree )
263+ u .AssertEquals (t , len (fanOut .NextTasks ), fanOut .FanOutDegree )
259264 u .AssertEquals (t , width , fanOut .FanOutDegree )
260- for _ , s := range fanOut .OutputTo {
265+ for _ , s := range fanOut .NextTasks {
261266 _ , foundSimple := wflow .Find (s )
262267 u .AssertTrue (t , foundSimple )
263268 }
264269 case * workflow.FanInTask :
265270 fanIn := node
266271 u .AssertEquals (t , width , fanIn .FanInDegree )
267- u .AssertEquals (t , wflow .End .GetId (), fanIn .OutputTo )
272+ u .AssertEquals (t , wflow .End .GetId (), fanIn .NextTasks [ 0 ] )
268273 case * workflow.SimpleTask :
269274 u .AssertTrue (t , n .(* workflow.SimpleTask ).Func == f .Name )
270- outputTo , _ := wflow .Find (node .OutputTo )
275+ outputTo , _ := wflow .Find (node .NextTasks [ 0 ] )
271276 _ , chainedToFanIn := outputTo .(* workflow.FanInTask )
272277 u .AssertTrue (t , chainedToFanIn )
273278 simpleNodeChainedToFanIn ++
@@ -292,7 +297,7 @@ func TestCreateBroadcastMultiFunctionWorkflow(t *testing.T) {
292297 func () (* workflow.Workflow , error ) { return CreateSequenceWorkflow (fArrJs ... ) },
293298 )
294299 u .AssertNil (t , errWorkflow )
295- startNext , startNextFound := wflow .Find (wflow .Start .Next )
300+ startNext , startNextFound := wflow .Find (wflow .Start .GetNext ()[ 0 ] )
296301
297302 u .AssertNonNil (t , wflow .Start )
298303 u .AssertNonNil (t , wflow .End )
@@ -309,20 +314,20 @@ func TestCreateBroadcastMultiFunctionWorkflow(t *testing.T) {
309314 switch node := n .(type ) {
310315 case * workflow.FanOutTask :
311316 fanOut := node
312- u .AssertEquals (t , len (fanOut .OutputTo ), fanOut .FanOutDegree )
317+ u .AssertEquals (t , len (fanOut .NextTasks ), fanOut .FanOutDegree )
313318 // test that there are simple nodes chained to fan out
314- for _ , s := range fanOut .OutputTo {
319+ for _ , s := range fanOut .NextTasks {
315320 _ , foundSimple := wflow .Find (s )
316321 u .AssertTrue (t , foundSimple )
317322 }
318323 case * workflow.FanInTask :
319324 fanIn := node
320- u .AssertEquals (t , wflow .End .GetId (), fanIn .OutputTo )
325+ u .AssertEquals (t , wflow .End .GetId (), fanIn .NextTasks [ 0 ] )
321326 default :
322327 continue
323328 case * workflow.SimpleTask :
324329 u .AssertTrue (t , node .Func == f .Name )
325- outputTo , _ := wflow .Find (node .OutputTo )
330+ outputTo , _ := wflow .Find (node .NextTasks [ 0 ] )
326331 if _ , ok := outputTo .(* workflow.FanInTask ); ok {
327332 simpleNodeChainedToFanIn ++
328333 }
@@ -371,16 +376,16 @@ func TestWorkflowBuilder(t *testing.T) {
371376 switch node := n .(type ) {
372377 case * workflow.FanOutTask :
373378 fanOut := node
374- u .AssertEquals (t , len (fanOut .OutputTo ), fanOut .FanOutDegree )
379+ u .AssertEquals (t , len (fanOut .NextTasks ), fanOut .FanOutDegree )
375380 u .AssertEquals (t , width , fanOut .FanOutDegree )
376- for _ , s := range fanOut .OutputTo {
381+ for _ , s := range fanOut .NextTasks {
377382 _ , found := wflow .Find (s )
378383 u .AssertTrue (t , found )
379384 }
380385 case * workflow.FanInTask :
381386 fanIn := node
382387 u .AssertEquals (t , width , fanIn .FanInDegree )
383- u .AssertEquals (t , wflow .End .GetId (), fanIn .OutputTo )
388+ u .AssertEquals (t , wflow .End .GetId (), fanIn .NextTasks [ 0 ] )
384389 case * workflow.SimpleTask :
385390 u .AssertTrue (t , node .Func == f .Name )
386391 nextNode , _ := wflow .Find (node .GetNext ()[0 ])
@@ -389,23 +394,23 @@ func TestWorkflowBuilder(t *testing.T) {
389394 }
390395 case * workflow.ChoiceTask :
391396 choice := node
392- u .AssertEquals (t , len (choice .Conditions ), len (choice .Alternatives ))
397+ u .AssertEquals (t , len (choice .Conditions ), len (choice .NextTasks ))
393398
394399 // specific for this test
395- alt0 , foundAlt0 := wflow .Find (choice .Alternatives [0 ])
396- alt1 , foundAlt1 := wflow .Find (choice .Alternatives [1 ])
400+ alt0 , foundAlt0 := wflow .Find (choice .NextTasks [0 ])
401+ alt1 , foundAlt1 := wflow .Find (choice .NextTasks [1 ])
397402 firstAlternative := alt0 .(* workflow.SimpleTask )
398403 secondAlternative := alt1 .(* workflow.FanOutTask )
399404
400405 u .AssertTrue (t , foundAlt0 )
401406 u .AssertTrue (t , foundAlt1 )
402- u .AssertEquals (t , firstAlternative .OutputTo , wflow .End .GetId ())
407+ u .AssertEquals (t , firstAlternative .NextTasks [ 0 ] , wflow .End .GetId ())
403408 // checking fan out - simples - fan in
404- for i := range secondAlternative .OutputTo {
405- secondAltOutput , _ := wflow .Find (secondAlternative .OutputTo [i ])
409+ for i := range secondAlternative .NextTasks {
410+ secondAltOutput , _ := wflow .Find (secondAlternative .NextTasks [i ])
406411 simple , ok := secondAltOutput .(* workflow.SimpleTask )
407412 u .AssertTrue (t , ok )
408- simpleNext , _ := wflow .Find (simple .OutputTo )
413+ simpleNext , _ := wflow .Find (simple .NextTasks [ 0 ] )
409414 _ , okFanIn := simpleNext .(* workflow.FanInTask )
410415 u .AssertTrue (t , okFanIn )
411416 }
@@ -432,7 +437,7 @@ func TestVisit(t *testing.T) {
432437 EndChoiceAndBuild ()
433438 u .AssertNil (t , err )
434439
435- startNext , _ := complexWorkflow .Find (complexWorkflow .Start .Next )
440+ startNext , _ := complexWorkflow .Find (complexWorkflow .Start .GetNext ()[ 0 ] )
436441
437442 choice := startNext .GetNext ()[0 ]
438443
0 commit comments