@Test public void testCallProcessIsRunning() { UUID procId = UUID.randomUUID(); Future<?> fut = mock(Future.class); doReturn(false).when(fut).isDone(); metadataStorage.put(procId, fut); LongRunningProcessStopTask stopTask = createTask(procId, true); List<LongRunningProcessStatus> statuses = stopTask.call(); assertEquals(1, statuses.size()); verify(fut).cancel(eq(true)); LongRunningProcessStatus status = statuses.get(0); assertEquals(LongRunningProcessState.DONE, status.getState()); assertNull(status.getException()); assertEquals(0, metadataStorage.size()); }
@Override public List<LongRunningProcessStatus> call() { ArrayList<LongRunningProcessStatus> res = new ArrayList<>(); for (UUID prodId : procIds) res.add(stopProcess(prodId)); if (clear) removeProcessesFromMetadataStorage(); return res; }
LongRunningProcessStopTask extends LongRunningProcessTask<List<LongRunningProcessStatus>> { @Override public List<LongRunningProcessStatus> call() { ArrayList<LongRunningProcessStatus> res = new ArrayList<>(); for (UUID prodId : procIds) res.add(stopProcess(prodId)); if (clear) removeProcessesFromMetadataStorage(); return res; } }
LongRunningProcessStopTask extends LongRunningProcessTask<List<LongRunningProcessStatus>> { @Override public List<LongRunningProcessStatus> call() { ArrayList<LongRunningProcessStatus> res = new ArrayList<>(); for (UUID prodId : procIds) res.add(stopProcess(prodId)); if (clear) removeProcessesFromMetadataStorage(); return res; } LongRunningProcessStopTask(List<UUID> procIds, boolean clear); }
LongRunningProcessStopTask extends LongRunningProcessTask<List<LongRunningProcessStatus>> { @Override public List<LongRunningProcessStatus> call() { ArrayList<LongRunningProcessStatus> res = new ArrayList<>(); for (UUID prodId : procIds) res.add(stopProcess(prodId)); if (clear) removeProcessesFromMetadataStorage(); return res; } LongRunningProcessStopTask(List<UUID> procIds, boolean clear); @Override List<LongRunningProcessStatus> call(); }
LongRunningProcessStopTask extends LongRunningProcessTask<List<LongRunningProcessStatus>> { @Override public List<LongRunningProcessStatus> call() { ArrayList<LongRunningProcessStatus> res = new ArrayList<>(); for (UUID prodId : procIds) res.add(stopProcess(prodId)); if (clear) removeProcessesFromMetadataStorage(); return res; } LongRunningProcessStopTask(List<UUID> procIds, boolean clear); @Override List<LongRunningProcessStatus> call();  }