GitHubPullRequestSender { protected GHRepository getForkFromExistingRecordToProcess(Multimap<String, GitHubContentToProcess> pathToDockerfilesInParentRepo, String parentRepoName) { if (pathToDockerfilesInParentRepo.containsKey(parentRepoName)) { Optional<GitHubContentToProcess> firstForkData = pathToDockerfilesInParentRepo.get(parentRepoName).stream().findFirst(); if (firstForkData.isPresent()) { return firstForkData.get().getFork(); } else { log.warn("For some reason we have data inconsistency when trying to find the fork for {}", parentRepoName); } } return null; } GitHubPullRequestSender(DockerfileGitHubUtil dockerfileGitHubUtil, ForkableRepoValidator forkableRepoValidator); Multimap<String, GitHubContentToProcess> forkRepositoriesFoundAndGetPathToDockerfiles(
            PagedSearchIterable<GHContent> contentsWithImage,
            GitForkBranch gitForkBranch); static final String REPO_IS_FORK; }
@Test public void testGetForkFromExistingRecordToProcess() { String reponame = "reponame"; DockerfileGitHubUtil dockerfileGitHubUtil = mock(DockerfileGitHubUtil.class); GitHubPullRequestSender gitHubPullRequestSender = new GitHubPullRequestSender(dockerfileGitHubUtil, mock(ForkableRepoValidator.class)); GHRepository fork = mock(GHRepository.class); GHRepository parent = mock(GHRepository.class); Multimap<String, GitHubContentToProcess> processMultimap = HashMultimap.create(); processMultimap.put(reponame, new GitHubContentToProcess(fork, parent, "path")); assertEquals(gitHubPullRequestSender.getForkFromExistingRecordToProcess(processMultimap, reponame), fork); }
@Test public void testGetForkNotFoundFromExistingRecords() { String reponame = "reponame"; DockerfileGitHubUtil dockerfileGitHubUtil = mock(DockerfileGitHubUtil.class); GitHubPullRequestSender gitHubPullRequestSender = new GitHubPullRequestSender(dockerfileGitHubUtil, mock(ForkableRepoValidator.class)); Multimap<String, GitHubContentToProcess> processMultimap = HashMultimap.create(); assertNull(gitHubPullRequestSender.getForkFromExistingRecordToProcess(processMultimap, reponame)); }