use of com.yahoo.elide.core.request.EntityProjection in project elide by yahoo.
the class DataStoreSupportsFilteringTest method testUnindexedField.
@Test
public void testUnindexedField() throws Exception {
/* The field is not indexed */
DataStoreTransaction testTransaction = searchStore.beginReadTransaction();
FilterExpression filter = filterParser.parseFilterExpression("price==123", ClassType.of(Item.class), false);
EntityProjection projection = EntityProjection.builder().type(Item.class).filterExpression(filter).build();
DataStoreIterable<Object> loaded = testTransaction.loadObjects(projection, mockScope);
// The query was passed to the wrapped transaction which is a mock.
assertNull(loaded);
verify(wrappedTransaction, times(1)).loadObjects(any(), any());
}
use of com.yahoo.elide.core.request.EntityProjection in project elide by yahoo.
the class DataStoreSupportsFilteringTest method testIndexedField.
@Test
public void testIndexedField() throws Exception {
/* The field is indexed using the @Field annotation */
DataStoreTransaction testTransaction = searchStore.beginReadTransaction();
FilterExpression filter = filterParser.parseFilterExpression("description==*rum*", ClassType.of(Item.class), false);
EntityProjection projection = EntityProjection.builder().type(Item.class).filterExpression(filter).build();
DataStoreIterable<Object> loaded = testTransaction.loadObjects(projection, mockScope);
assertFalse(loaded.needsInMemoryFilter());
assertFalse(loaded.needsInMemoryPagination());
assertFalse(loaded.needsInMemorySort());
verify(wrappedTransaction, times(0)).loadObjects(any(), any());
}
use of com.yahoo.elide.core.request.EntityProjection in project elide by yahoo.
the class DataStoreSupportsFilteringTest method testLargeNgramForEqualityOperator.
@Test
public void testLargeNgramForEqualityOperator() throws Exception {
DataStoreTransaction testTransaction = searchStore.beginReadTransaction();
FilterPredicate filter = (FilterPredicate) filterParser.parseFilterExpression("description==abcdefghijk", ClassType.of(Item.class), false);
EntityProjection projection = EntityProjection.builder().type(Item.class).filterExpression(filter).build();
DataStoreIterable<Object> loaded = testTransaction.loadObjects(projection, mockScope);
// The query was passed to the wrapped transaction which is a mock.
assertNull(loaded);
verify(wrappedTransaction, times(1)).loadObjects(any(), any());
}
use of com.yahoo.elide.core.request.EntityProjection in project elide by yahoo.
the class DataStoreSupportsFilteringTest method testNgramTooLarge.
@Test
public void testNgramTooLarge() throws Exception {
DataStoreTransaction testTransaction = searchStore.beginReadTransaction();
FilterPredicate filter = (FilterPredicate) filterParser.parseFilterExpression("description==*abcdefghijk*", ClassType.of(Item.class), false);
EntityProjection projection = EntityProjection.builder().type(Item.class).filterExpression(filter).build();
assertThrows(InvalidValueException.class, () -> testTransaction.loadObjects(projection, mockScope));
}
use of com.yahoo.elide.core.request.EntityProjection in project elide by yahoo.
the class DataStoreSupportsFilteringTest method testInfixOperator.
@Test
public void testInfixOperator() throws Exception {
DataStoreTransaction testTransaction = searchStore.beginReadTransaction();
FilterPredicate filter = (FilterPredicate) filterParser.parseFilterExpression("name==*rum*", ClassType.of(Item.class), false);
EntityProjection projection = EntityProjection.builder().type(Item.class).filterExpression(filter).build();
DataStoreIterable<Object> loaded = testTransaction.loadObjects(projection, mockScope);
assertFalse(loaded.needsInMemoryFilter());
assertFalse(loaded.needsInMemoryPagination());
assertFalse(loaded.needsInMemorySort());
verify(wrappedTransaction, times(0)).loadObjects(any(), any());
}
Aggregations