@Test
public void testGetReposForUserAtCurrentInstant() throws Exception {

    GHMyself currentUser = mock(GHMyself.class);
    PagedIterable<GHRepository> listOfRepos = mock(PagedIterable.class);
    GHRepository repo1 = mock(GHRepository.class);
    when(repo1.getName()).thenReturn("test1");
    GHRepository repo2 = mock(GHRepository.class);
    when(repo2.getName()).thenReturn("test2");
    GHRepository repo3 = mock(GHRepository.class);
    when(repo3.getName()).thenReturn("test3");
    GHRepository repo4 = mock(GHRepository.class);
    when(repo4.getName()).thenReturn("test4");
    PagedIterator<GHRepository> listOfReposIterator = mock(PagedIterator.class);
    when(listOfReposIterator.hasNext()).thenReturn(true, true, true, true, false);
    when(listOfReposIterator.next()).thenReturn(repo1, repo2, repo3, repo4, null);
    when(listOfRepos.iterator()).thenReturn(listOfReposIterator);
    when(currentUser.listRepositories(100, GHMyself.RepositoryListFilter.OWNER)).thenReturn(listOfRepos);
    GitHub github = mock(GitHub.class);
    GitHubUtil gitHubUtil = new GitHubUtil(github);
    Map<String, GHRepository> repoByName = gitHubUtil.getReposForUserAtCurrentInstant(currentUser);
    assertEquals(repoByName.size(), 4);
    assertTrue(repoByName.containsKey("test1") && repoByName.get("test1") == repo1);
    assertTrue(repoByName.containsKey("test2") && repoByName.get("test2") == repo2);
    assertTrue(repoByName.containsKey("test3") && repoByName.get("test3") == repo3);
    assertTrue(repoByName.containsKey("test4") && repoByName.get("test4") == repo4);
}