use of org.jboss.pnc.spi.datastore.repositories.api.SortInfo in project pnc by project-ncl.
the class SortInfoTest method shouldCreateProperComparatorAndSortWithTwoDimensions.
@Test
public void shouldCreateProperComparatorAndSortWithTwoDimensions() throws Exception {
// given
String sorting = "=asc=(field1,field2)";
List<SortTester> tester = new ArrayList<>();
tester.add(new SortTester("a", "b"));
tester.add(new SortTester("a", "a"));
// when
SortInfo testedSorting = defaultSortInfoProducer.getSortInfo(sorting);
List<String> sorted = tester.stream().sorted(testedSorting.getComparator()).map(SortTester::getField2).collect(Collectors.toList());
// then
assertThat(sorted).containsExactly("a", "b");
}
use of org.jboss.pnc.spi.datastore.repositories.api.SortInfo in project pnc by project-ncl.
the class SortInfoTest method shouldParseSimpleAscendingRSQL.
@Test
public void shouldParseSimpleAscendingRSQL() throws Exception {
// given
String sorting = "sort=asc=id";
// when
SortInfo testedSorting = defaultSortInfoProducer.getSortInfo(sorting);
// then
assertThat(testedSorting.getFields()).containsExactly("id");
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 shouldAllowSortingStringWithoutSortAtTheBeginning.
@Test
public void shouldAllowSortingStringWithoutSortAtTheBeginning() throws Exception {
// given
String sorting = "=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 BuildRecordRepositoryImpl method getAnyLatestSuccessfulBuildRecordWithRevision.
@Override
public BuildRecord getAnyLatestSuccessfulBuildRecordWithRevision(IdRev idRev, boolean temporaryBuild) {
PageInfo pageInfo = new DefaultPageInfo(0, 1);
SortInfo sortInfo = new DefaultSortInfo(SortInfo.SortingDirection.DESC, BuildRecord_.submitTime.getName());
List<BuildRecord> buildRecords = queryWithPredicates(pageInfo, sortInfo, withBuildConfigurationIdRev(idRev), withSuccess(), includeTemporary(temporaryBuild));
if (buildRecords.size() == 0) {
return null;
} else {
return buildRecords.get(0);
}
}
use of org.jboss.pnc.spi.datastore.repositories.api.SortInfo in project pnc by project-ncl.
the class BuildRecordRepositoryImpl method getLatestSuccessfulBuildRecord.
@Override
public BuildRecord getLatestSuccessfulBuildRecord(IdRev idRev, boolean temporaryBuild) {
PageInfo pageInfo = new DefaultPageInfo(0, 1);
SortInfo sortInfo = new DefaultSortInfo(SortInfo.SortingDirection.DESC, BuildRecord_.id.getName());
List<BuildRecord> buildRecords = queryWithPredicates(pageInfo, sortInfo, withBuildConfigurationIdRev(idRev), withSuccess(), includeTemporary(idRev, temporaryBuild));
if (buildRecords.size() == 0) {
return null;
} else {
return buildRecords.get(0);
}
}
Aggregations