test_class.file: dockerfile-image-update/src/test/java/com/salesforce/dockerfileimageupdate/utils/GitHubUtilTest.java
test_class.identifier: GitHubUtilTest
test_case.body: @Test
      public void testCreatePullReq_errorCase0() throws Exception {
          GitHub github = mock(GitHub.class);
          GitHubUtil gitHubUtil = new GitHubUtil(github);
          GHRepository origRepo = mock(GHRepository.class);
          when(origRepo.getDefaultBranch()).thenReturn("master");
          when(origRepo.createPullRequest(eq("title"), eq("owner:branch"), eq("master"), eq("body")))
                  .thenThrow(new IOException("{\"message\":\"Validation Failed\",\"errors\":[{\"resource\":\"PullRequest\",\"code\":\"custom\",\"message\":\"A pull request already exists for someone:somebranch.\"}],\"documentation_url\":\"https://developer.github.com/enterprise/2.6/v3/pulls/#create-a-pull-request\"}"));
          GHRepository forkRepo = mock(GHRepository.class);
          when(forkRepo.getOwnerName()).thenReturn("owner");
          assertEquals(gitHubUtil.createPullReq(origRepo, "branch", forkRepo, "title", "body"), 0);
          verify(origRepo, times(1)).createPullRequest(eq("title"), eq("owner:branch"), eq("master"), eq("body"));
      }
test_case.class_method_signature: GitHubUtilTest.testCreatePullReq_errorCase0()
test_case.full_signature: @Test public void testCreatePullReq_errorCase0()
test_case.identifier: testCreatePullReq_errorCase0
test_case.invocations: mock mock thenReturn when getDefaultBranch thenThrow when createPullRequest eq eq eq eq mock thenReturn when getOwnerName assertEquals createPullReq createPullRequest verify times eq eq eq eq
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testCreatePullReq_errorCase0()
focal_class.declarator: log = LoggerFactory.getLogger(GitHubUtil.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger log = LoggerFactory.getLogger(GitHubUtil.class);
focal_class.type: Logger
focal_class.var_name: log
focal_class.declarator: NO_BRANCH_WARN_FORMAT = "Couldn't find branch `%s` in repo `%s`. Waiting a second..."
focal_class.modifier: public static final
focal_class.original_string: public static final String NO_BRANCH_WARN_FORMAT = "Couldn't find branch `%s` in repo `%s`. Waiting a second...";
focal_class.type: String
focal_class.var_name: NO_BRANCH_WARN_FORMAT
focal_class.declarator: github
focal_class.modifier: private final
focal_class.original_string: private final GitHub github;
focal_class.type: GitHub
focal_class.var_name: github
focal_class.file: dockerfile-image-update/src/main/java/com/salesforce/dockerfileimageupdate/utils/GitHubUtil.java
focal_class.identifier: GitHubUtil
focal_class.class_method_signature: GitHubUtil.GitHubUtil(GitHub gitHub)
focal_class.full_signature: public  GitHubUtil(GitHub gitHub)
focal_class.identifier: GitHubUtil
focal_class.modifiers: public
focal_class.parameters: (GitHub gitHub)
focal_class.signature:  GitHubUtil(GitHub gitHub)
focal_class.class_method_signature: GitHubUtil.getGithub()
focal_class.full_signature: public GitHub getGithub()
focal_class.identifier: getGithub
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: GitHub
focal_class.signature: GitHub getGithub()
focal_class.class_method_signature: GitHubUtil.getRepo(String repo)
focal_class.full_signature: public GHRepository getRepo(String repo)
focal_class.identifier: getRepo
focal_class.modifiers: public
focal_class.parameters: (String repo)
focal_class.return: GHRepository
focal_class.signature: GHRepository getRepo(String repo)
focal_class.class_method_signature: GitHubUtil.createPublicRepo(String repoName)
focal_class.full_signature: public GHRepository createPublicRepo(String repoName)
focal_class.identifier: createPublicRepo
focal_class.modifiers: public
focal_class.parameters: (String repoName)
focal_class.return: GHRepository
focal_class.signature: GHRepository createPublicRepo(String repoName)
focal_class.class_method_signature: GitHubUtil.getMyself()
focal_class.full_signature: public GHMyself getMyself()
focal_class.identifier: getMyself
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: GHMyself
focal_class.signature: GHMyself getMyself()
focal_class.class_method_signature: GitHubUtil.startSearch()
focal_class.full_signature: public GHContentSearchBuilder startSearch()
focal_class.identifier: startSearch
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: GHContentSearchBuilder
focal_class.signature: GHContentSearchBuilder startSearch()
focal_class.class_method_signature: GitHubUtil.createFork(GHRepository repo)
focal_class.full_signature: public GHRepository createFork(GHRepository repo)
focal_class.identifier: createFork
focal_class.modifiers: public
focal_class.parameters: (GHRepository repo)
focal_class.return: GHRepository
focal_class.signature: GHRepository createFork(GHRepository repo)
focal_class.class_method_signature: GitHubUtil.safeDeleteRepo(GHRepository repo)
focal_class.full_signature: public void safeDeleteRepo(GHRepository repo)
focal_class.identifier: safeDeleteRepo
focal_class.modifiers: public
focal_class.parameters: (GHRepository repo)
focal_class.return: void
focal_class.signature: void safeDeleteRepo(GHRepository repo)
focal_class.class_method_signature: GitHubUtil.createPullReq(GHRepository origRepo, String branch,
                                   GHRepository forkRepo, String title, String body)
focal_class.full_signature: public int createPullReq(GHRepository origRepo, String branch,
                                   GHRepository forkRepo, String title, String body)
focal_class.identifier: createPullReq
focal_class.modifiers: public
focal_class.parameters: (GHRepository origRepo, String branch,
                                   GHRepository forkRepo, String title, String body)
focal_class.return: int
focal_class.signature: int createPullReq(GHRepository origRepo, String branch,
                                   GHRepository forkRepo, String title, String body)
focal_class.class_method_signature: GitHubUtil.tryRetrievingBranch(GHRepository repo, String branchName)
focal_class.full_signature: protected GHBranch tryRetrievingBranch(GHRepository repo, String branchName)
focal_class.identifier: tryRetrievingBranch
focal_class.modifiers: protected
focal_class.parameters: (GHRepository repo, String branchName)
focal_class.return: GHBranch
focal_class.signature: GHBranch tryRetrievingBranch(GHRepository repo, String branchName)
focal_class.class_method_signature: GitHubUtil.tryRetrievingRepository(String repoName)
focal_class.full_signature: public GHRepository tryRetrievingRepository(String repoName)
focal_class.identifier: tryRetrievingRepository
focal_class.modifiers: public
focal_class.parameters: (String repoName)
focal_class.return: GHRepository
focal_class.signature: GHRepository tryRetrievingRepository(String repoName)
focal_class.class_method_signature: GitHubUtil.tryRetrievingContent(GHRepository repo, String path, String branch)
focal_class.full_signature: public GHContent tryRetrievingContent(GHRepository repo, String path, String branch)
focal_class.identifier: tryRetrievingContent
focal_class.modifiers: public
focal_class.parameters: (GHRepository repo, String path, String branch)
focal_class.return: GHContent
focal_class.signature: GHContent tryRetrievingContent(GHRepository repo, String path, String branch)
focal_class.class_method_signature: GitHubUtil.getGHRepositories(Multimap<String, String> pathToDockerfileInParentRepo,
                                                   GHMyself currentUser)
focal_class.full_signature: public List<GHRepository> getGHRepositories(Multimap<String, String> pathToDockerfileInParentRepo,
                                                   GHMyself currentUser)
focal_class.identifier: getGHRepositories
focal_class.modifiers: public
focal_class.parameters: (Multimap<String, String> pathToDockerfileInParentRepo,
                                                   GHMyself currentUser)
focal_class.return: List<GHRepository>
focal_class.signature: List<GHRepository> getGHRepositories(Multimap<String, String> pathToDockerfileInParentRepo,
                                                   GHMyself currentUser)
focal_class.class_method_signature: GitHubUtil.waitFor(long millis)
focal_class.full_signature: protected void waitFor(long millis)
focal_class.identifier: waitFor
focal_class.modifiers: protected
focal_class.parameters: (long millis)
focal_class.return: void
focal_class.signature: void waitFor(long millis)
focal_class.class_method_signature: GitHubUtil.repoHasBranch(GHRepository repo, String branchName)
focal_class.full_signature: public boolean repoHasBranch(GHRepository repo, String branchName)
focal_class.identifier: repoHasBranch
focal_class.modifiers: public
focal_class.parameters: (GHRepository repo, String branchName)
focal_class.return: boolean
focal_class.signature: boolean repoHasBranch(GHRepository repo, String branchName)
focal_class.class_method_signature: GitHubUtil.getReposForUserAtCurrentInstant(GHMyself user)
focal_class.full_signature: public Map<String, GHRepository> getReposForUserAtCurrentInstant(GHMyself user)
focal_class.identifier: getReposForUserAtCurrentInstant
focal_class.modifiers: public
focal_class.parameters: (GHMyself user)
focal_class.return: Map<String, GHRepository>
focal_class.signature: Map<String, GHRepository> getReposForUserAtCurrentInstant(GHMyself user)
focal_method.body: public int createPullReq(GHRepository origRepo, String branch,
                                   GHRepository forkRepo, String title, String body) throws InterruptedException {
          log.info("Creating Pull Request on {} from {}...", origRepo.getFullName(), forkRepo.getFullName());
          //TODO: if no commits, pull request will fail, but this doesn't handle that.
          try {
              GHPullRequest pullRequest = origRepo.createPullRequest(title, forkRepo.getOwnerName() + ":" + branch,
                      origRepo.getDefaultBranch(), body);
  //            origRepo.createPullRequest("Update base image in Dockerfile", forkRepo.getOwnerName() + ":" + branch,
  //                    origRepo.getDefaultBranch(), "Automatic Dockerfile Image Updater. Please merge.");
              log.info("A pull request has been created at {}", pullRequest.getHtmlUrl());
              return 0;
          } catch (IOException e) {
              log.warn("Handling error with pull request creation... {}", e.getMessage());
              JsonElement root = JsonParser.parseString(e.getMessage());
              JsonArray errorJson = root.getAsJsonObject().get("errors").getAsJsonArray();
              String error = errorJson.get(0).getAsJsonObject().get("message").getAsString();
              log.info("error: {}", error);
              if (error.startsWith("A pull request already exists")) {
                  log.info("NOTE: {} New commits may have been added to the pull request.", error);
                  return 0;
              } else if (error.startsWith("No commits between")) {
                  log.warn("NOTE: {} Pull request was not created.", error);
                  return 1;
              } else {
                  // TODO: THIS WILL LOOP FOREVVEEEEEERRRR
                  log.warn("An error occurred in pull request: {} Trying again...", error);
                  waitFor(TimeUnit.SECONDS.toMillis(3));
                  return -1;
              }
          }
      }
focal_method.class_method_signature: GitHubUtil.createPullReq(GHRepository origRepo, String branch,
                                   GHRepository forkRepo, String title, String body)
focal_method.full_signature: public int createPullReq(GHRepository origRepo, String branch,
                                   GHRepository forkRepo, String title, String body)
focal_method.identifier: createPullReq
focal_method.invocations: info getFullName getFullName createPullRequest getOwnerName getDefaultBranch info getHtmlUrl warn getMessage parseString getMessage getAsJsonArray get getAsJsonObject getAsString get getAsJsonObject get info startsWith info startsWith warn warn waitFor toMillis
focal_method.modifiers: public
focal_method.parameters: (GHRepository origRepo, String branch,
                                   GHRepository forkRepo, String title, String body)
focal_method.return: int
focal_method.signature: int createPullReq(GHRepository origRepo, String branch,
                                   GHRepository forkRepo, String title, String body)