### Question:
ContextExecutorService { public void cancelContext(UUID contextUuid){ final ArrayList<Future<?>> toCancel = new ArrayList<Future<?>>(getFuturesOfContext(contextUuid)); if(!toCancel.isEmpty()) { if(log.isDebugEnabled())log.debug("About to cancel " + toCancel.size() + " tasks of context " + contextUuid); for (Future<?> future : toCancel) { future.cancel(true); } if(log.isDebugEnabled())log.debug("Cancelled " + toCancel.size() + " tasks of context " + contextUuid); } }  Future<T> runWithContext(UUID contextUuid, final Callable<T> callable); void cancelContext(UUID contextUuid);  }### Answer:
@Test public void cancelContext(){ final UUID contextUuid = UUID.randomUUID(); final List<Future> futures = Arrays.asList(mock(Future.class), mock(Future.class), mock(Future.class)); doReturn(futures).when(spy).getFuturesOfContext(contextUuid); spy.cancelContext(contextUuid); for (Future future : futures) { verify(future).cancel(true); } }