Authenticator { void cacheResources() throws IOException { final CloudResourceManager.Projects.List request = cloudResourceManager.projects().list(); ListProjectsResponse response; do { response = executeWithRetries(request, retryWaitStrategy, retryStopStrategy); if (response.getProjects() == null) { continue; } for (Project project : response.getProjects()) { final boolean access = resolveProject(project); logger.info("Resolved project: {}, access={}", project.getProjectId(), access); } request.setPageToken(response.getNextPageToken()); } while (response.getNextPageToken() != null); logger.info("Resource cache loaded"); } Authenticator(GoogleIdTokenVerifier googleIdTokenVerifier,
                CloudResourceManager cloudResourceManager,
                Iam iam,
                AuthenticatorConfiguration configuration);   Authenticator(GoogleIdTokenVerifier googleIdTokenVerifier,
                CloudResourceManager cloudResourceManager,
                Iam iam,
                AuthenticatorConfiguration configuration,
                WaitStrategy retryWaitStrategy,
                StopStrategy retryStopStrategy);   }
@Test public void shouldFailToLoadCache() throws IOException { reset(projectsList); final IOException exception = new IOException(); doThrow(exception).when(projectsList).execute(); try { validator.cacheResources(); fail("Expected exception"); } catch (IOException e) { assertThat(e.getCause().getCause(), is(exception)); } verify(projectsList, times(3)).execute(); }
@Test public void shouldRetryToLoadCacheOnQuotaExhausted() throws IOException { reset(projectsList); when(projectsList.execute()) .thenThrow(QUOTA_EXHAUSTED) .thenReturn(new ListProjectsResponse().setProjects(PROJECTS)); validator.cacheResources(); verify(projectsList, times(2)).execute(); }