PPLService { public void execute(PPLQueryRequest request, ResponseListener<QueryResponse> listener) { try { ParseTree cst = parser.analyzeSyntax(request.getRequest()); UnresolvedPlan ast = cst.accept(new AstBuilder(new AstExpressionBuilder(), request.getRequest())); LogicalPlan logicalPlan = analyzer.analyze(UnresolvedPlanHelper.addSelectAll(ast), new AnalysisContext()); PhysicalPlan physicalPlan = new Planner(storageEngine).plan(logicalPlan); executionEngine.execute(physicalPlan, listener); } catch (Exception e) { listener.onFailure(e); } }  void execute(PPLQueryRequest request, ResponseListener<QueryResponse> listener);  }
@Test public void testExecuteShouldPass() { doAnswer(invocation -> { ResponseListener<QueryResponse> listener = invocation.getArgument(1); listener.onResponse(new QueryResponse(schema, Collections.emptyList())); return null; }).when(executionEngine).execute(any(), any()); pplService.execute(new PPLQueryRequest("search source=t a=1", null), new ResponseListener<QueryResponse>() { @Override public void onResponse(QueryResponse pplQueryResponse) { } @Override public void onFailure(Exception e) { Assert.fail(); } }); }
@Test public void testExecuteWithIllegalQueryShouldBeCaughtByHandler() { pplService.execute(new PPLQueryRequest("search", null), new ResponseListener<QueryResponse>() { @Override public void onResponse(QueryResponse pplQueryResponse) { Assert.fail(); } @Override public void onFailure(Exception e) { } }); }
@Test public void test() { pplService.execute(new PPLQueryRequest("search", null), new ResponseListener<QueryResponse>() { @Override public void onResponse(QueryResponse pplQueryResponse) { Assert.fail(); } @Override public void onFailure(Exception e) { } }); }