QueryStatement implements Statement<QueryResult<?>> { @Override public QueryResult<?> execute(DataStorage dataStorage) throws IOException { CompiledQuery compiledQuery; try { compiledQuery = dataStorage.compile(this.query); } catch (QueryCompileException e) { throw new IOException(e); } try { EntityDefinition entityDefinition = EntityDefinitionManager.getEntityByServiceName(compiledQuery.getServiceName()); return dataStorage.query(compiledQuery, entityDefinition); } catch (InstantiationException | IllegalAccessException e) { throw new IOException(e); } } QueryStatement(RawQuery queryCondition); @Override QueryResult<?> execute(DataStorage dataStorage);  }
@Test public void testQueryExecute() throws Exception { RawQuery query = mock(RawQuery.class); CompiledQuery compiledQuery = mock(CompiledQuery.class); QueryStatement queryStatement = new QueryStatement(query); when(mockDataStorage.compile(query)).thenReturn(compiledQuery); when(compiledQuery.getServiceName()).thenReturn("TestTimeSeriesAPIEntity"); queryStatement.execute(mockDataStorage); verify(mockDataStorage).query(any(), any()); }