use of com.yahoo.elide.core.sort.SortingImpl in project elide by yahoo.
the class DataStoreLoadTest method testSortingDescending.
@Test
public void testSortingDescending() throws Exception {
DataStoreTransaction testTransaction = searchStore.beginReadTransaction();
Map<String, Sorting.SortOrder> sortRules = new HashMap<>();
sortRules.put("name", Sorting.SortOrder.desc);
sortRules.put("modifiedDate", Sorting.SortOrder.asc);
Sorting sorting = new SortingImpl(sortRules, Item.class, dictionary);
FilterExpression filter = filterParser.parseFilterExpression("name==cymbal*", ClassType.of(Item.class), false);
Iterable<Object> loaded = testTransaction.loadObjects(EntityProjection.builder().type(Item.class).filterExpression(filter).sorting(sorting).build(), mockScope);
assertListMatches(loaded, Lists.newArrayList(2L, 5L, 4L));
verify(wrappedTransaction, never()).loadObjects(any(), any());
}
use of com.yahoo.elide.core.sort.SortingImpl in project elide by yahoo.
the class DataStoreLoadTest method testPaginationPageOne.
@Test
public void testPaginationPageOne() throws Exception {
DataStoreTransaction testTransaction = searchStore.beginReadTransaction();
Map<String, Sorting.SortOrder> sortRules = new HashMap<>();
sortRules.put("name", Sorting.SortOrder.desc);
sortRules.put("modifiedDate", Sorting.SortOrder.asc);
Sorting sorting = new SortingImpl(sortRules, Item.class, dictionary);
PaginationImpl pagination = new PaginationImpl(Item.class, 0, 1, PaginationImpl.DEFAULT_PAGE_LIMIT, PaginationImpl.MAX_PAGE_LIMIT, true, false);
FilterExpression filter = filterParser.parseFilterExpression("name==cymbal*", ClassType.of(Item.class), false);
Iterable<Object> loaded = testTransaction.loadObjects(EntityProjection.builder().type(Item.class).filterExpression(filter).sorting(sorting).pagination(pagination).build(), mockScope);
assertListMatches(loaded, Lists.newArrayList(2L));
assertEquals(pagination.getPageTotals(), 3);
verify(wrappedTransaction, never()).loadObjects(any(), any());
}
use of com.yahoo.elide.core.sort.SortingImpl in project elide by yahoo.
the class DataStoreLoadTest method testSortingAscending.
@Test
public void testSortingAscending() throws Exception {
DataStoreTransaction testTransaction = searchStore.beginReadTransaction();
Map<String, Sorting.SortOrder> sortRules = new HashMap<>();
sortRules.put("name", Sorting.SortOrder.asc);
sortRules.put("modifiedDate", Sorting.SortOrder.desc);
Sorting sorting = new SortingImpl(sortRules, Item.class, dictionary);
FilterExpression filter = filterParser.parseFilterExpression("name==cymbal*", ClassType.of(Item.class), false);
Iterable<Object> loaded = testTransaction.loadObjects(EntityProjection.builder().type(Item.class).filterExpression(filter).sorting(sorting).build(), mockScope);
assertListContains(loaded, Lists.newArrayList(4L, 5L, 2L));
verify(wrappedTransaction, never()).loadObjects(any(), any());
}
Aggregations