@Test
void executeSuccessfully() {

  List<ExprValue> expected =
      Arrays.asList(
          tupleValue(of("name", "John", "age", 20)), tupleValue(of("name", "Allen", "age", 30)));
  FakePhysicalPlan plan = new FakePhysicalPlan(expected.iterator());
  when(protector.protect(plan)).thenReturn(plan);
  ElasticsearchExecutionEngine executor = new ElasticsearchExecutionEngine(client, protector);
  List<ExprValue> actual = new ArrayList<>();
  executor.execute(
      plan,
      new ResponseListener<QueryResponse>() {
        @Override
        public void onResponse(QueryResponse response) {
          actual.addAll(response.getResults());
        }
        @Override
        public void onFailure(Exception e) {
          fail("Error occurred during execution", e);
        }
      });
  assertTrue(plan.hasOpen);
  assertEquals(expected, actual);
  assertTrue(plan.hasClosed);
}