ForkableRepoValidator { public ShouldForkResult shouldFork(GHRepository parentRepo, GHContent searchResultContent, GitForkBranch gitForkBranch) { return parentIsFork(parentRepo) .and(parentIsArchived(parentRepo) .and(thisUserIsNotOwner(parentRepo) .and(contentHasChangesInDefaultBranch(parentRepo, searchResultContent, gitForkBranch)))); } 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(dataProvider = "shouldForkData") public void testShouldFork(ShouldForkResult isForkResult, ShouldForkResult isArchivedResult, ShouldForkResult userIsNotOwnerResult, ShouldForkResult contentHasChangesResult, ShouldForkResult expectedResult) { ForkableRepoValidator validator = mock(ForkableRepoValidator.class); when(validator.parentIsFork(any())).thenReturn(isForkResult); when(validator.parentIsArchived(any())).thenReturn(isArchivedResult); when(validator.thisUserIsNotOwner(any())).thenReturn(userIsNotOwnerResult); when(validator.contentHasChangesInDefaultBranch(any(), any(), any())).thenReturn(contentHasChangesResult); when(validator.shouldFork(any(), any(), any())).thenCallRealMethod(); assertEquals(validator.shouldFork(mock(GHRepository.class), mock(GHContent.class), mock(GitForkBranch.class)), expectedResult); }