@Test public void testThisUserIsOwner() throws IOException { GitHubUtil gitHubUtil = mock(GitHubUtil.class); DockerfileGitHubUtil dockerfileGitHubUtil = new DockerfileGitHubUtil(gitHubUtil); String me = "me"; GHRepository repo = mock(GHRepository.class); when(repo.getOwnerName()).thenReturn(me); GHMyself ghMyself = mock(GHMyself.class); when(ghMyself.getLogin()).thenReturn(me); when(gitHubUtil.getMyself()).thenReturn(ghMyself); assertTrue(dockerfileGitHubUtil.thisUserIsOwner(repo)); }
public boolean thisUserIsOwner(GHRepository repo) throws IOException { String repoOwner = repo.getOwnerName(); GHMyself myself = gitHubUtil.getMyself(); if (myself == null) { throw new IOException("Could not retrieve authenticated user."); } String myselfLogin = myself.getLogin(); return repoOwner.equals(myselfLogin); }
DockerfileGitHubUtil { public boolean thisUserIsOwner(GHRepository repo) throws IOException { String repoOwner = repo.getOwnerName(); GHMyself myself = gitHubUtil.getMyself(); if (myself == null) { throw new IOException("Could not retrieve authenticated user."); } String myselfLogin = myself.getLogin(); return repoOwner.equals(myselfLogin); } }
DockerfileGitHubUtil { public boolean thisUserIsOwner(GHRepository repo) throws IOException { String repoOwner = repo.getOwnerName(); GHMyself myself = gitHubUtil.getMyself(); if (myself == null) { throw new IOException("Could not retrieve authenticated user."); } String myselfLogin = myself.getLogin(); return repoOwner.equals(myselfLogin); } DockerfileGitHubUtil(GitHubUtil gitHubUtil); }
DockerfileGitHubUtil { public boolean thisUserIsOwner(GHRepository repo) throws IOException { String repoOwner = repo.getOwnerName(); GHMyself myself = gitHubUtil.getMyself(); if (myself == null) { throw new IOException("Could not retrieve authenticated user."); } String myselfLogin = myself.getLogin(); return repoOwner.equals(myselfLogin); } DockerfileGitHubUtil(GitHubUtil gitHubUtil); GHRepository getOrCreateFork(GHRepository parent); GHMyself getMyself(); GHRepository getRepo(String repoName); PagedSearchIterable<GHContent> findFilesWithImage(String query, String org); List<GHRepository> getGHRepositories(Multimap<String, String> pathToDockerfileInParentRepo,
                                                            GHMyself currentUser); void modifyAllOnGithub(GHRepository repo, String branch,
                                  String img, String tag); GHContent tryRetrievingContent(GHRepository repo, String path, String branch); void modifyOnGithub(GHContent content,
                               String branch, String img, String tag, String customMessage); GitHubJsonStore getGitHubJsonStore(String store); void createPullReq(GHRepository origRepo,
                              String branch, GHRepository forkRepo,
                              PullRequestInfo pullRequestInfo); Optional<GHPullRequest> getPullRequestForImageBranch(GHRepository repository, GitForkBranch gitForkBranch); void createOrUpdateForkBranchToParentDefault(GHRepository parent, GHRepository fork, GitForkBranch gitForkBranch); boolean thisUserIsOwner(GHRepository repo); Optional<PagedSearchIterable<GHContent>> getGHContents(String org, String img); }
DockerfileGitHubUtil { public boolean thisUserIsOwner(GHRepository repo) throws IOException { String repoOwner = repo.getOwnerName(); GHMyself myself = gitHubUtil.getMyself(); if (myself == null) { throw new IOException("Could not retrieve authenticated user."); } String myselfLogin = myself.getLogin(); return repoOwner.equals(myselfLogin); } DockerfileGitHubUtil(GitHubUtil gitHubUtil); GHRepository getOrCreateFork(GHRepository parent); GHMyself getMyself(); GHRepository getRepo(String repoName); PagedSearchIterable<GHContent> findFilesWithImage(String query, String org); List<GHRepository> getGHRepositories(Multimap<String, String> pathToDockerfileInParentRepo,
                                                            GHMyself currentUser); void modifyAllOnGithub(GHRepository repo, String branch,
                                  String img, String tag); GHContent tryRetrievingContent(GHRepository repo, String path, String branch); void modifyOnGithub(GHContent content,
                               String branch, String img, String tag, String customMessage); GitHubJsonStore getGitHubJsonStore(String store); void createPullReq(GHRepository origRepo,
                              String branch, GHRepository forkRepo,
                              PullRequestInfo pullRequestInfo); Optional<GHPullRequest> getPullRequestForImageBranch(GHRepository repository, GitForkBranch gitForkBranch); void createOrUpdateForkBranchToParentDefault(GHRepository parent, GHRepository fork, GitForkBranch gitForkBranch); boolean thisUserIsOwner(GHRepository repo); Optional<PagedSearchIterable<GHContent>> getGHContents(String org, String img);  }