use of org.sonar.db.issue.IssueChangeDto in project sonarqube by SonarSource.
the class EditCommentActionTest method fail_when_comment_has_not_user.
@Test
public void fail_when_comment_has_not_user() throws Exception {
IssueDto issueDto = issueDbTester.insertIssue();
IssueChangeDto commentDto = issueDbTester.insertComment(issueDto, null, "please fix it");
userSession.logIn("john").addProjectUuidPermissions(USER, issueDto.getProjectUuid());
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("You can only edit your own comments");
call(commentDto.getKey(), "please have a look");
}
use of org.sonar.db.issue.IssueChangeDto 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);
}
}
use of org.sonar.db.issue.IssueChangeDto in project sonarqube by SonarSource.
the class SearchResponseFormat method formatIssueComments.
private static void formatIssueComments(SearchResponseData data, Issues.Issue.Builder wsIssue, IssueDto dto) {
Issues.Comments.Builder wsComments = Issues.Comments.newBuilder();
List<IssueChangeDto> comments = data.getCommentsForIssueKey(dto.getKey());
if (comments != null) {
Issues.Comment.Builder wsComment = Issues.Comment.newBuilder();
for (IssueChangeDto comment : comments) {
String markdown = comment.getChangeData();
wsComment.clear().setKey(comment.getKey()).setLogin(nullToEmpty(comment.getUserLogin())).setUpdatable(data.isUpdatableComment(comment.getKey())).setCreatedAt(DateUtils.formatDateTime(new Date(comment.getCreatedAt())));
if (markdown != null) {
wsComment.setHtmlText(Markdown.convertToHtml(markdown)).setMarkdown(markdown);
}
wsComments.addComments(wsComment);
}
}
wsIssue.setComments(wsComments);
}
use of org.sonar.db.issue.IssueChangeDto 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);
}
}
use of org.sonar.db.issue.IssueChangeDto in project sonarqube by SonarSource.
the class NewEffortCalculatorTest method new_debt_if_issue_created_before_period.
@Test
public void new_debt_if_issue_created_before_period() {
// creation: 1d
// before period: increased to 2d
// after period: increased to 5d, decreased to 4d then increased to 10d
// -> new debt is 10d - 2d = 8d
issue.setEffort(TEN_DAYS).setCreationDate(new Date(PERIOD_DATE - 10000));
List<IssueChangeDto> changelog = Arrays.asList(newDebtChangelog(ONE_DAY.toMinutes(), TWO_DAYS.toMinutes(), PERIOD_DATE - 9000), newDebtChangelog(TWO_DAYS.toMinutes(), FIVE_DAYS.toMinutes(), PERIOD_DATE + 10000), newDebtChangelog(FIVE_DAYS.toMinutes(), FOUR_DAYS.toMinutes(), PERIOD_DATE + 20000), newDebtChangelog(FOUR_DAYS.toMinutes(), TEN_DAYS.toMinutes(), PERIOD_DATE + 30000));
long newDebt = underTest.calculate(issue, changelog, PERIOD);
assertThat(newDebt).isEqualTo(TEN_DAYS.toMinutes() - TWO_DAYS.toMinutes());
}
Aggregations