use of org.sonar.core.issue.FieldDiffs in project sonarqube by SonarSource.
the class ChangelogActionTest method return_changelog_not_having_user.
@Test
public void return_changelog_not_having_user() throws Exception {
IssueDto issueDto = db.issues().insertIssue(newIssue());
userSession.logIn("john").addProjectUuidPermissions(USER, issueDto.getProjectUuid());
db.issues().insertFieldDiffs(issueDto, new FieldDiffs().setUserLogin(null).setDiff("severity", "MAJOR", "BLOCKER"));
ChangelogWsResponse result = call(issueDto.getKey());
assertThat(result.getChangelogList()).hasSize(1);
assertThat(result.getChangelogList().get(0).hasUser()).isFalse();
assertThat(result.getChangelogList().get(0).hasUserName()).isFalse();
assertThat(result.getChangelogList().get(0).hasEmail()).isFalse();
assertThat(result.getChangelogList().get(0).getDiffsList()).isNotEmpty();
}
use of org.sonar.core.issue.FieldDiffs in project sonarqube by SonarSource.
the class ChangelogActionTest method return_changelog_on_none_existing_user.
@Test
public void return_changelog_on_none_existing_user() throws Exception {
IssueDto issueDto = db.issues().insertIssue(newIssue());
userSession.logIn("john").addProjectUuidPermissions(USER, issueDto.getProjectUuid());
db.issues().insertFieldDiffs(issueDto, new FieldDiffs().setUserLogin("UNKNOWN").setDiff("severity", "MAJOR", "BLOCKER"));
ChangelogWsResponse result = call(issueDto.getKey());
assertThat(result.getChangelogList()).hasSize(1);
assertThat(result.getChangelogList().get(0).hasUser()).isFalse();
assertThat(result.getChangelogList().get(0).hasUserName()).isFalse();
assertThat(result.getChangelogList().get(0).hasEmail()).isFalse();
assertThat(result.getChangelogList().get(0).getDiffsList()).isNotEmpty();
}
use of org.sonar.core.issue.FieldDiffs in project sonarqube by SonarSource.
the class SetSeverityActionTest method insert_entry_in_changelog_when_setting_severity.
@Test
public void insert_entry_in_changelog_when_setting_severity() throws Exception {
IssueDto issueDto = issueDbTester.insertIssue(newIssue().setSeverity(MAJOR));
setUserWithBrowseAndAdministerIssuePermission(issueDto.getProjectUuid());
call(issueDto.getKey(), MINOR);
List<FieldDiffs> fieldDiffs = dbClient.issueChangeDao().selectChangelogByIssue(dbTester.getSession(), issueDto.getKey());
assertThat(fieldDiffs).hasSize(1);
assertThat(fieldDiffs.get(0).diffs()).hasSize(1);
assertThat(fieldDiffs.get(0).diffs().get("severity").newValue()).isEqualTo(MINOR);
assertThat(fieldDiffs.get(0).diffs().get("severity").oldValue()).isEqualTo(MAJOR);
}
use of org.sonar.core.issue.FieldDiffs in project sonarqube by SonarSource.
the class SetTypeActionTest method insert_entry_in_changelog_when_setting_type.
@Test
public void insert_entry_in_changelog_when_setting_type() throws Exception {
IssueDto issueDto = issueDbTester.insertIssue(newIssue().setType(CODE_SMELL));
setUserWithBrowseAndAdministerIssuePermission(issueDto.getProjectUuid());
call(issueDto.getKey(), BUG.name());
List<FieldDiffs> fieldDiffs = dbClient.issueChangeDao().selectChangelogByIssue(dbTester.getSession(), issueDto.getKey());
assertThat(fieldDiffs).hasSize(1);
assertThat(fieldDiffs.get(0).diffs()).hasSize(1);
assertThat(fieldDiffs.get(0).diffs().get("type").newValue()).isEqualTo(BUG.name());
assertThat(fieldDiffs.get(0).diffs().get("type").oldValue()).isEqualTo(CODE_SMELL.name());
}
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