Java Code Examples for org.eclipse.egit.github.core.Issue#setNumber()

The following examples show how to use org.eclipse.egit.github.core.Issue#setNumber() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GitHubRepo.java    From HubTurbo with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public Optional<Integer> setMilestone(String repoId, int issueId, String issueTitle,
                                      Optional<Integer> issueMilestone) throws IOException {
    // github api requires at least id and title
    Issue createdIssue = new Issue();
    createdIssue.setNumber(issueId);
    createdIssue.setTitle(issueTitle);

    Milestone gitHubMilestone = new Milestone();
    // set milestone number to the desired milestone id
    // simply don't set a number to demilestone
    issueMilestone.ifPresent(gitHubMilestone::setNumber);
    createdIssue.setMilestone(gitHubMilestone);

    Issue returnedIssue = issueService.editIssue(RepositoryId.createFromId(repoId), createdIssue);

    return Optional.ofNullable(returnedIssue.getMilestone())
            .map(Milestone::getNumber);
}
 
Example 2
Source File: GitHubRepo.java    From HubTurbo with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public Optional<String> setAssignee(String repoId, int issueId, String issueTitle,
                                    Optional<String> issueAssigneeLoginName) throws IOException {

    Issue createdIssue = new Issue();
    createdIssue.setNumber(issueId);
    createdIssue.setTitle(issueTitle);

    User issueAssignee = new User();
    issueAssigneeLoginName.ifPresent(issueAssignee::setLogin);
    createdIssue.setAssignee(issueAssignee);

    Issue issueReturned = issueService.editIssue(RepositoryId.createFromId(repoId), createdIssue);

    return Optional.ofNullable(issueReturned.getAssignee())
            .map(User::getLogin);
}
 
Example 3
Source File: TurboIssueTests.java    From HubTurbo with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Test
public void turboIssueTest() {
    Issue issue = new Issue();
    issue.setNumber(1);
    issue.setUser(new User().setLogin("test_user"));
    issue.setCreatedAt(new Date());
    issue.setUpdatedAt(new Date());
    issue.setState("open");
    ArrayList<Label> labels = new ArrayList<>();
    labels.add(new Label().setName("test label"));
    issue.setLabels(labels);
    TurboIssue turboIssue = new TurboIssue("dummy/dummy", issue);
    assertEquals(1, turboIssue.getId());
    assertEquals("test_user", turboIssue.getCreator());
    assertEquals(true, turboIssue.isOpen());
    assertEquals("test label", turboIssue.getLabels().get(0));
}
 
Example 4
Source File: GitHubExporter.java    From rtc2jira with GNU General Public License v2.0 4 votes vote down vote up
private Issue createIssueFromWorkItem(ODocument workItem) throws IOException {
  Issue issue = new Issue();
  for (Entry<String, Object> entry : workItem) {
    String field = entry.getKey();
    switch (field) {
      case ID:
        String id = (String) entry.getValue();
        issue.setNumber(Integer.valueOf(id));
        break;
      case SUMMARY:
        String summary = (String) entry.getValue();
        issue.setTitle(summary);
        break;
      case DESCRIPTION:
        String htmlText = (String) entry.getValue();
        issue.setBody(htmlText);
        break;
      case WORK_ITEM_TYPE:
        String workitemType = (String) entry.getValue();
        switch (workitemType) {
          case TASK:
            issue.setLabels(Collections.singletonList(getLabel("Task")));
            break;
          case STORY:
            issue.setLabels(Collections.singletonList(getLabel("Story")));
            break;
          case EPIC:
            issue.setLabels(Collections.singletonList(getLabel("Epic")));
            break;
          case BUSINESSNEED:
            issue.setLabels(Collections.singletonList(getLabel("Business Need")));
            break;
          case DEFECT:
            issue.setLabels(Collections.singletonList(getLabel("Defect")));
            break;
          default:
            LOGGER.warning("Cannot create label for unknown workitemType: " + workitemType);
            break;
        }
        break;
      default:
        break;
    }
  }
  issue.setTitle(issue.getNumber() + ": " + issue.getTitle());
  int existingGitHubIssueNumber = StorageQuery.getField(workItem, FieldNames.GITHUB_WORKITEM_LINK, 0);
  issue.setNumber(existingGitHubIssueNumber);
  return issue;
}