Search in sources :

Example 1 with DefaultIssueComment

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

the class PersistIssuesStepTest method add_comment.

@Test
public void add_comment() {
    dbTester.prepareDbUnit(getClass(), "shared.xml");
    issueCache.newAppender().append(new DefaultIssue().setKey("ISSUE").setType(RuleType.CODE_SMELL).setRuleKey(RuleKey.of("xoo", "S01")).setComponentUuid("COMPONENT").setProjectUuid("PROJECT").setSeverity(Severity.BLOCKER).setStatus(Issue.STATUS_CLOSED).setResolution(Issue.RESOLUTION_FIXED).setNew(false).setChanged(true).addComment(new DefaultIssueComment().setKey("COMMENT").setIssueKey("ISSUE").setUserLogin("john").setMarkdownText("Some text").setNew(true))).close();
    step.execute();
    dbTester.assertDbUnit(getClass(), "add_comment-result.xml", new String[] { "id", "created_at", "updated_at" }, "issue_changes");
}
Also used : DefaultIssue(org.sonar.core.issue.DefaultIssue) DefaultIssueComment(org.sonar.core.issue.DefaultIssueComment) Test(org.junit.Test)

Example 2 with DefaultIssueComment

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

the class IssueStorageTest method batch_update_issues.

@Test
public void batch_update_issues() {
    dbTester.prepareDbUnit(getClass(), "should_update_issues.xml");
    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(false).setChanged(true).setLine(5000).setEffort(Duration.create(10L)).setChecksum("FFFFF").setAuthorLogin("simon").setAssignee("loic").setFieldChange(context, "severity", "INFO", "BLOCKER").setResolution("FIXED").setStatus("RESOLVED").setSeverity("BLOCKER").setAttribute("foo", "bar").addComment(comment).setCreationDate(date).setUpdateDate(date).setCloseDate(date).setComponentUuid("uuid-100").setProjectUuid("uuid-10").setRuleKey(RuleKey.of("xxx", "unknown")).setComponentKey("not:a:component");
    saver.save(issue);
    dbTester.assertDbUnit(getClass(), "should_update_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 3 with DefaultIssueComment

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

the class IssueStorageTest method batch_insert_new_issues_with_session.

@Test
public void batch_insert_new_issues_with_session() {
    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(dbTester.getSession(), issue);
    dbTester.getSession().commit();
    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 4 with DefaultIssueComment

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

the class IssueStorageTest method server_insert_new_issues_with_session.

@Test
public void server_insert_new_issues_with_session() {
    ComponentDto project = new ComponentDto().setId(10L).setUuid("uuid-10");
    ComponentDto component = new ComponentDto().setId(100L).setUuid("uuid-100");
    FakeServerSaver saver = new FakeServerSaver(dbClient, new FakeRuleFinder(), component, project);
    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).setComponentKey("struts:Action").setComponentUuid("component-uuid").setProjectUuid("project-uuid");
    saver.save(dbTester.getSession(), issue);
    dbTester.getSession().commit();
    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 : ComponentDto(org.sonar.db.component.ComponentDto) DefaultIssue(org.sonar.core.issue.DefaultIssue) DefaultIssueComment(org.sonar.core.issue.DefaultIssueComment) Date(java.util.Date) Test(org.junit.Test)

Example 5 with DefaultIssueComment

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

the class IssueStorageTest method server_update_issues.

@Test
public void server_update_issues() {
    dbTester.prepareDbUnit(getClass(), "should_update_issues.xml");
    ComponentDto project = new ComponentDto().setId(10L).setUuid("whatever-uuid");
    ComponentDto component = new ComponentDto().setId(100L).setUuid("whatever-uuid-2");
    FakeServerSaver saver = new FakeServerSaver(dbClient, new FakeRuleFinder(), component, project);
    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(false).setChanged(true).setLine(5000).setEffort(Duration.create(10L)).setChecksum("FFFFF").setAuthorLogin("simon").setAssignee("loic").setFieldChange(context, "severity", "INFO", "BLOCKER").setResolution("FIXED").setStatus("RESOLVED").setSeverity("BLOCKER").setAttribute("foo", "bar").addComment(comment).setCreationDate(date).setUpdateDate(date).setCloseDate(date).setProjectUuid("uuid-10").setRuleKey(RuleKey.of("xxx", "unknown")).setComponentKey("not:a:component");
    saver.save(issue);
    dbTester.assertDbUnit(getClass(), "should_update_issues-result.xml", new String[] { "id", "created_at", "updated_at", "issue_change_creation_date" }, "issues", "issue_changes");
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) 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)22 Test (org.junit.Test)18 Date (java.util.Date)13 DefaultIssue (org.sonar.core.issue.DefaultIssue)13 FieldDiffs (org.sonar.core.issue.FieldDiffs)7 ComponentDto (org.sonar.db.component.ComponentDto)6 IssueChangeDto (org.sonar.db.issue.IssueChangeDto)6 RuleDefinitionDto (org.sonar.db.rule.RuleDefinitionDto)4 TestComputationStepContext (org.sonar.ce.task.step.TestComputationStepContext)3 IssueDto (org.sonar.db.issue.IssueDto)3 IssueComment (org.sonar.api.issue.IssueComment)2 DateUtils.parseDate (org.sonar.api.utils.DateUtils.parseDate)2 Branch (org.sonar.ce.task.projectanalysis.analysis.Branch)2 DiskCache (org.sonar.ce.task.projectanalysis.util.cache.DiskCache)1 IssueChangeContext (org.sonar.core.issue.IssueChangeContext)1