@Test public void setResponseLeadsToResponse() throws CancellationException, InterruptedException, ExecutionException { Response response = mock(Response.class); cut.setResponse(response); assertThat(cut.get(), is(response)); }
@Test public void setThrowableLeadsToThrowable() throws CancellationException, InterruptedException { Throwable throwable = mock(Throwable.class); cut.setThrowable(throwable); try { cut.get(); } catch (ExecutionException e) { assertThat(e.getCause(), is(throwable)); return; } fail(); }
@Test(expected = CancellationException.class) public void setCancelledLeadsToCancelledException() throws CancellationException, InterruptedException, ExecutionException { cut.setCancelled(); cut.get(); }