use of org.jboss.pnc.spi.datastore.repositories.api.SortInfo in project pnc by project-ncl.
the class SortInfoTest method shouldParseSimpleDescendingRSQL.
@Test
public void shouldParseSimpleDescendingRSQL() throws Exception {
// given
String sorting = "sort=desc=id";
// when
SortInfo testedSorting = defaultSortInfoProducer.getSortInfo(sorting);
// then
assertThat(testedSorting.getFields()).containsExactly("id");
assertThat(testedSorting.getDirection()).isEqualTo(SortInfo.SortingDirection.DESC);
}
use of org.jboss.pnc.spi.datastore.repositories.api.SortInfo in project pnc by project-ncl.
the class SortInfoTest method shouldParseComplicatedAscendingRSQL.
@Test
public void shouldParseComplicatedAscendingRSQL() throws Exception {
// given
String sorting = "sort=asc=(id,name)";
// when
SortInfo testedSorting = defaultSortInfoProducer.getSortInfo(sorting);
// then
assertThat(testedSorting.getFields()).containsExactly("id", "name");
assertThat(testedSorting.getDirection()).isEqualTo(SortInfo.SortingDirection.ASC);
}
use of org.jboss.pnc.spi.datastore.repositories.api.SortInfo in project pnc by project-ncl.
the class SortInfoTest method shouldCreateProperComparatorAndSortDescending.
@Test
public void shouldCreateProperComparatorAndSortDescending() throws Exception {
// given
String sorting = "=desc=(field1)";
List<SortTester> tester = new ArrayList<>();
tester.add(new SortTester("a", "b"));
tester.add(new SortTester("b", "a"));
// when
SortInfo testedSorting = defaultSortInfoProducer.getSortInfo(sorting);
List<String> sorted = tester.stream().sorted(testedSorting.getComparator()).map(SortTester::getField1).collect(Collectors.toList());
// then
assertThat(sorted).containsExactly("b", "a");
}
use of org.jboss.pnc.spi.datastore.repositories.api.SortInfo in project pnc by project-ncl.
the class SortInfoTest method shouldParseComplicatedDescendingRSQL.
@Test
public void shouldParseComplicatedDescendingRSQL() throws Exception {
// given
String sorting = "sort=desc=(id,name)";
// when
SortInfo testedSorting = defaultSortInfoProducer.getSortInfo(sorting);
// then
assertThat(testedSorting.getFields()).containsExactly("id", "name");
assertThat(testedSorting.getDirection()).isEqualTo(SortInfo.SortingDirection.DESC);
}
use of org.jboss.pnc.spi.datastore.repositories.api.SortInfo in project pnc by project-ncl.
the class SortInfoTest method shouldCreateProperComparator.
@Test
public void shouldCreateProperComparator() throws Exception {
// given
String sorting = "=asc=(field1)";
List<SortTester> tester = new ArrayList<>();
tester.add(new SortTester("b", "b"));
tester.add(new SortTester("a", "b"));
// when
SortInfo testedSorting = defaultSortInfoProducer.getSortInfo(sorting);
List<String> sorted = tester.stream().sorted(testedSorting.getComparator()).map(SortTester::getField1).collect(Collectors.toList());
// then
assertThat(sorted).containsExactly("a", "b");
}
Aggregations