@Test
public void testForkRepositoriesFound() throws Exception {

    DockerfileGitHubUtil dockerfileGitHubUtil = mock(DockerfileGitHubUtil.class);
    GHRepository contentRepo1 = mock(GHRepository.class);
    when(contentRepo1.getFullName()).thenReturn("1");
    GHRepository contentRepo2 = mock(GHRepository.class);
    when(contentRepo2.getFullName()).thenReturn("2");
    GHRepository contentRepo3 = mock(GHRepository.class);
    when(contentRepo3.getFullName()).thenReturn("3");
    GHContent content1 = mock(GHContent.class);
    when(content1.getOwner()).thenReturn(contentRepo1);
    GHContent content2 = mock(GHContent.class);
    when(content2.getOwner()).thenReturn(contentRepo2);
    GHContent content3 = mock(GHContent.class);
    when(content3.getOwner()).thenReturn(contentRepo3);
    PagedSearchIterable<GHContent> contentsWithImage = mock(PagedSearchIterable.class);
    PagedIterator<GHContent> contentsWithImageIterator = mock(PagedIterator.class);
    when(contentsWithImageIterator.hasNext()).thenReturn(true, true, true, false);
    when(contentsWithImageIterator.next()).thenReturn(content1, content2, content3, null);
    when(contentsWithImage.iterator()).thenReturn(contentsWithImageIterator);
    when(dockerfileGitHubUtil.getOrCreateFork(Mockito.any())).thenReturn(new GHRepository());
    when(dockerfileGitHubUtil.getRepo(any())).thenReturn(mock(GHRepository.class));
    ForkableRepoValidator forkableRepoValidator = mock(ForkableRepoValidator.class);
    when(forkableRepoValidator.shouldFork(any(), any(), any())).thenReturn(ShouldForkResult.shouldForkResult());
    GitHubPullRequestSender pullRequestSender = new GitHubPullRequestSender(dockerfileGitHubUtil, forkableRepoValidator);
    Multimap<String, GitHubContentToProcess> repoMap =
            pullRequestSender.forkRepositoriesFoundAndGetPathToDockerfiles(contentsWithImage, null);
    verify(dockerfileGitHubUtil, times(3)).getOrCreateFork(any());
    assertEquals(repoMap.size(), 3);
}