SiddhiHandler implements RestListener, EventHandler<MapEvent> { @Override public List<Map<String, Object>> list() throws RestException { List<Map<String, Object>> listQueries = new ArrayList<>(); for (SiddhiPlan siddhiPlan : siddhiPlans.values()) { listQueries.add(siddhiPlan.toMap()); } return listQueries; } SiddhiHandler(Sink eventReceiver);  SiddhiHandler(); void stop(); Map<String, SiddhiPlan> getSiddhiPlans(); @Override void onEvent(MapEvent mapEvent, long sequence, boolean endOfBatch); @Override void add(Map<String, Object> element); synchronized void add(SiddhiPlan siddhiPlan); @Override synchronized void remove(String id); @Override synchronized void synchronize(List<Map<String, Object>> elements); @Override List<Map<String, Object>> list(); synchronized void save(); synchronized void restore();  }
@Test public void list() throws RestException { SiddhiHandler siddhiHandler = new SiddhiHandler(); List<Map<String, Object>> executionPlans = new ArrayList<>(); Map<String, Object> executionPlanMap = new HashMap<>(); Map<String, String> outputTopics = new HashMap<>(); outputTopics.put("testOutput", "outputTopic"); executionPlanMap.put("id", "testID"); executionPlanMap.put("input", Arrays.asList("test", "test2")); executionPlanMap.put("output", outputTopics); executionPlanMap.put("executionPlan", "from test select a insert into testOutput"); executionPlanMap.put("version", 0); executionPlanMap.put("filters", Collections.emptyMap()); executionPlans.add(executionPlanMap); Map<String, Object> executionPlanMap2 = new HashMap<>(); Map<String, String> outputTopics2 = new HashMap<>(); outputTopics2.put("testOutput", "outputTopic"); executionPlanMap2.put("id", "testID2"); executionPlanMap2.put("input", Arrays.asList("test", "test2")); executionPlanMap2.put("output", outputTopics2); executionPlanMap2.put("executionPlan", "from test select d insert into testOutput"); executionPlanMap2.put("version", 0); executionPlanMap2.put("filters", Collections.emptyMap()); executionPlans.add(executionPlanMap2); siddhiHandler.synchronize(executionPlans); assertTrue(executionPlans.containsAll(siddhiHandler.list())); assertTrue(siddhiHandler.list().containsAll(executionPlans)); }