Search in sources :

Example 11 with IssueQuery

use of org.sonar.server.issue.index.IssueQuery in project sonarqube by SonarSource.

the class IssuesFinderSortTest method should_sort_by_severity.

@Test
public void should_sort_by_severity() {
    IssueDto issue1 = new IssueDto().setKee("A").setSeverity("INFO");
    IssueDto issue2 = new IssueDto().setKee("B").setSeverity("BLOCKER");
    IssueDto issue3 = new IssueDto().setKee("C").setSeverity("MAJOR");
    List<IssueDto> dtoList = newArrayList(issue1, issue2, issue3);
    IssueQuery query = IssueQuery.builder().sort(IssueQuery.SORT_BY_SEVERITY).asc(true).build();
    IssuesFinderSort issuesFinderSort = new IssuesFinderSort(dtoList, query);
    List<IssueDto> result = newArrayList(issuesFinderSort.sort());
    assertThat(result).hasSize(3);
    assertThat(result.get(0).getSeverity()).isEqualTo("INFO");
    assertThat(result.get(1).getSeverity()).isEqualTo("MAJOR");
    assertThat(result.get(2).getSeverity()).isEqualTo("BLOCKER");
}
Also used : IssueDto(org.sonar.db.issue.IssueDto) IssueQuery(org.sonar.server.issue.index.IssueQuery) Test(org.junit.Test)

Aggregations

IssueQuery (org.sonar.server.issue.index.IssueQuery)11 Test (org.junit.Test)8 IssueDto (org.sonar.db.issue.IssueDto)7 Date (java.util.Date)3 SearchOptions (org.sonar.server.es.SearchOptions)2 Collections (java.util.Collections)1 Map (java.util.Map)1 SearchResponse (org.elasticsearch.action.search.SearchResponse)1 Paging (org.sonar.api.utils.Paging)1 JsonWriter (org.sonar.api.utils.text.JsonWriter)1 Facets (org.sonar.server.es.Facets)1 SearchRequest (org.sonar.server.issue.SearchRequest)1