Search in sources :

Example 6 with FieldDiffs

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

the class IssueChangeNotificationTest method set_issue_with_current_change_having_no_old_value.

@Test
public void set_issue_with_current_change_having_no_old_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("resolution", null, "FIXED")));
    assertThat(result.getFieldValue("old.resolution")).isNull();
    assertThat(result.getFieldValue("new.resolution")).isEqualTo("FIXED");
    result = notification.setIssue(issue.setCurrentChange(new FieldDiffs().setDiff("resolution", "", "FIXED")));
    assertThat(result.getFieldValue("old.resolution")).isNull();
    assertThat(result.getFieldValue("new.resolution")).isEqualTo("FIXED");
}
Also used : FieldDiffs(org.sonar.core.issue.FieldDiffs) DefaultIssue(org.sonar.core.issue.DefaultIssue) Test(org.junit.Test)

Example 7 with FieldDiffs

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

the class IssueChangeNotificationTest method set_issue.

@Test
public void set_issue() {
    DefaultIssue issue = new DefaultIssue().setKey("ABCD").setAssignee("simon").setMessage("Remove this useless method").setComponentKey("MyService").setCurrentChange(new FieldDiffs().setDiff("resolution", "FALSE-POSITIVE", "FIXED"));
    IssueChangeNotification result = notification.setIssue(issue);
    assertThat(result.getFieldValue("key")).isEqualTo("ABCD");
    assertThat(result.getFieldValue("assignee")).isEqualTo("simon");
    assertThat(result.getFieldValue("message")).isEqualTo("Remove this useless method");
    assertThat(result.getFieldValue("componentKey")).isEqualTo("MyService");
    assertThat(result.getFieldValue("old.resolution")).isEqualTo("FALSE-POSITIVE");
    assertThat(result.getFieldValue("new.resolution")).isEqualTo("FIXED");
}
Also used : FieldDiffs(org.sonar.core.issue.FieldDiffs) DefaultIssue(org.sonar.core.issue.DefaultIssue) Test(org.junit.Test)

Example 8 with FieldDiffs

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

the class ChangelogActionTest method changelog_of_file_move_is_empty_when_files_does_not_exists.

@Test
public void changelog_of_file_move_is_empty_when_files_does_not_exists() throws Exception {
    IssueDto issueDto = db.issues().insertIssue(newIssue());
    userSession.logIn("john").addProjectUuidPermissions(USER, issueDto.getProjectUuid());
    db.issues().insertFieldDiffs(issueDto, new FieldDiffs().setDiff("file", "UNKNOWN_1", "UNKNOWN_2"));
    ChangelogWsResponse result = call(issueDto.getKey());
    assertThat(result.getChangelogList()).hasSize(1);
    assertThat(result.getChangelogList().get(0).getDiffsList()).extracting(Diff::getKey, Diff::hasOldValue, Diff::hasNewValue).containsOnly(tuple("file", false, false));
}
Also used : ChangelogWsResponse(org.sonarqube.ws.Issues.ChangelogWsResponse) FieldDiffs(org.sonar.core.issue.FieldDiffs) IssueDto(org.sonar.db.issue.IssueDto) Test(org.junit.Test)

Example 9 with FieldDiffs

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

the class ChangelogActionTest method return_multiple_diffs.

@Test
public void return_multiple_diffs() throws Exception {
    UserDto user = db.users().insertUser();
    IssueDto issueDto = db.issues().insertIssue(newIssue());
    userSession.logIn("john").addProjectUuidPermissions(USER, issueDto.getProjectUuid());
    db.issues().insertFieldDiffs(issueDto, new FieldDiffs().setUserLogin(user.getLogin()).setDiff("severity", "MAJOR", "BLOCKER").setDiff("status", "RESOLVED", "CLOSED"));
    ChangelogWsResponse result = call(issueDto.getKey());
    assertThat(result.getChangelogList()).hasSize(1);
    assertThat(result.getChangelogList().get(0).getDiffsList()).extracting(Diff::getKey, Diff::getOldValue, Diff::getNewValue).containsOnly(tuple("severity", "MAJOR", "BLOCKER"), tuple("status", "RESOLVED", "CLOSED"));
}
Also used : ChangelogWsResponse(org.sonarqube.ws.Issues.ChangelogWsResponse) FieldDiffs(org.sonar.core.issue.FieldDiffs) UserDto(org.sonar.db.user.UserDto) UserTesting.newUserDto(org.sonar.db.user.UserTesting.newUserDto) IssueDto(org.sonar.db.issue.IssueDto) Test(org.junit.Test)

Example 10 with FieldDiffs

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

the class ChangelogActionTest method return_changelog_on_user_without_email.

@Test
public void return_changelog_on_user_without_email() throws Exception {
    UserDto user = db.users().insertUser(UserTesting.newUserDto("john", "John", null));
    IssueDto issueDto = db.issues().insertIssue(newIssue());
    userSession.logIn("john").addProjectUuidPermissions(USER, issueDto.getProjectUuid());
    db.issues().insertFieldDiffs(issueDto, new FieldDiffs().setUserLogin(user.getLogin()).setDiff("severity", "MAJOR", "BLOCKER"));
    ChangelogWsResponse result = call(issueDto.getKey());
    assertThat(result.getChangelogList()).hasSize(1);
    assertThat(result.getChangelogList().get(0).getUser()).isNotNull().isEqualTo(user.getLogin());
    assertThat(result.getChangelogList().get(0).getUserName()).isNotNull().isEqualTo(user.getName());
    assertThat(result.getChangelogList().get(0).hasEmail()).isFalse();
}
Also used : ChangelogWsResponse(org.sonarqube.ws.Issues.ChangelogWsResponse) FieldDiffs(org.sonar.core.issue.FieldDiffs) UserDto(org.sonar.db.user.UserDto) UserTesting.newUserDto(org.sonar.db.user.UserTesting.newUserDto) IssueDto(org.sonar.db.issue.IssueDto) Test(org.junit.Test)

Aggregations

FieldDiffs (org.sonar.core.issue.FieldDiffs)27 Test (org.junit.Test)23 IssueDto (org.sonar.db.issue.IssueDto)14 ChangelogWsResponse (org.sonarqube.ws.Issues.ChangelogWsResponse)11 UserDto (org.sonar.db.user.UserDto)8 UserTesting.newUserDto (org.sonar.db.user.UserTesting.newUserDto)8 DefaultIssue (org.sonar.core.issue.DefaultIssue)4 Map (java.util.Map)2 IssueComment (org.sonar.api.issue.IssueComment)2 DefaultIssueComment (org.sonar.core.issue.DefaultIssueComment)2 IssueChangeDto (org.sonar.db.issue.IssueChangeDto)2 Date (java.util.Date)1 ComponentDto (org.sonar.db.component.ComponentDto)1 RuleDto (org.sonar.db.rule.RuleDto)1 RuleTesting.newRuleDto (org.sonar.db.rule.RuleTesting.newRuleDto)1