@Test
public void when_auth_token_is_required_and_token_is_expired() throws Exception {

  when(data.isAccessTokenRequired()).thenReturn(true);
  long thirtyMinutesBeforeNow = System.currentTimeMillis() - TimeUnit.MINUTES.toMillis(30);
  when(data.tokenExpiryTimeMillis()).thenReturn(Single.just(thirtyMinutesBeforeNow));
  when(data.accessToken()).thenReturn(Single.just(AUTH_TOKEN));
  GfycatResponse response = GfycatResponse.create(GFYCAT_RESPONSE);
  when(dankApi.gfycat(AUTH_TOKEN, UNRESOLVED_ID)).thenReturn(Single.just(response));
  GfycatOauthResponse oAuthResponse = GfycatOauthResponse.create(3600, AUTH_TOKEN);
  when(dankApi.gfycatOAuth(anyString(), anyString())).thenReturn(Single.just(oAuthResponse));
  when(data.saveOAuthResponse(oAuthResponse)).thenReturn(Completable.complete());
  gfycatRepository.gif(UNRESOLVED_ID)
      .test()
      .assertNoErrors()
      .assertComplete()
      .assertValue(GFYCAT_RESOLVED_LINK);
  verify(dankApi).gfycatOAuth(anyString(), anyString());
  verify(data).saveOAuthResponse(oAuthResponse);
}