@Test
  public void itDelegatesTaskToAsyncTaskWhenGetIsCalled()
      throws ExecutionException, InterruptedException {
    retryableAsyncTask.execute("foo");

    flushBackgroundThreadScheduler();

    assertThat(retryableAsyncTask.get(), is("bar"));
  }
  @Test
  public void itShowsDialogOnError() {
    String params = "foo";

    retryableAsyncTask.execute(params);

    retryableAsyncTask.onError(new RuntimeException(), params);

    verify(retryableDialogMock).show(application.getString(R.string.something_went_wrong), params);
  }
  @Test
  public void itCancelsAsyncTaskExecution() {
    retryableAsyncTask.execute("foo");

    assertThat(retryableAsyncTask.isCancelled(), is(false));

    retryableAsyncTask.cancel();

    assertThat(retryableAsyncTask.isCancelled(), is(true));
  }
  @Test
  public void itDoesNotExecutAsyncTaskIfThereIsNoConnectivity()
      throws ExecutionException, InterruptedException {
    when(connectivityCheckerMock.isConnected()).thenReturn(false);

    retryableAsyncTask.execute();

    flushBackgroundThreadScheduler();

    assertNull(retryableAsyncTask.get());
  }
  @Test
  public void itShowsDialogWhenThereIsNoConnectivity() {
    when(connectivityCheckerMock.isConnected()).thenReturn(false);

    retryableAsyncTask.execute();

    verify(retryableDialogMock).show(application.getString(R.string.no_internet_connection));
  }
  @Test
  public void itDelegatesTaskToAsyncTaskWhenDoInBackgroundIsCalled() {
    retryableAsyncTask.execute("foo");

    verify(doInBackgroundMock).call("foo");
  }
  @Test
  public void itDelegatesTaskToAsyncTaskWhenOnPreExecuteIsCalled() {
    retryableAsyncTask.execute("foo");

    verify(onPreExecuteMock).call();
  }
  @Test
  public void itRetriesAsyncTaskExecution() throws ExecutionException, InterruptedException {
    retryableAsyncTask.retry();

    assertThat(retryableAsyncTask.get(), is("bar"));
  }