use of com.yahoo.elide.core.datastore.DataStoreTransaction in project elide by yahoo.
the class DataStoreLoadTest method testContainsPredicate.
@Test
public void testContainsPredicate() throws Exception {
DataStoreTransaction testTransaction = searchStore.beginReadTransaction();
// Case insensitive query against case insensitive index
FilterExpression filter = filterParser.parseFilterExpression("name=ini=*DrU*", ClassType.of(Item.class), false);
Iterable<Object> loaded = testTransaction.loadObjects(EntityProjection.builder().type(Item.class).filterExpression(filter).build(), mockScope);
assertListContains(loaded, Lists.newArrayList(1L, 3L));
verify(wrappedTransaction, never()).loadObjects(any(), any());
}
use of com.yahoo.elide.core.datastore.DataStoreTransaction in project elide by yahoo.
the class DataStoreLoadTest method testPredicateConjunction.
@Test
public void testPredicateConjunction() throws Exception {
DataStoreTransaction testTransaction = searchStore.beginReadTransaction();
FilterExpression filter = filterParser.parseFilterExpression("name==drum*;description==brass*", ClassType.of(Item.class), false);
Iterable<Object> loaded = testTransaction.loadObjects(EntityProjection.builder().type(Item.class).filterExpression(filter).build(), mockScope);
assertListContains(loaded, Lists.newArrayList(1L));
verify(wrappedTransaction, never()).loadObjects(any(), any());
}
use of com.yahoo.elide.core.datastore.DataStoreTransaction in project elide by yahoo.
the class DataStoreLoadTest method testPaginationPageTwo.
@Test
public void testPaginationPageTwo() 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, 1, 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(5L));
assertEquals(pagination.getPageTotals(), 3);
verify(wrappedTransaction, never()).loadObjects(any(), any());
}
use of com.yahoo.elide.core.datastore.DataStoreTransaction in project elide by yahoo.
the class DataStoreLoadTest method testEmptyResult.
@Test
public void testEmptyResult() throws Exception {
DataStoreTransaction testTransaction = searchStore.beginReadTransaction();
FilterExpression filter = filterParser.parseFilterExpression("name==+lucen*", ClassType.of(Item.class), false);
Iterable<Object> loaded = testTransaction.loadObjects(EntityProjection.builder().type(Item.class).filterExpression(filter).build(), mockScope);
assertListContains(loaded, Lists.newArrayList());
verify(wrappedTransaction, never()).loadObjects(any(), any());
}
use of com.yahoo.elide.core.datastore.DataStoreTransaction in project elide by yahoo.
the class DataStoreLoadTest method testEqualityPredicate.
@Test
public void testEqualityPredicate() throws Exception {
DataStoreTransaction testTransaction = searchStore.beginReadTransaction();
// Case sensitive query against case insensitive index must lowercase
FilterExpression filter = filterParser.parseFilterExpression("name==drum", ClassType.of(Item.class), false);
Iterable<Object> loaded = testTransaction.loadObjects(EntityProjection.builder().type(Item.class).filterExpression(filter).build(), mockScope);
assertNull(loaded);
/* This query should hit the underlying store */
verify(wrappedTransaction, times(1)).loadObjects(any(), any());
}
Aggregations