use of com.yahoo.elide.datastores.aggregation.query.QueryResult in project elide by yahoo.
the class AggregationDataStoreTransactionTest method loadObjectsUsesCache.
@Test
public void loadObjectsUsesCache() {
Mockito.reset(queryLogger);
String cacheKey = "foo;" + queryKey;
QueryResult queryResult = QueryResult.builder().data(DATA).build();
NativeQuery myQuery = NativeQuery.builder().fromClause(playerStatsTable.getName()).projectionClause(" ").build();
when(cache.get(cacheKey)).thenReturn(queryResult);
when(queryEngine.getTableVersion(playerStatsTable, qeTransaction)).thenReturn("foo");
when(queryEngine.explain(query)).thenReturn(Arrays.asList(myQuery.toString()));
AggregationDataStoreTransaction transaction = new MyAggregationDataStoreTransaction(queryEngine, cache, queryLogger);
EntityProjection entityProjection = EntityProjection.builder().type(PlayerStats.class).build();
assertEquals(DATA, Lists.newArrayList(transaction.loadObjects(entityProjection, scope)));
Mockito.verify(queryEngine, never()).executeQuery(any(), any());
Mockito.verify(cache).get(cacheKey);
Mockito.verifyNoMoreInteractions(cache);
Mockito.verify(queryLogger, times(1)).acceptQuery(Mockito.eq(scope.getRequestId()), any(), any(), any(), any(), any());
Mockito.verify(queryLogger, times(1)).processQuery(Mockito.eq(scope.getRequestId()), any(), any(), Mockito.eq(true));
Mockito.verify(queryLogger, times(1)).completeQuery(Mockito.eq(scope.getRequestId()), any());
}
use of com.yahoo.elide.datastores.aggregation.query.QueryResult in project elide by yahoo.
the class RedisCacheTest method testGetResultsMulti.
@Test
public void testGetResultsMulti() {
String key = "example_PlayerStats;{highScore;{}}{}{};;;;";
Iterable<Object> data = Collections.singletonList("xyzzy");
QueryResult queryResult = QueryResult.builder().data(data).build();
cache.put(key, queryResult);
// retrive results and verify they match original.
assertEquals(queryResult, cache.get(key));
// retrive results again and verify they match original.
assertEquals(queryResult, cache.get(key));
String key1 = "example_PlayerStats1;{highScore;{}}{}{};;;;";
Iterable<Object> data1 = Collections.singletonList("xyzz");
QueryResult queryResult1 = QueryResult.builder().data(data).build();
cache.put(key1, queryResult1);
// retrive results and verify they match original.
assertEquals(queryResult1, cache.get(key1));
}
Aggregations