ForkableRepoValidator { protected ShouldForkResult parentIsFork(GHRepository parentRepo) { return parentRepo.isFork() ? shouldNotForkResult(REPO_IS_FORK) : shouldForkResult(); } ForkableRepoValidator(DockerfileGitHubUtil dockerfileGitHubUtil); ShouldForkResult shouldFork(GHRepository parentRepo,
                                       GHContent searchResultContent,
                                       GitForkBranch gitForkBranch); static final String REPO_IS_FORK; static final String REPO_IS_ARCHIVED; static final String REPO_IS_OWNED_BY_THIS_USER; static final String COULD_NOT_CHECK_THIS_USER; static final String CONTENT_PATH_NOT_IN_DEFAULT_BRANCH_TEMPLATE; static final String COULD_NOT_FIND_IMAGE_TO_UPDATE_TEMPLATE; }
@Test public void testParentIsForkDoNotForkIt() { DockerfileGitHubUtil dockerfileGitHubUtil = mock(DockerfileGitHubUtil.class); GHRepository repo = mock(GHRepository.class); ForkableRepoValidator validator = new ForkableRepoValidator(dockerfileGitHubUtil); when(repo.isFork()).thenReturn(true); ShouldForkResult shouldForkResult = validator.parentIsFork(repo); assertFalse(shouldForkResult.isForkable()); assertEquals(shouldForkResult.getReason(), REPO_IS_FORK); }
@Test public void testParentIsNotForkSoForkIt() { DockerfileGitHubUtil dockerfileGitHubUtil = mock(DockerfileGitHubUtil.class); GHRepository repo = mock(GHRepository.class); ForkableRepoValidator validator = new ForkableRepoValidator(dockerfileGitHubUtil); when(repo.isFork()).thenReturn(false); ShouldForkResult shouldForkResult = validator.parentIsFork(repo); assertTrue(shouldForkResult.isForkable()); }