@Test public void testCallProcessIsDoneWithException() throws ExecutionException, InterruptedException { UUID procId = UUID.randomUUID(); Future<?> fut = mock(Future.class); doReturn(true).when(fut).isDone(); doThrow(RuntimeException.class).when(fut).get(); metadataStorage.put(procId, fut); LongRunningProcessClearTask clearTask = createTask(procId); List<LongRunningProcessStatus> statuses = clearTask.call(); assertEquals(1, statuses.size()); LongRunningProcessStatus status = statuses.get(0); assertEquals(LongRunningProcessState.DONE, status.getState()); assertNotNull(status.getException()); assertTrue(status.getException() instanceof RuntimeException); assertEquals(0, metadataStorage.size()); }
@Override public List<LongRunningProcessStatus> call() { ArrayList<LongRunningProcessStatus> res = new ArrayList<>(); for (UUID prodId : procIds) res.add(prepareProcessForRemoving(prodId)); removeProcessesFromMetadataStorage(); return res; }
LongRunningProcessClearTask extends LongRunningProcessTask<List<LongRunningProcessStatus>> { @Override public List<LongRunningProcessStatus> call() { ArrayList<LongRunningProcessStatus> res = new ArrayList<>(); for (UUID prodId : procIds) res.add(prepareProcessForRemoving(prodId)); removeProcessesFromMetadataStorage(); return res; } }
LongRunningProcessClearTask extends LongRunningProcessTask<List<LongRunningProcessStatus>> { @Override public List<LongRunningProcessStatus> call() { ArrayList<LongRunningProcessStatus> res = new ArrayList<>(); for (UUID prodId : procIds) res.add(prepareProcessForRemoving(prodId)); removeProcessesFromMetadataStorage(); return res; } LongRunningProcessClearTask(List<UUID> procIds); }
LongRunningProcessClearTask extends LongRunningProcessTask<List<LongRunningProcessStatus>> { @Override public List<LongRunningProcessStatus> call() { ArrayList<LongRunningProcessStatus> res = new ArrayList<>(); for (UUID prodId : procIds) res.add(prepareProcessForRemoving(prodId)); removeProcessesFromMetadataStorage(); return res; } LongRunningProcessClearTask(List<UUID> procIds); @Override List<LongRunningProcessStatus> call(); }
LongRunningProcessClearTask extends LongRunningProcessTask<List<LongRunningProcessStatus>> { @Override public List<LongRunningProcessStatus> call() { ArrayList<LongRunningProcessStatus> res = new ArrayList<>(); for (UUID prodId : procIds) res.add(prepareProcessForRemoving(prodId)); removeProcessesFromMetadataStorage(); return res; } LongRunningProcessClearTask(List<UUID> procIds); @Override List<LongRunningProcessStatus> call();  }