use of org.sonar.db.issue.IssueDto in project sonarqube by SonarSource.
the class IssuesFinderSortTest method should_sort_by_status.
@Test
public void should_sort_by_status() {
IssueDto issue1 = new IssueDto().setId(1L).setStatus("CLOSED");
IssueDto issue2 = new IssueDto().setId(2L).setStatus("REOPENED");
IssueDto issue3 = new IssueDto().setId(3L).setStatus("OPEN");
List<IssueDto> dtoList = newArrayList(issue1, issue2, issue3);
IssueQuery query = IssueQuery.builder().sort(IssueQuery.SORT_BY_STATUS).asc(false).build();
IssuesFinderSort issuesFinderSort = new IssuesFinderSort(dtoList, query);
List<IssueDto> result = newArrayList(issuesFinderSort.sort());
assertThat(result).hasSize(3);
assertThat(result.get(0).getStatus()).isEqualTo("REOPENED");
assertThat(result.get(1).getStatus()).isEqualTo("OPEN");
assertThat(result.get(2).getStatus()).isEqualTo("CLOSED");
}
use of org.sonar.db.issue.IssueDto in project sonarqube by SonarSource.
the class IssuesFinderSortTest method should_sort_by_update_date.
@Test
public void should_sort_by_update_date() {
Date date = new Date();
Date date1 = DateUtils.addDays(date, -3);
Date date2 = DateUtils.addDays(date, -2);
Date date3 = DateUtils.addDays(date, -1);
IssueDto issue1 = new IssueDto().setId(1L).setIssueUpdateDate(date1);
IssueDto issue2 = new IssueDto().setId(2L).setIssueUpdateDate(date3);
IssueDto issue3 = new IssueDto().setId(3L).setIssueUpdateDate(date2);
List<IssueDto> dtoList = newArrayList(issue1, issue2, issue3);
IssueQuery query = IssueQuery.builder().sort(IssueQuery.SORT_BY_UPDATE_DATE).asc(false).build();
IssuesFinderSort issuesFinderSort = new IssuesFinderSort(dtoList, query);
List<IssueDto> result = newArrayList(issuesFinderSort.sort());
assertThat(result).hasSize(3);
assertThat(result.get(0).getIssueUpdateDate()).isEqualTo(date3);
assertThat(result.get(1).getIssueUpdateDate()).isEqualTo(date2);
assertThat(result.get(2).getIssueUpdateDate()).isEqualTo(date1);
}
use of org.sonar.db.issue.IssueDto in project sonarqube by SonarSource.
the class IssuesFinderSortTest method should_sort_by_desc_severity.
@Test
public void should_sort_by_desc_severity() {
IssueDto issue1 = new IssueDto().setId(1L).setSeverity("INFO");
IssueDto issue2 = new IssueDto().setId(2L).setSeverity("BLOCKER");
IssueDto issue3 = new IssueDto().setId(3L).setSeverity("MAJOR");
List<IssueDto> dtoList = newArrayList(issue1, issue2, issue3);
IssueQuery query = IssueQuery.builder().sort(IssueQuery.SORT_BY_SEVERITY).asc(false).build();
IssuesFinderSort issuesFinderSort = new IssuesFinderSort(dtoList, query);
List<IssueDto> result = newArrayList(issuesFinderSort.sort());
assertThat(result).hasSize(3);
assertThat(result.get(0).getSeverity()).isEqualTo("BLOCKER");
assertThat(result.get(1).getSeverity()).isEqualTo("MAJOR");
assertThat(result.get(2).getSeverity()).isEqualTo("INFO");
}
use of org.sonar.db.issue.IssueDto in project sonarqube by SonarSource.
the class IssueFinderTest method get_by_issue_key.
@Test
public void get_by_issue_key() throws Exception {
IssueDto issueDto = insertIssue();
userSession.addProjectUuidPermissions(USER, issueDto.getProjectUuid());
IssueDto result = underTest.getByKey(db.getSession(), issueDto.getKey());
assertThat(result).isNotNull();
assertThat(result.getKey()).isEqualTo(issueDto.getKey());
}
use of org.sonar.db.issue.IssueDto in project sonarqube by SonarSource.
the class IssueServiceMediumTest method assign.
@Test
public void assign() {
RuleDto rule = newRule();
ComponentDto project = newProject();
ComponentDto file = newFile(project);
userSessionRule.logIn("john").addProjectUuidPermissions(UserRole.USER, project.uuid());
IssueDto issue = saveIssue(IssueTesting.newDto(rule, file, project));
UserDto user = new UserDto().setLogin("perceval").setName("Perceval");
db.userDao().insert(session, user);
session.commit();
index();
assertThat(getIssueByKey(issue.getKey()).assignee()).isNull();
service.assign(issue.getKey(), user.getLogin());
assertThat(getIssueByKey(issue.getKey()).assignee()).isEqualTo("perceval");
}
Aggregations