use of org.elasticsearch.search.sort.SortBuilder in project sonarqube by SonarSource.
the class SortingTest method ascending_sort_on_single_field_with_missing_in_last_position.
@Test
public void ascending_sort_on_single_field_with_missing_in_last_position() throws Exception {
Sorting sorting = new Sorting();
sorting.add("updatedAt").missingLast();
SearchRequestBuilder request = new SearchRequestBuilder(mock(Client.class), SearchAction.INSTANCE);
sorting.fill(request, "updatedAt", true);
List<SortBuilder> fields = fields(request);
assertThat(fields).hasSize(1);
expectField(fields.get(0), "updatedAt", "_last", SortOrder.ASC);
}
use of org.elasticsearch.search.sort.SortBuilder in project sonarqube by SonarSource.
the class SortingTest method default_sorting.
@Test
public void default_sorting() throws Exception {
Sorting sorting = new Sorting();
sorting.addDefault("file");
SearchRequestBuilder request = new SearchRequestBuilder(mock(Client.class), SearchAction.INSTANCE);
sorting.fillDefault(request);
List<SortBuilder> fields = fields(request);
assertThat(fields).hasSize(1);
}
use of org.elasticsearch.search.sort.SortBuilder in project sonarqube by SonarSource.
the class SortingTest method ascending_sort_on_single_field.
@Test
public void ascending_sort_on_single_field() throws Exception {
Sorting sorting = new Sorting();
sorting.add("updatedAt");
SearchRequestBuilder request = new SearchRequestBuilder(mock(Client.class), SearchAction.INSTANCE);
sorting.fill(request, "updatedAt", true);
List<SortBuilder> fields = fields(request);
assertThat(fields).hasSize(1);
expectField(fields.get(0), "updatedAt", "_first", SortOrder.ASC);
}
use of org.elasticsearch.search.sort.SortBuilder in project sonarqube by SonarSource.
the class SortingTest method sort_on_multiple_fields.
@Test
public void sort_on_multiple_fields() throws Exception {
// asc => file asc, line asc, severity desc, key asc
Sorting sorting = new Sorting();
sorting.add("fileLine", "file");
sorting.add("fileLine", "line");
sorting.add("fileLine", "severity").reverse();
sorting.add("fileLine", "key").missingLast();
SearchRequestBuilder request = new SearchRequestBuilder(mock(Client.class), SearchAction.INSTANCE);
sorting.fill(request, "fileLine", true);
List<SortBuilder> fields = fields(request);
assertThat(fields).hasSize(4);
expectField(fields.get(0), "file", "_first", SortOrder.ASC);
expectField(fields.get(1), "line", "_first", SortOrder.ASC);
expectField(fields.get(2), "severity", "_first", SortOrder.DESC);
expectField(fields.get(3), "key", "_last", SortOrder.ASC);
}
Aggregations