@SuppressWarnings("unchecked") @Test public void testExecutorProblem() throws Exception { ExecutorService mockExecutor = Mockito.mock(ExecutorService.class); when(mockExecutor.submit(any(Callable.class))).thenThrow(new RuntimeException("")); underTest = new OAuthCredentialsCache(mockExecutor, mockCredentials); Assert.assertFalse(underTest.getHeader(TIMEOUT_SECONDS, TimeUnit.SECONDS).getStatus().isOk()); }
HeaderToken getHeader(long timeout, TimeUnit timeUnit) { try { return getHeaderUnsafe(timeout, timeUnit).getToken(); } catch (Exception e) { LOG.warn("Got an unexpected exception while trying to refresh google credentials.", e); Status status = Status.UNAUTHENTICATED.withDescription("Unexpected failure get auth token").withCause(e); return new HeaderToken(status, null); } }
OAuthCredentialsCache { HeaderToken getHeader(long timeout, TimeUnit timeUnit) { try { return getHeaderUnsafe(timeout, timeUnit).getToken(); } catch (Exception e) { LOG.warn("Got an unexpected exception while trying to refresh google credentials.", e); Status status = Status.UNAUTHENTICATED.withDescription("Unexpected failure get auth token").withCause(e); return new HeaderToken(status, null); } } }
OAuthCredentialsCache { HeaderToken getHeader(long timeout, TimeUnit timeUnit) { try { return getHeaderUnsafe(timeout, timeUnit).getToken(); } catch (Exception e) { LOG.warn("Got an unexpected exception while trying to refresh google credentials.", e); Status status = Status.UNAUTHENTICATED.withDescription("Unexpected failure get auth token").withCause(e); return new HeaderToken(status, null); } } OAuthCredentialsCache(ExecutorService scheduler, OAuth2Credentials credentials); }
OAuthCredentialsCache { HeaderToken getHeader(long timeout, TimeUnit timeUnit) { try { return getHeaderUnsafe(timeout, timeUnit).getToken(); } catch (Exception e) { LOG.warn("Got an unexpected exception while trying to refresh google credentials.", e); Status status = Status.UNAUTHENTICATED.withDescription("Unexpected failure get auth token").withCause(e); return new HeaderToken(status, null); } } OAuthCredentialsCache(ExecutorService scheduler, OAuth2Credentials credentials);  }
OAuthCredentialsCache { HeaderToken getHeader(long timeout, TimeUnit timeUnit) { try { return getHeaderUnsafe(timeout, timeUnit).getToken(); } catch (Exception e) { LOG.warn("Got an unexpected exception while trying to refresh google credentials.", e); Status status = Status.UNAUTHENTICATED.withDescription("Unexpected failure get auth token").withCause(e); return new HeaderToken(status, null); } } OAuthCredentialsCache(ExecutorService scheduler, OAuth2Credentials credentials);   }