Search in sources :

Example 21 with FieldDiffs

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

the class ChangelogActionTest method return_changelog.

@Test
public void return_changelog() 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"));
    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).getEmail()).isNotNull().isEqualTo(user.getEmail());
    assertThat(result.getChangelogList().get(0).getCreationDate()).isNotEmpty();
    assertThat(result.getChangelogList().get(0).getDiffsList()).extracting(Diff::getKey, Diff::getOldValue, Diff::getNewValue).containsOnly(tuple("severity", "MAJOR", "BLOCKER"));
}
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 22 with FieldDiffs

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

the class ChangelogActionTest method test_example.

@Test
public void test_example() throws Exception {
    UserDto user = db.users().insertUser(newUserDto("john.smith", "John Smith", "john@smith.com"));
    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").setCreationDate(DateUtils.parseDateTime("2014-03-04T23:03:44+0100")));
    String result = tester.newRequest().setParam("issue", issueDto.getKey()).execute().getInput();
    assertJson(result).isSimilarTo(getClass().getResource("changelog-example.json"));
}
Also used : 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 23 with FieldDiffs

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

the class IssueChangeDtoTest method to_field_diffs_with_create_at.

@Test
public void to_field_diffs_with_create_at() {
    IssueChangeDto changeDto = new IssueChangeDto().setKey("EFGH").setUserLogin("emmerik").setChangeData("Some text").setIssueKey("ABCDE").setCreatedAt(System2.INSTANCE.now());
    FieldDiffs diffs = changeDto.toFieldDiffs();
    assertThat(diffs.userLogin()).isEqualTo("emmerik");
    assertThat(diffs.issueKey()).isEqualTo("ABCDE");
    assertThat(diffs.creationDate()).isNotNull();
}
Also used : FieldDiffs(org.sonar.core.issue.FieldDiffs) Test(org.junit.Test)

Example 24 with FieldDiffs

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");
}
Also used : FieldDiffs(org.sonar.core.issue.FieldDiffs) Test(org.junit.Test)

Example 25 with FieldDiffs

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());
}
Also used : FieldDiffs(org.sonar.core.issue.FieldDiffs) 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