use of com.yahoo.elide.core.datastore.DataStoreTransaction 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());
}
use of com.yahoo.elide.core.datastore.DataStoreTransaction in project elide by yahoo.
the class DataStoreSupportsFilteringTest method testPrefixOperator.
@Test
public void testPrefixOperator() throws Exception {
DataStoreTransaction testTransaction = searchStore.beginReadTransaction();
FilterPredicate filter = (FilterPredicate) filterParser.parseFilterExpression("name==drum*", ClassType.of(Item.class), false);
EntityProjection projection = EntityProjection.builder().type(Item.class).filterExpression(filter).build();
DataStoreIterable<Object> loaded = testTransaction.loadObjects(projection, mockScope);
assertTrue(loaded.needsInMemoryFilter());
assertTrue(loaded.needsInMemoryPagination());
assertTrue(loaded.needsInMemorySort());
verify(wrappedTransaction, times(0)).loadObjects(any(), any());
}
use of com.yahoo.elide.core.datastore.DataStoreTransaction in project elide by yahoo.
the class DataStoreSupportsFilteringTest method testNgramTooSmall.
@Test
public void testNgramTooSmall() throws Exception {
DataStoreTransaction testTransaction = searchStore.beginReadTransaction();
FilterPredicate filter = (FilterPredicate) filterParser.parseFilterExpression("description==*ru*", 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.datastore.DataStoreTransaction in project elide by yahoo.
the class MultiplexWriteTransaction method createObject.
@SuppressWarnings("resource")
@Override
public <T> void createObject(T entity, RequestScope scope) {
DataStoreTransaction transaction = getTransaction(EntityDictionary.getType(entity));
transaction.createObject(entity, scope);
// mark this object as newly created to be deleted on reverse transaction
clonedObjects.put(entity, NEWLY_CREATED_OBJECT);
}
use of com.yahoo.elide.core.datastore.DataStoreTransaction in project elide by yahoo.
the class MultiplexWriteTransaction method getToManyRelation.
@Override
public <T, R> DataStoreIterable<R> getToManyRelation(DataStoreTransaction relationTx, T entity, Relationship relationship, RequestScope scope) {
DataStoreTransaction transaction = getTransaction(EntityDictionary.getType(entity));
DataStoreIterable<R> relation = super.getToManyRelation(relationTx, entity, relationship, scope);
return hold(transaction, relation);
}
Aggregations