@Before
  public void setUp() {
    initMocks(this);

    when(connectivityCheckerMock.isConnected()).thenReturn(true);

    activity = buildActivity(Activity.class).create().get();
    retryableAsyncTask =
        new RetryableAsyncTask<String, Void, String>(
            activity, connectivityCheckerMock, retryableDialogMock) {

          @Override
          protected void onPreExecute() {
            onPreExecuteMock.call();
          }

          @Override
          protected String doInBackground(String... params) {
            doInBackgroundMock.call((Object[]) params);

            return "bar";
          }

          @Override
          protected void onPostExecute(String result) {
            onPostExecuteMock.call(result);
          }
        };
  }
  @Test
  public void itShowsDialogWhenThereIsNoConnectivity() {
    when(connectivityCheckerMock.isConnected()).thenReturn(false);

    retryableAsyncTask.execute();

    verify(retryableDialogMock).show(application.getString(R.string.no_internet_connection));
  }
  @Test
  public void itDoesNotExecutAsyncTaskIfThereIsNoConnectivity()
      throws ExecutionException, InterruptedException {
    when(connectivityCheckerMock.isConnected()).thenReturn(false);

    retryableAsyncTask.execute();

    flushBackgroundThreadScheduler();

    assertNull(retryableAsyncTask.get());
  }