JAL-4199 Patch task execution in action tests
authorMateusz Warowny <mmzwarowny@dundee.ac.uk>
Thu, 6 Jul 2023 13:56:38 +0000 (15:56 +0200)
committerMateusz Warowny <mmzwarowny@dundee.ac.uk>
Wed, 12 Jul 2023 14:25:05 +0000 (16:25 +0200)
test/jalview/ws2/actions/alignment/AlignmentActionTest.java

index 5586108..e573032 100644 (file)
@@ -24,6 +24,7 @@ import jalview.datamodel.SequenceI;
 import jalview.gui.AlignViewport;
 import jalview.viewmodel.AlignmentViewport;
 import jalview.ws.params.ParamDatastoreI;
+import jalview.ws2.actions.PollingTaskExecutor;
 import jalview.ws2.actions.api.JobI;
 import jalview.ws2.actions.api.TaskEventListener;
 import jalview.ws2.api.Credentials;
@@ -210,12 +211,16 @@ public class AlignmentActionTest
       return null;
     })
         .when(listener).taskCompleted(any(), any());
-    action.perform(viewport, List.of(), Credentials.empty(), listener);
+    var executor = PollingTaskExecutor.fromPool(viewport.getServiceExecutor());
+    var task = action.createTask(viewport, List.of(), Credentials.empty());
+    task.addTaskEventListener(listener);
+    var cancellable = executor.submit(task);
     try
     {
       latch.await(100, TimeUnit.MILLISECONDS);
     } catch (InterruptedException e)
     {
+      cancellable.cancel(true);
     }
     return listener;
   }