use of com.yahoo.elide.core.Path in project elide by yahoo.
the class InMemoryExecutionVerifierTest method testFullInMemoryExecution.
@Test
public void testFullInMemoryExecution() {
FilterExpression dataStoreExpression = new InPredicate(new Path(Book.class, dictionary, "genre"), "Literary Fiction");
FilterExpression inMemoryExpression = new InPredicate(new Path(Book.class, dictionary, "editor.firstName"), "Literary Fiction");
FilterExpression finalExpression = new NotFilterExpression(new AndFilterExpression(dataStoreExpression, inMemoryExpression));
assertTrue(InMemoryExecutionVerifier.shouldExecuteInMemory(dictionary, finalExpression));
}
use of com.yahoo.elide.core.Path in project elide by yahoo.
the class InMemoryExecutionVerifierTest method testNoInMemoryExecution.
@Test
public void testNoInMemoryExecution() {
FilterExpression expression = new InPredicate(new Path(Book.class, dictionary, "genre"), "Literary Fiction");
assertFalse(InMemoryExecutionVerifier.shouldExecuteInMemory(dictionary, expression));
}
use of com.yahoo.elide.core.Path in project elide by yahoo.
the class InMemoryExecutionVerifierTest method testPartialInMemoryExecution.
@Test
public void testPartialInMemoryExecution() {
FilterExpression dataStoreExpression = new InPredicate(new Path(Book.class, dictionary, "genre"), "Literary Fiction");
FilterExpression inMemoryExpression = new InPredicate(new Path(Book.class, dictionary, "editor.firstName"), "Literary Fiction");
FilterExpression finalExpression = new NotFilterExpression(new OrFilterExpression(dataStoreExpression, inMemoryExpression));
assertTrue(InMemoryExecutionVerifier.shouldExecuteInMemory(dictionary, finalExpression));
}
use of com.yahoo.elide.core.Path in project elide by yahoo.
the class EntityProjectionMakerTest method testRootCollectionWithTypedFilter.
@Test
public void testRootCollectionWithTypedFilter() {
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<>();
queryParams.add("filter[book]", "genre=='Science Fiction'");
String path = "/book";
RequestScope scope = new TestRequestScope(dictionary, path, queryParams);
FilterExpression expression = new InPredicate(new Path(Book.class, dictionary, "genre"), "Science Fiction");
EntityProjectionMaker maker = new EntityProjectionMaker(dictionary, scope);
EntityProjection expected = EntityProjection.builder().type(Book.class).attribute(Attribute.builder().name("title").type(String.class).build()).attribute(Attribute.builder().name("awards").type(Collection.class).build()).attribute(Attribute.builder().name("genre").type(String.class).build()).attribute(Attribute.builder().name("language").type(String.class).build()).attribute(Attribute.builder().name("publishDate").type(long.class).build()).attribute(Attribute.builder().name("authorTypes").type(Collection.class).build()).attribute(Attribute.builder().name("price").type(Price.class).build()).filterExpression(expression).relationship("authors", EntityProjection.builder().type(Author.class).build()).relationship("publisher", EntityProjection.builder().type(Publisher.class).build()).relationship("editor", EntityProjection.builder().type(Editor.class).build()).pagination(PaginationImpl.getDefaultPagination(ClassType.of(Book.class))).build();
EntityProjection actual = maker.parsePath(path);
projectionEquals(expected, actual);
}
use of com.yahoo.elide.core.Path in project elide by yahoo.
the class EntityProjectionMakerTest method testNestedCollectionWithTypedFilter.
@Test
public void testNestedCollectionWithTypedFilter() {
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<>();
queryParams.add("filter[publisher]", "name=='Foo'");
String path = "/author/1/books/3/publisher";
FilterExpression expression = new InPredicate(new Path(Publisher.class, dictionary, "name"), "Foo");
RequestScope scope = new TestRequestScope(dictionary, path, queryParams);
EntityProjectionMaker maker = new EntityProjectionMaker(dictionary, scope);
EntityProjection expected = EntityProjection.builder().type(Author.class).relationship("books", EntityProjection.builder().type(Book.class).relationship("publisher", EntityProjection.builder().type(Publisher.class).attribute(Attribute.builder().name("name").type(String.class).build()).attribute(Attribute.builder().name("updateHookInvoked").type(boolean.class).build()).filterExpression(expression).relationship("books", EntityProjection.builder().type(Book.class).build()).relationship("editor", EntityProjection.builder().type(Editor.class).build()).pagination(PaginationImpl.getDefaultPagination(ClassType.of(Publisher.class))).build()).build()).build();
EntityProjection actual = maker.parsePath(path);
projectionEquals(expected, actual);
}
Aggregations