Search in sources :

Example 71 with FilterExpression

use of com.yahoo.elide.core.filter.expression.FilterExpression in project elide by yahoo.

the class DataStoreLoadTest method testPrefixPredicateWithInMemoryFiltering.

@Test
public void testPrefixPredicateWithInMemoryFiltering() throws Exception {
    DataStoreTransaction testTransaction = searchStore.beginReadTransaction();
    testTransaction = new InMemoryStoreTransaction(testTransaction);
    // Case sensitive query against case insensitive index must lowercase
    FilterExpression filter = filterParser.parseFilterExpression("name==dru*", 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());
}
Also used : Item(com.yahoo.elide.datastores.search.models.Item) InMemoryStoreTransaction(com.yahoo.elide.core.datastore.inmemory.InMemoryStoreTransaction) DataStoreTransaction(com.yahoo.elide.core.datastore.DataStoreTransaction) FilterExpression(com.yahoo.elide.core.filter.expression.FilterExpression) Test(org.junit.jupiter.api.Test)

Example 72 with FilterExpression

use of com.yahoo.elide.core.filter.expression.FilterExpression 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());
}
Also used : Item(com.yahoo.elide.datastores.search.models.Item) DataStoreTransaction(com.yahoo.elide.core.datastore.DataStoreTransaction) FilterExpression(com.yahoo.elide.core.filter.expression.FilterExpression) Test(org.junit.jupiter.api.Test)

Example 73 with FilterExpression

use of com.yahoo.elide.core.filter.expression.FilterExpression 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());
}
Also used : Item(com.yahoo.elide.datastores.search.models.Item) DataStoreTransaction(com.yahoo.elide.core.datastore.DataStoreTransaction) FilterExpression(com.yahoo.elide.core.filter.expression.FilterExpression) Test(org.junit.jupiter.api.Test)

Example 74 with FilterExpression

use of com.yahoo.elide.core.filter.expression.FilterExpression 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());
}
Also used : Item(com.yahoo.elide.datastores.search.models.Item) PaginationImpl(com.yahoo.elide.core.pagination.PaginationImpl) HashMap(java.util.HashMap) SortingImpl(com.yahoo.elide.core.sort.SortingImpl) DataStoreTransaction(com.yahoo.elide.core.datastore.DataStoreTransaction) FilterExpression(com.yahoo.elide.core.filter.expression.FilterExpression) Sorting(com.yahoo.elide.core.request.Sorting) Test(org.junit.jupiter.api.Test)

Example 75 with FilterExpression

use of com.yahoo.elide.core.filter.expression.FilterExpression 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());
}
Also used : Item(com.yahoo.elide.datastores.search.models.Item) DataStoreTransaction(com.yahoo.elide.core.datastore.DataStoreTransaction) FilterExpression(com.yahoo.elide.core.filter.expression.FilterExpression) Test(org.junit.jupiter.api.Test)

Aggregations

FilterExpression (com.yahoo.elide.core.filter.expression.FilterExpression)214 Test (org.junit.jupiter.api.Test)161 OrFilterExpression (com.yahoo.elide.core.filter.expression.OrFilterExpression)91 AndFilterExpression (com.yahoo.elide.core.filter.expression.AndFilterExpression)72 MultivaluedHashMap (javax.ws.rs.core.MultivaluedHashMap)49 FilterPredicate (com.yahoo.elide.core.filter.predicates.FilterPredicate)46 Path (com.yahoo.elide.core.Path)44 Query (com.yahoo.elide.datastores.aggregation.query.Query)42 Argument (com.yahoo.elide.core.request.Argument)39 SQLUnitTest (com.yahoo.elide.datastores.aggregation.framework.SQLUnitTest)39 DataStoreTransaction (com.yahoo.elide.core.datastore.DataStoreTransaction)34 SQLTable (com.yahoo.elide.datastores.aggregation.queryengines.sql.metadata.SQLTable)34 HashMap (java.util.HashMap)29 Book (example.Book)28 NotFilterExpression (com.yahoo.elide.core.filter.expression.NotFilterExpression)24 EntityProjection (com.yahoo.elide.core.request.EntityProjection)22 Date (java.util.Date)21 EntityDictionary (com.yahoo.elide.core.dictionary.EntityDictionary)20 Day (com.yahoo.elide.datastores.aggregation.timegrains.Day)19 HashSet (java.util.HashSet)18