use of org.sonar.core.issue.FieldDiffs in project sonarqube by SonarSource.
the class IssueChangeDtoTest method create_from_diff.
@Test
public void create_from_diff() {
FieldDiffs diffs = new FieldDiffs();
diffs.setDiff("severity", "INFO", "BLOCKER");
diffs.setUserLogin("emmerik");
IssueChangeDto dto = IssueChangeDto.of("ABCDE", diffs);
assertThat(dto.getChangeData()).isEqualTo("severity=INFO|BLOCKER");
assertThat(dto.getChangeType()).isEqualTo("diff");
assertThat(dto.getCreatedAt()).isNotNull();
assertThat(dto.getUpdatedAt()).isNotNull();
assertThat(dto.getIssueChangeCreationDate()).isNull();
assertThat(dto.getIssueKey()).isEqualTo("ABCDE");
assertThat(dto.getUserLogin()).isEqualTo("emmerik");
}
use of org.sonar.core.issue.FieldDiffs in project sonarqube by SonarSource.
the class IssueChangeDtoTest method create_from_diff_with_created_at.
@Test
public void create_from_diff_with_created_at() {
FieldDiffs diffs = new FieldDiffs();
diffs.setDiff("severity", "INFO", "BLOCKER");
diffs.setUserLogin("emmerik");
diffs.setCreationDate(parseDate("2015-01-13"));
IssueChangeDto dto = IssueChangeDto.of("ABCDE", diffs);
assertThat(dto.getIssueChangeCreationDate()).isEqualTo(parseDate("2015-01-13").getTime());
}
use of org.sonar.core.issue.FieldDiffs 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.core.issue.FieldDiffs 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.core.issue.FieldDiffs in project sonarqube by SonarSource.
the class IssueChangeNotificationTest method set_issue_with_current_change_having_no_new_value.
@Test
public void set_issue_with_current_change_having_no_new_value() {
DefaultIssue issue = new DefaultIssue().setKey("ABCD").setAssignee("simon").setMessage("Remove this useless method").setComponentKey("MyService");
IssueChangeNotification result = notification.setIssue(issue.setCurrentChange(new FieldDiffs().setDiff("assignee", "john", null)));
assertThat(result.getFieldValue("old.assignee")).isEqualTo("john");
assertThat(result.getFieldValue("new.assignee")).isNull();
result = notification.setIssue(issue.setCurrentChange(new FieldDiffs().setDiff("assignee", "john", "")));
assertThat(result.getFieldValue("old.assignee")).isEqualTo("john");
assertThat(result.getFieldValue("new.assignee")).isNull();
}
Aggregations