Search in sources :

Example 1 with QueryService

use of com.gemstone.gemfire.cache.query.QueryService in project zeppelin by apache.

the class GeodeOqlInterpreterTest method testOql.

private void testOql(Iterator<Object> queryResponseIterator, String expectedOutput, int maxResult) throws Exception {
    GeodeOqlInterpreter spyGeodeOqlInterpreter = spy(new GeodeOqlInterpreter(new Properties()));
    QueryService mockQueryService = mock(QueryService.class, RETURNS_DEEP_STUBS);
    when(spyGeodeOqlInterpreter.getQueryService()).thenReturn(mockQueryService);
    when(spyGeodeOqlInterpreter.getMaxResult()).thenReturn(maxResult);
    @SuppressWarnings("unchecked") SelectResults<Object> mockResults = mock(SelectResults.class);
    when(mockQueryService.newQuery(eq(OQL_QUERY)).execute()).thenReturn(mockResults);
    when(mockResults.iterator()).thenReturn(queryResponseIterator);
    InterpreterResult interpreterResult = spyGeodeOqlInterpreter.interpret(OQL_QUERY, null);
    assertEquals(Code.SUCCESS, interpreterResult.code());
    assertEquals(expectedOutput, interpreterResult.message().get(0).getData());
}
Also used : QueryService(com.gemstone.gemfire.cache.query.QueryService) GeodeOqlInterpreter(org.apache.zeppelin.geode.GeodeOqlInterpreter) InterpreterResult(org.apache.zeppelin.interpreter.InterpreterResult) Properties(java.util.Properties)

Aggregations

QueryService (com.gemstone.gemfire.cache.query.QueryService)1 Properties (java.util.Properties)1 GeodeOqlInterpreter (org.apache.zeppelin.geode.GeodeOqlInterpreter)1 InterpreterResult (org.apache.zeppelin.interpreter.InterpreterResult)1