Search in sources :

Example 56 with FieldDiffs

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

the class ChangelogActionTest method return_many_changelog.

@Test
public void return_many_changelog() {
    UserDto user = insertUser();
    IssueDto issueDto = insertNewIssue();
    userSession.logIn("john").addProjectPermission(USER, project, file);
    db.issues().insertFieldDiffs(issueDto, new FieldDiffs().setUserUuid(user.getUuid()).setDiff("severity", "MAJOR", "BLOCKER").setCreationDate(new Date()), new FieldDiffs().setDiff("status", "RESOLVED", "CLOSED").setCreationDate(new Date()));
    ChangelogWsResponse result = call(issueDto.getKey());
    assertThat(result.getChangelogList()).hasSize(2);
}
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) Date(java.util.Date) Test(org.junit.Test)

Example 57 with FieldDiffs

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

the class ChangelogActionTest method changelog_of_file_move_contains_file_names.

@Test
public void changelog_of_file_move_contains_file_names() {
    RuleDto rule = db.rules().insertRule(newRuleDto());
    ComponentDto project = db.components().insertPrivateProject();
    ComponentDto file1 = db.components().insertComponent(newFileDto(project));
    ComponentDto file2 = db.components().insertComponent(newFileDto(project));
    IssueDto issueDto = db.issues().insertIssue(newDto(rule, file2, project));
    userSession.logIn("john").addProjectPermission(USER, project, file);
    db.issues().insertFieldDiffs(issueDto, new FieldDiffs().setDiff("file", file1.uuid(), file2.uuid()).setCreationDate(new Date()));
    ChangelogWsResponse result = call(issueDto.getKey());
    assertThat(result.getChangelogList()).hasSize(1);
    assertThat(result.getChangelogList().get(0).hasUser()).isFalse();
    assertThat(result.getChangelogList().get(0).getCreationDate()).isNotEmpty();
    assertThat(result.getChangelogList().get(0).getDiffsList()).extracting(Diff::getKey, Diff::getOldValue, Diff::getNewValue).containsOnly(tuple("file", file1.longName(), file2.longName()));
}
Also used : RuleTesting.newRuleDto(org.sonar.db.rule.RuleTesting.newRuleDto) RuleDto(org.sonar.db.rule.RuleDto) ChangelogWsResponse(org.sonarqube.ws.Issues.ChangelogWsResponse) FieldDiffs(org.sonar.core.issue.FieldDiffs) ComponentDto(org.sonar.db.component.ComponentDto) IssueDto(org.sonar.db.issue.IssueDto) Date(java.util.Date) Test(org.junit.Test)

Aggregations

FieldDiffs (org.sonar.core.issue.FieldDiffs)57 Test (org.junit.Test)42 IssueDto (org.sonar.db.issue.IssueDto)31 Date (java.util.Date)25 IssueChangeDto (org.sonar.db.issue.IssueChangeDto)18 UserDto (org.sonar.db.user.UserDto)18 DefaultIssue (org.sonar.core.issue.DefaultIssue)12 FormattingContext (org.sonar.server.issue.IssueChangeWSSupport.FormattingContext)12 ChangelogWsResponse (org.sonarqube.ws.Issues.ChangelogWsResponse)12 ComponentDto (org.sonar.db.component.ComponentDto)11 UserTesting.newUserDto (org.sonar.db.user.UserTesting.newUserDto)9 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)8 DefaultIssueComment (org.sonar.core.issue.DefaultIssueComment)8 ArrayList (java.util.ArrayList)6 Random (java.util.Random)6 Changelog (org.sonarqube.ws.Common.Changelog)6 ImmutableSet (com.google.common.collect.ImmutableSet)5 DataProvider (com.tngtech.java.junit.dataprovider.DataProvider)5 DataProviderRunner (com.tngtech.java.junit.dataprovider.DataProviderRunner)5 Arrays (java.util.Arrays)5