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");
}
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");
}
use of org.sonar.core.issue.DefaultIssueComment in project sonarqube by SonarSource.
the class ServerIssueStorageTest method should_update_issues.
@Test
public void should_update_issues() {
dbTester.prepareDbUnit(getClass(), "should_update_issues.xml");
IssueChangeContext context = IssueChangeContext.createUser(new Date(), "emmerik");
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).setProjectUuid("CDEF").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).setRuleKey(RuleKey.of("xxx", "unknown")).setComponentKey("struts:Action").setProjectKey("struts");
storage.save(issue);
dbTester.assertDbUnit(getClass(), "should_update_issues-result.xml", new String[] { "id", "created_at", "updated_at", "issue_change_creation_date" }, "issues", "issue_changes");
}
use of org.sonar.core.issue.DefaultIssueComment in project sonarqube by SonarSource.
the class IssueChangeDtoTest method to_comment.
@Test
public void to_comment() {
IssueChangeDto changeDto = new IssueChangeDto().setKey("EFGH").setUserLogin("emmerik").setChangeData("Some text").setIssueKey("ABCDE").setCreatedAt(System2.INSTANCE.now()).setUpdatedAt(System2.INSTANCE.now());
DefaultIssueComment comment = changeDto.toComment();
assertThat(comment.key()).isEqualTo("EFGH");
assertThat(comment.markdownText()).isEqualTo("Some text");
assertThat(comment.createdAt()).isNotNull();
assertThat(comment.updatedAt()).isNotNull();
assertThat(comment.userLogin()).isEqualTo("emmerik");
assertThat(comment.issueKey()).isEqualTo("ABCDE");
}
use of org.sonar.core.issue.DefaultIssueComment in project sonarqube by SonarSource.
the class IssueChangeDtoTest method create_from_comment.
@Test
public void create_from_comment() {
DefaultIssueComment comment = DefaultIssueComment.create("ABCDE", "emmerik", "the comment");
IssueChangeDto dto = IssueChangeDto.of(comment);
assertThat(dto.getChangeData()).isEqualTo("the comment");
assertThat(dto.getChangeType()).isEqualTo("comment");
assertThat(dto.getCreatedAt()).isNotNull();
assertThat(dto.getUpdatedAt()).isNotNull();
assertThat(dto.getIssueChangeCreationDate()).isNotNull();
assertThat(dto.getIssueKey()).isEqualTo("ABCDE");
assertThat(dto.getUserLogin()).isEqualTo("emmerik");
}
Aggregations