@@ -109,16 +109,15 @@ void testParallelPartialFailure_failedBranchDoesNotPreventOthers() {
109109 void testParallelAllBranchesFail () {
110110 var runner = LocalDurableTestRunner .create (String .class , (input , context ) -> {
111111 var config = ParallelConfig .builder ().build ();
112- var futures = new ArrayList <DurableFuture <String >>();
113112 var parallel = context .parallel ("all-fail" , config );
114113
115114 try (parallel ) {
116- futures . add ( parallel .branch ("branch-x" , String .class , ctx -> {
115+ parallel .branch ("branch-x" , String .class , ctx -> {
117116 throw new RuntimeException ("fail-x" );
118- })) ;
119- futures . add ( parallel .branch ("branch-y" , String .class , ctx -> {
117+ });
118+ parallel .branch ("branch-y" , String .class , ctx -> {
120119 throw new RuntimeException ("fail-y" );
121- })) ;
120+ });
122121 }
123122
124123 var result = parallel .get ();
@@ -298,7 +297,7 @@ void testStepBeforeAndAfterParallel() {
298297
299298 var config = ParallelConfig .builder ().build ();
300299 var futures = new ArrayList <DurableFuture <String >>();
301- var parallel = context .parallel ("middle-parallel" , config );
300+ ParallelDurableFuture parallel = context .parallel ("middle-parallel" , config );
302301
303302 try (parallel ) {
304303 futures .add (parallel .branch ("branch-a" , String .class , ctx -> "A" ));
@@ -451,19 +450,18 @@ void testParallelUnlimitedConcurrencyWithToleratedFailureCount() {
451450 var config = ParallelConfig .builder ()
452451 .completionConfig (CompletionConfig .toleratedFailureCount (1 ))
453452 .build ();
454- var futures = new ArrayList <DurableFuture <String >>();
455- var parallel = context .parallel ("unlimited-tolerated" , config );
453+ ParallelDurableFuture parallel = context .parallel ("unlimited-tolerated" , config );
456454
457455 try (parallel ) {
458- futures . add ( parallel .branch ("branch-ok1" , String .class , ctx -> "OK1" ) );
459- futures . add ( parallel .branch ("branch-fail1" , String .class , ctx -> {
456+ parallel .branch ("branch-ok1" , String .class , ctx -> "OK1" );
457+ parallel .branch ("branch-fail1" , String .class , ctx -> {
460458 throw new RuntimeException ("failed: fail1" );
461- })) ;
462- futures . add ( parallel .branch ("branch-ok2" , String .class , ctx -> "OK2" ) );
463- futures . add ( parallel .branch ("branch-fail2" , String .class , ctx -> {
459+ });
460+ parallel .branch ("branch-ok2" , String .class , ctx -> "OK2" );
461+ parallel .branch ("branch-fail2" , String .class , ctx -> {
464462 throw new RuntimeException ("failed: fail2" );
465- })) ;
466- futures . add ( parallel .branch ("branch-ok3" , String .class , ctx -> "OK3" ) );
463+ });
464+ parallel .branch ("branch-ok3" , String .class , ctx -> "OK3" );
467465 }
468466
469467 var result = parallel .get ();
@@ -508,7 +506,7 @@ void testParallelBranchesReturnDifferentTypes() {
508506 void testParallelResultSummary_succeededAndFailedCounts () {
509507 var runner = LocalDurableTestRunner .create (String .class , (input , context ) -> {
510508 var config = ParallelConfig .builder ().build ();
511- var parallel = context .parallel ("count-check" , config );
509+ ParallelDurableFuture parallel = context .parallel ("count-check" , config );
512510
513511 try (parallel ) {
514512 parallel .branch ("ok1" , String .class , ctx -> "OK1" );
@@ -595,15 +593,14 @@ void testParallel50BranchesWithWaitForCallback_maxConcurrency5() {
595593
596594 var runner = LocalDurableTestRunner .create (String .class , (input , context ) -> {
597595 var config = ParallelConfig .builder ().maxConcurrency (5 ).build ();
598- var futures = new ArrayList <DurableFuture <String >>();
599596 var parallel = context .parallel ("50-callbacks-limited" , config );
600597
601598 try (parallel ) {
602599 for (int i = 0 ; i < branchCount ; i ++) {
603600 var idx = i ;
604- futures . add ( parallel .branch ("branch-" + i , String .class , ctx -> {
601+ parallel .branch ("branch-" + i , String .class , ctx -> {
605602 return ctx .waitForCallback ("cb-" + idx , String .class , (callbackId , stepCtx ) -> {});
606- })) ;
603+ });
607604 }
608605 }
609606
@@ -644,15 +641,14 @@ void testParallel50BranchesWithWaitForCallback_partialFailure() {
644641
645642 var runner = LocalDurableTestRunner .create (String .class , (input , context ) -> {
646643 var config = ParallelConfig .builder ().build ();
647- var futures = new ArrayList <DurableFuture <String >>();
648644 var parallel = context .parallel ("50-callbacks-partial-fail" , config );
649645
650646 try (parallel ) {
651647 for (int i = 0 ; i < branchCount ; i ++) {
652648 var idx = i ;
653- futures . add ( parallel .branch ("branch-" + i , String .class , ctx -> {
649+ parallel .branch ("branch-" + i , String .class , ctx -> {
654650 return ctx .waitForCallback ("approval-" + idx , String .class , (callbackId , stepCtx ) -> {});
655- })) ;
651+ });
656652 }
657653 }
658654
@@ -697,18 +693,17 @@ void testParallel50BranchesWithWaitForCallback_stepsBeforeAndAfterCallback() {
697693
698694 var runner = LocalDurableTestRunner .create (String .class , (input , context ) -> {
699695 var config = ParallelConfig .builder ().build ();
700- var futures = new ArrayList <DurableFuture <String >>();
701- var parallel = context .parallel ("50-callbacks-with-steps" , config );
696+ ParallelDurableFuture parallel = context .parallel ("50-callbacks-with-steps" , config );
702697
703698 try (parallel ) {
704699 for (int i = 0 ; i < branchCount ; i ++) {
705700 var idx = i ;
706- futures . add ( parallel .branch ("branch-" + i , String .class , ctx -> {
701+ parallel .branch ("branch-" + i , String .class , ctx -> {
707702 var before = ctx .step ("prepare-" + idx , String .class , stepCtx -> "prepared-" + idx );
708703 var approval =
709704 ctx .waitForCallback ("approval-" + idx , String .class , (callbackId , stepCtx ) -> {});
710705 return ctx .step ("finalize-" + idx , String .class , stepCtx -> before + ":" + approval + ":done" );
711- })) ;
706+ });
712707 }
713708 }
714709
@@ -890,20 +885,19 @@ void testParallel50BranchesMixed_callbackAndCondition() {
890885
891886 var runner = LocalDurableTestRunner .create (String .class , (input , context ) -> {
892887 var config = ParallelConfig .builder ().build ();
893- var futures = new ArrayList <DurableFuture <String >>();
894888 var parallel = context .parallel ("50-mixed" , config );
895889
896890 try (parallel ) {
897891 for (int i = 0 ; i < branchCount ; i ++) {
898892 var idx = i ;
899893 if (i % 2 == 0 ) {
900894 // Even branches: waitForCallback
901- futures . add ( parallel .branch ("branch-" + i , String .class , ctx -> {
895+ parallel .branch ("branch-" + i , String .class , ctx -> {
902896 return ctx .waitForCallback ("cb-" + idx , String .class , (callbackId , stepCtx ) -> {});
903- })) ;
897+ });
904898 } else {
905899 // Odd branches: waitForCondition
906- futures . add ( parallel .branch ("branch-" + i , String .class , ctx -> {
900+ parallel .branch ("branch-" + i , String .class , ctx -> {
907901 var strategy = WaitStrategies .<Integer >fixedDelay (5 , Duration .ofSeconds (1 ));
908902 var wfcConfig = WaitForConditionConfig .<Integer >builder ()
909903 .waitStrategy (strategy )
@@ -916,7 +910,7 @@ void testParallel50BranchesMixed_callbackAndCondition() {
916910 wfcConfig );
917911
918912 return "polled-" + polled ;
919- })) ;
913+ });
920914 }
921915 }
922916 }
0 commit comments