@Override public final Request refresh(Response response) throws IOException { if (isRefreshable() && canRefresh(response) && canRetry(response)) { return doRefresh(response); } return null; }
@Override public final Request refresh(Response response) throws IOException { if (isRefreshable() && canRefresh(response) && canRetry(response)) { return doRefresh(response); } return null; }
@Test public void testRefresh_canReAuthAndRetry_callsRefresh() throws Exception { doReturn(request).when(authenticator).doRefresh(response); doReturn(true).when(authenticator).isRefreshable(); doReturn(true).when(authenticator).canRetry(eq(response)); doReturn(true).when(authenticator).canRefresh(eq(response)); assertNotNull(authenticator.refresh(response)); verify(authenticator).doRefresh(response); }
@Test public void testRefresh_canReAuthButCannotRetry_returnsNull() throws Exception { doReturn(true).when(authenticator).isRefreshable(); doReturn(false).when(authenticator).canRetry(eq(response)); doReturn(true).when(authenticator).canRefresh(eq(response)); assertNull(authenticator.refresh(response)); verify(authenticator, never()).doRefresh(response); }
@Test public void testRefresh_cannotReAuthButCanRetry_returnsNull() throws Exception { doReturn(false).when(authenticator).isRefreshable(); doReturn(true).when(authenticator).canRetry(eq(response)); doReturn(true).when(authenticator).canRefresh(eq(response)); assertNull(authenticator.refresh(response)); verify(authenticator, never()).doRefresh(response); }
@Test public void testRefresh_canReAuthRetryButCannotRefresh_returnsNull() throws Exception { doReturn(true).when(authenticator).isRefreshable(); doReturn(true).when(authenticator).canRetry(eq(response)); doReturn(false).when(authenticator).canRefresh(eq(response)); assertNull(authenticator.refresh(response)); verify(authenticator, never()).doRefresh(response); }