@Test
public void testDispatch_DeleteFromTableFail() throws Exception {

  DyneinJobSpec jobSpec = getTestJobSpec(validToken, "test6");
  Schedule schedule = getSchedule(jobSpec, false);
  CompletableFuture<Void> response = new CompletableFuture<>();
  Exception exception = new Exception();
  response.completeExceptionally(exception);
  when(asyncClient.add(schedule.getJobSpec(), "test6"))
      .thenReturn(CompletableFuture.completedFuture(null));
  when(scheduleManager.deleteDispatchedJob(schedule)).thenReturn(response);
  CompletableFuture<Void> ret = worker.dispatchToDestination(schedule);
  ret.get(1000, TimeUnit.MILLISECONDS);
  verify(asyncClient, times(1)).add(schedule.getJobSpec(), "test6");
  verify(scheduleManager, times(1)).deleteDispatchedJob(schedule);
  verifyNoMoreInteractions(scheduleManager, asyncClient);
}