Search in sources :

Example 11 with DefaultIssueComment

use of org.sonar.core.issue.DefaultIssueComment in project sonarqube by SonarSource.

the class PersistIssuesStep method insertChanges.

private static void insertChanges(IssueChangeMapper mapper, DefaultIssue issue) {
    for (IssueComment comment : issue.comments()) {
        DefaultIssueComment c = (DefaultIssueComment) comment;
        if (c.isNew()) {
            IssueChangeDto changeDto = IssueChangeDto.of(c);
            mapper.insert(changeDto);
        }
    }
    FieldDiffs diffs = issue.currentChange();
    if (!issue.isNew() && diffs != null) {
        IssueChangeDto changeDto = IssueChangeDto.of(issue.key(), diffs);
        mapper.insert(changeDto);
    }
}
Also used : IssueChangeDto(org.sonar.db.issue.IssueChangeDto) FieldDiffs(org.sonar.core.issue.FieldDiffs) DefaultIssueComment(org.sonar.core.issue.DefaultIssueComment) IssueComment(org.sonar.api.issue.IssueComment) DefaultIssueComment(org.sonar.core.issue.DefaultIssueComment)

Example 12 with DefaultIssueComment

use of org.sonar.core.issue.DefaultIssueComment in project sonarqube by SonarSource.

the class IssueStorage method insertChanges.

private void insertChanges(IssueChangeMapper mapper, DefaultIssue issue) {
    for (IssueComment comment : issue.comments()) {
        DefaultIssueComment c = (DefaultIssueComment) comment;
        if (c.isNew()) {
            IssueChangeDto changeDto = IssueChangeDto.of(c);
            mapper.insert(changeDto);
        }
    }
    FieldDiffs diffs = issue.currentChange();
    if (!issue.isNew() && diffs != null) {
        IssueChangeDto changeDto = IssueChangeDto.of(issue.key(), diffs);
        mapper.insert(changeDto);
    }
}
Also used : IssueChangeDto(org.sonar.db.issue.IssueChangeDto) FieldDiffs(org.sonar.core.issue.FieldDiffs) DefaultIssueComment(org.sonar.core.issue.DefaultIssueComment) IssueComment(org.sonar.api.issue.IssueComment) DefaultIssueComment(org.sonar.core.issue.DefaultIssueComment)

Example 13 with DefaultIssueComment

use of org.sonar.core.issue.DefaultIssueComment in project sonarqube by SonarSource.

the class ServerIssueStorageTest method should_insert_new_issues.

@Test
public void should_insert_new_issues() {
    dbTester.prepareDbUnit(getClass(), "should_insert_new_issues.xml");
    DefaultIssueComment comment = DefaultIssueComment.create("ABCDE", "emmerik", "the comment");
    // override generated key
    comment.setKey("FGHIJ");
    Date date = DateUtils.parseDateTime("2013-05-18T12:00:00+0000");
    DefaultIssue issue = new DefaultIssue().setKey("ABCDE").setType(RuleType.BUG).setNew(true).setRuleKey(RuleKey.of("squid", "AvoidCycle")).setProjectKey("struts").setLine(5000).setEffort(Duration.create(10L)).setResolution("OPEN").setStatus("OPEN").setSeverity("BLOCKER").setAttribute("foo", "bar").addComment(comment).setCreationDate(date).setUpdateDate(date).setCloseDate(date).setComponentKey("struts:Action");
    storage.save(issue);
    dbTester.assertDbUnit(getClass(), "should_insert_new_issues-result.xml", new String[] { "id", "created_at", "updated_at", "issue_change_creation_date" }, "issues", "issue_changes");
}
Also used : DefaultIssue(org.sonar.core.issue.DefaultIssue) DefaultIssueComment(org.sonar.core.issue.DefaultIssueComment) Date(java.util.Date) Test(org.junit.Test)

Example 14 with DefaultIssueComment

use of org.sonar.core.issue.DefaultIssueComment in project sonarqube by SonarSource.

the class IssueStorageTest method batch_insert_new_issues.

@Test
public void batch_insert_new_issues() {
    FakeBatchSaver saver = new FakeBatchSaver(dbClient, new FakeRuleFinder());
    DefaultIssueComment comment = DefaultIssueComment.create("ABCDE", "emmerik", "the comment");
    // override generated key
    comment.setKey("FGHIJ");
    Date date = DateUtils.parseDateTime("2013-05-18T12:00:00+0000");
    DefaultIssue issue = new DefaultIssue().setKey("ABCDE").setType(RuleType.BUG).setNew(true).setRuleKey(RuleKey.of("squid", "AvoidCycle")).setLine(5000).setEffort(Duration.create(10L)).setResolution("OPEN").setStatus("OPEN").setSeverity("BLOCKER").setAttribute("foo", "bar").addComment(comment).setCreationDate(date).setUpdateDate(date).setCloseDate(date).setComponentUuid("uuid-100").setProjectUuid("uuid-10").setComponentKey("struts:Action");
    saver.save(issue);
    dbTester.assertDbUnit(getClass(), "should_insert_new_issues-result.xml", new String[] { "id", "created_at", "updated_at", "issue_change_creation_date" }, "issues", "issue_changes");
}
Also used : DefaultIssue(org.sonar.core.issue.DefaultIssue) DefaultIssueComment(org.sonar.core.issue.DefaultIssueComment) Date(java.util.Date) Test(org.junit.Test)

Aggregations

DefaultIssueComment (org.sonar.core.issue.DefaultIssueComment)14 Test (org.junit.Test)12 DefaultIssue (org.sonar.core.issue.DefaultIssue)8 Date (java.util.Date)7 IssueComment (org.sonar.api.issue.IssueComment)2 FieldDiffs (org.sonar.core.issue.FieldDiffs)2 ComponentDto (org.sonar.db.component.ComponentDto)2 IssueChangeDto (org.sonar.db.issue.IssueChangeDto)2 IssueChangeContext (org.sonar.core.issue.IssueChangeContext)1