@Test public void testCanForkThisUserIsNotOwner() throws IOException { DockerfileGitHubUtil dockerfileGitHubUtil = mock(DockerfileGitHubUtil.class); GHRepository repo = mock(GHRepository.class); ForkableRepoValidator validator = new ForkableRepoValidator(dockerfileGitHubUtil); when(dockerfileGitHubUtil.thisUserIsOwner(repo)).thenReturn(false); ShouldForkResult shouldForkResult = validator.thisUserIsNotOwner(repo); assertTrue(shouldForkResult.isForkable()); }
protected ShouldForkResult thisUserIsNotOwner(GHRepository parentRepo) { try { if (dockerfileGitHubUtil.thisUserIsOwner(parentRepo)) { return shouldNotForkResult(REPO_IS_OWNED_BY_THIS_USER); } } catch (IOException ioException) { return shouldNotForkResult(COULD_NOT_CHECK_THIS_USER); } return shouldForkResult(); }
ForkableRepoValidator { protected ShouldForkResult thisUserIsNotOwner(GHRepository parentRepo) { try { if (dockerfileGitHubUtil.thisUserIsOwner(parentRepo)) { return shouldNotForkResult(REPO_IS_OWNED_BY_THIS_USER); } } catch (IOException ioException) { return shouldNotForkResult(COULD_NOT_CHECK_THIS_USER); } return shouldForkResult(); } }
ForkableRepoValidator { protected ShouldForkResult thisUserIsNotOwner(GHRepository parentRepo) { try { if (dockerfileGitHubUtil.thisUserIsOwner(parentRepo)) { return shouldNotForkResult(REPO_IS_OWNED_BY_THIS_USER); } } catch (IOException ioException) { return shouldNotForkResult(COULD_NOT_CHECK_THIS_USER); } return shouldForkResult(); } ForkableRepoValidator(DockerfileGitHubUtil dockerfileGitHubUtil); }
ForkableRepoValidator { protected ShouldForkResult thisUserIsNotOwner(GHRepository parentRepo) { try { if (dockerfileGitHubUtil.thisUserIsOwner(parentRepo)) { return shouldNotForkResult(REPO_IS_OWNED_BY_THIS_USER); } } catch (IOException ioException) { return shouldNotForkResult(COULD_NOT_CHECK_THIS_USER); } return shouldForkResult(); } ForkableRepoValidator(DockerfileGitHubUtil dockerfileGitHubUtil); ShouldForkResult shouldFork(GHRepository parentRepo,
                                       GHContent searchResultContent,
                                       GitForkBranch gitForkBranch); }
ForkableRepoValidator { protected ShouldForkResult thisUserIsNotOwner(GHRepository parentRepo) { try { if (dockerfileGitHubUtil.thisUserIsOwner(parentRepo)) { return shouldNotForkResult(REPO_IS_OWNED_BY_THIS_USER); } } catch (IOException ioException) { return shouldNotForkResult(COULD_NOT_CHECK_THIS_USER); } return 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; }