GitHubUtil { public GHRepository createFork(GHRepository repo) { try { return repo.fork(); } catch (IOException e) { log.error("Could not fork {}", repo.getFullName(), e); } return null; } GitHubUtil(GitHub gitHub); GitHub getGithub(); GHRepository getRepo(String repo); GHRepository createPublicRepo(String repoName); GHMyself getMyself(); GHContentSearchBuilder startSearch(); GHRepository createFork(GHRepository repo); void safeDeleteRepo(GHRepository repo); int createPullReq(GHRepository origRepo, String branch,
                                 GHRepository forkRepo, String title, String body); GHRepository tryRetrievingRepository(String repoName); GHContent tryRetrievingContent(GHRepository repo, String path, String branch); List<GHRepository> getGHRepositories(Multimap<String, String> pathToDockerfileInParentRepo,
                                                 GHMyself currentUser); boolean repoHasBranch(GHRepository repo, String branchName); Map<String, GHRepository> getReposForUserAtCurrentInstant(GHMyself user); static final String NO_BRANCH_WARN_FORMAT; }
@Test public void testCreateFork() throws Exception { GitHub github = mock(GitHub.class); GitHubUtil gitHubUtil = new GitHubUtil(github); GHRepository repo = mock(GHRepository.class); gitHubUtil.createFork(repo); verify(repo, times(1)).fork(); }
@Test public void testCreateForkWithExceptionProceeds() throws Exception { GitHub github = mock(GitHub.class); GitHubUtil gitHubUtil = new GitHubUtil(github); GHRepository repo = mock(GHRepository.class); when(repo.fork()) .thenThrow(new IOException("Some issue with forking occurred and the library throws an IOException")); assertNull(gitHubUtil.createFork(repo)); verify(repo, times(1)).fork(); }