Esempio n. 1
0
 public static IssueChangeDto of(DefaultIssueComment comment) {
   IssueChangeDto dto = newDto(comment.issueKey());
   dto.setKey(comment.key());
   dto.setChangeType(IssueChangeDto.TYPE_COMMENT);
   dto.setChangeData(comment.markdownText());
   dto.setUserLogin(comment.userLogin());
   return dto;
 }
  @Test
  public void should_update_issues() throws Exception {
    setupData("should_update_issues");

    IssueChangeContext context = IssueChangeContext.createUser(new Date(), "emmerik");

    DefaultIssueComment comment = DefaultIssueComment.create("ABCDE", "emmerik", "the comment");
    // override generated key
    comment.setKey("FGHIJ");

    Date date = DateUtils.parseDate("2013-05-18");
    DefaultIssue issue =
        new DefaultIssue()
            .setKey("ABCDE")
            .setNew(false)
            .setChanged(true)

            // updated fields
            .setLine(5000)
            .setProjectUuid("CDEF")
            .setDebt(Duration.create(10L))
            .setChecksum("FFFFF")
            .setAuthorLogin("simon")
            .setAssignee("loic")
            .setFieldChange(context, "severity", "INFO", "BLOCKER")
            .setReporter("emmerik")
            .setResolution("FIXED")
            .setStatus("RESOLVED")
            .setSeverity("BLOCKER")
            .setAttribute("foo", "bar")
            .addComment(comment)
            .setCreationDate(date)
            .setUpdateDate(date)
            .setCloseDate(date)

            // unmodifiable fields
            .setRuleKey(RuleKey.of("xxx", "unknown"))
            .setComponentKey("struts:Action")
            .setProjectKey("struts");

    storage.save(issue);

    checkTables(
        "should_update_issues",
        new String[] {"id", "created_at", "updated_at", "issue_change_creation_date"},
        "issues",
        "issue_changes");
  }
  @Test
  public void should_insert_new_issues() throws Exception {
    setupData("should_insert_new_issues");

    DefaultIssueComment comment = DefaultIssueComment.create("ABCDE", "emmerik", "the comment");
    // override generated key
    comment.setKey("FGHIJ");

    Date date = DateUtils.parseDate("2013-05-18");
    DefaultIssue issue =
        new DefaultIssue()
            .setKey("ABCDE")
            .setNew(true)
            .setRuleKey(RuleKey.of("squid", "AvoidCycle"))
            .setProjectKey("struts")
            .setLine(5000)
            .setDebt(Duration.create(10L))
            .setReporter("emmerik")
            .setResolution("OPEN")
            .setStatus("OPEN")
            .setSeverity("BLOCKER")
            .setAttribute("foo", "bar")
            .addComment(comment)
            .setCreationDate(date)
            .setUpdateDate(date)
            .setCloseDate(date)
            .setComponentKey("struts:Action");

    storage.save(issue);

    checkTables(
        "should_insert_new_issues",
        new String[] {"id", "created_at", "updated_at", "issue_change_creation_date"},
        "issues",
        "issue_changes");
  }
Esempio n. 4
0
 public void addComment(DefaultIssue issue, String text, IssueChangeContext context) {
   issue.addComment(DefaultIssueComment.create(issue.key(), context.login(), text));
   issue.setUpdateDate(context.date());
   issue.setChanged(true);
 }