use of org.sonarqube.ws.Issues.ChangelogWsResponse in project sonarqube by SonarSource.
the class ChangelogAction method handle.
@Override
public void handle(Request request, Response response) throws Exception {
try (DbSession dbSession = dbClient.openSession(false)) {
ChangelogWsResponse wsResponse = Stream.of(request).map(searchChangelog(dbSession)).map(buildResponse()).collect(Collectors.toOneElement());
writeProtobuf(wsResponse, request, response);
}
}
use of org.sonarqube.ws.Issues.ChangelogWsResponse 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));
}
use of org.sonarqube.ws.Issues.ChangelogWsResponse 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"));
}
use of org.sonarqube.ws.Issues.ChangelogWsResponse 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();
}
use of org.sonarqube.ws.Issues.ChangelogWsResponse 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();
}
Aggregations