GitHubApi { public List<GHRepo> getUserRepos(String login) { return getForAll("https: } GitHubApi(RestTemplateBuilder builder); boolean isAnonymous(); GHUser getUser(); GHUser getUser(String login); List<GHOrg> getUserOrgs(String login); GHOrg getOrg(String org); List<GHRepo> getUserRepos(String login); List<GHRepo> getOrgRepos(String login); GHRepo getRepo(String owner, String repo);  }
@Test public void testGetUserRepos() throws Exception { HttpHeaders headers; Cache page1 = mock(Cache.class, "page1"), page2 = mock(Cache.class, "page2"); when(cacheManager.getCache(eq(GitHubApi.class.getName()))).thenReturn(page1); when(cacheManager.getCache(eq(GitHubApi.class.getName()))).thenReturn(page2); headers = new HttpHeaders(); headers.set(HttpHeaders.ETAG, "abcd"); headers.set("Link", "<https: server.expect(once(), requestTo("https: .andRespond(withSuccess(new ClassPathResource("github/users-jcooky-repos.1.json"), MediaType.APPLICATION_JSON).headers(headers)); headers = new HttpHeaders(); headers.set(HttpHeaders.ETAG, "efgh"); headers.set("Link", "<https: server.expect(once(), requestTo("https: .andRespond(withSuccess().headers(headers).body(new ClassPathResource("github/users-jcooky-repos.2.json")).contentType(MediaType.APPLICATION_JSON)); gitHubApi.getUserRepos("jcooky"); server.verify(); }