use of com.yahoo.elide.core.Path in project elide by yahoo.
the class HasMemberJPQLGenerator method getInnerQueryIdField.
private String getInnerQueryIdField(Path path) {
Path.PathElement firstElement = path.getPathElements().get(0);
Path firstElementPath = new Path(Arrays.asList(firstElement));
Type<?> modelType = firstElement.getType();
String idField = dictionary.getIdFieldName(modelType);
return INNER + getPathAlias(firstElementPath, dictionary) + "." + idField;
}
use of com.yahoo.elide.core.Path in project elide by yahoo.
the class InMemoryStoreTransactionTest method testFilterPredicateInMemoryOnComplexAttribute.
@Test
public void testFilterPredicateInMemoryOnComplexAttribute() {
FilterExpression expression = new InPredicate(new Path(Author.class, dictionary, "homeAddress.street1"), "Foo");
EntityProjection projection = EntityProjection.builder().type(Author.class).filterExpression(expression).build();
DataStoreIterable filterInMemory = new DataStoreIterableBuilder(Arrays.asList(author1, author2)).filterInMemory(true).build();
when(wrappedTransaction.loadObjects(any(), eq(scope))).thenReturn(filterInMemory);
Collection<Object> loaded = ImmutableList.copyOf(inMemoryStoreTransaction.loadObjects(projection, scope));
assertEquals(1, loaded.size());
assertTrue(loaded.contains(author1));
}
use of com.yahoo.elide.core.Path in project elide by yahoo.
the class InMemoryStoreTransactionTest method testDataStoreRequiresTotalInMemoryFilter.
@Test
public void testDataStoreRequiresTotalInMemoryFilter() {
FilterExpression expression = new InPredicate(new Path(Book.class, dictionary, "genre"), "Literary Fiction");
EntityProjection projection = EntityProjection.builder().type(Book.class).filterExpression(expression).build();
DataStoreIterable filterInMemory = new DataStoreIterableBuilder(books).filterInMemory(true).build();
when(wrappedTransaction.loadObjects(any(), eq(scope))).thenReturn(filterInMemory);
Collection<Object> loaded = ImmutableList.copyOf(inMemoryStoreTransaction.loadObjects(projection, scope));
verify(wrappedTransaction, times(1)).loadObjects(any(EntityProjection.class), eq(scope));
assertEquals(2, loaded.size());
assertTrue(loaded.contains(book1));
assertTrue(loaded.contains(book3));
}
use of com.yahoo.elide.core.Path in project elide by yahoo.
the class InMemoryStoreTransactionTest method testFilteringRequiresInMemorySorting.
@Test
public void testFilteringRequiresInMemorySorting() {
FilterExpression expression = new InPredicate(new Path(Book.class, dictionary, "genre"), "Literary Fiction");
Map<String, Sorting.SortOrder> sortOrder = new HashMap<>();
sortOrder.put("title", Sorting.SortOrder.desc);
Sorting sorting = new SortingImpl(sortOrder, Book.class, dictionary);
EntityProjection projection = EntityProjection.builder().type(Book.class).filterExpression(expression).sorting(sorting).build();
DataStoreIterable filterInMemory = new DataStoreIterableBuilder(books).filterInMemory(true).build();
when(wrappedTransaction.loadObjects(any(), eq(scope))).thenReturn(filterInMemory);
Collection<Object> loaded = Lists.newArrayList(inMemoryStoreTransaction.loadObjects(projection, scope));
verify(wrappedTransaction, times(1)).loadObjects(any(EntityProjection.class), eq(scope));
assertEquals(2, loaded.size());
List<String> bookTitles = loaded.stream().map((o) -> ((Book) o).getTitle()).collect(Collectors.toList());
assertEquals(Lists.newArrayList("Book 3", "Book 1"), bookTitles);
}
use of com.yahoo.elide.core.Path in project elide by yahoo.
the class InMemoryStoreTransactionTest method testFullFilterPredicatePushDown.
@Test
public void testFullFilterPredicatePushDown() {
FilterExpression expression = new InPredicate(new Path(Book.class, dictionary, "genre"), "Literary Fiction");
EntityProjection projection = EntityProjection.builder().type(Book.class).filterExpression(expression).build();
DataStoreIterable expected = new DataStoreIterableBuilder<>(books).build();
when(wrappedTransaction.loadObjects(eq(projection), eq(scope))).thenReturn(expected);
DataStoreIterable actual = inMemoryStoreTransaction.loadObjects(projection, scope);
assertEquals(expected, actual);
verify(wrappedTransaction, times(1)).loadObjects(eq(projection), eq(scope));
}
Aggregations