Source:
public void testCreateFromJSONFunctionExtension2() throws InterruptedException { log.info("CreateFromJSONFunctionExtension TestCase 2"); SiddhiManager siddhiManager = new SiddhiManager(); siddhiManager.setExtension("str:concat",ConcatFunctionExtension.class); String inStreamDefinition = "\ndefine stream inputStream (symbol string, price long, volume long);"; String query = ("@info(name = 'query1') from inputStream select " + "map:createFromJSON(str:concat('{symbol :',symbol,', price :',price,', volume :',volume,'}')) as hashMap insert into outputStream;"); ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(inStreamDefinition + query); executionPlanRuntime.addCallback("outputStream",new StreamCallback() { @Override public void receive(Event[] inEvents) { EventPrinter.print(inEvents); for (Event event : inEvents) { count.incrementAndGet(); HashMap map = (HashMap) event.getData(0); if (count.get() == 1) { Assert.assertEquals("IBM",map.get("symbol")); eventArrived = true; } if (count.get() == 2) { Assert.assertEquals("WSO2",map.get("symbol")); eventArrived = true; } if (count.get() == 3) { Assert.assertEquals("XYZ",map.get("symbol")); eventArrived = true; } } } }); InputHandler inputHandler = executionPlanRuntime.getInputHandler("inputStream"); executionPlanRuntime.start(); inputHandler.send(new Object[]{"IBM",100,100l}); inputHandler.send(new Object[]{"WSO2",200,200l}); inputHandler.send(new Object[]{"XYZ",300,200l}); SiddhiTestHelper.waitForEvents(100,3,count,60000); Assert.assertEquals(3,count.get()); Assert.assertTrue(eventArrived); executionPlanRuntime.shutdown(); }

Target:
public void testCreateFromJSONFunctionExtension2() throws InterruptedException { log.info("CreateFromJSONFunctionExtension TestCase 2"); SiddhiManager siddhiManager = new SiddhiManager(); siddhiManager.setExtension("str:concat", ConcatFunctionExtension.class); String inStreamDefinition = "\ndefine stream inputStream (symbol string, price long, volume long);"; String query = ("@info(name = 'query1') from inputStream select " + "map:createFromJSON(str:concat('{symbol " + ",symbol,', price :',price,', volume :',volume,'}')) as hashMap insert into outputStream;"); ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(inStreamDefinition + query); executionPlanRuntime.addCallback("outputStream", new StreamCallback() { @Override public void receive(Event[] inEvents) { EventPrinter.print(inEvents); for (Event event : inEvents) { count.incrementAndGet(); HashMap map = (HashMap) event.getData(0); if (count.get() == 1) { Assert.assertEquals("IBM", map.get("symbol")); eventArrived = true; } if (count.get() == 2) { Assert.assertEquals("WSO2", map.get("symbol")); eventArrived = true; } if (count.get() == 3) { Assert.assertEquals("XYZ", map.get("symbol")); eventArrived = true; } } } }); InputHandler inputHandler = executionPlanRuntime.getInputHandler("inputStream"); executionPlanRuntime.start(); inputHandler.send(new Object[]{"IBM", 100, 100l}); inputHandler.send(new Object[]{"WSO2", 200, 200l}); inputHandler.send(new Object[]{"XYZ", 300, 200l}); SiddhiTestHelper.waitForEvents(100, 3, count, 60000); Assert.assertEquals(3, count.get()); Assert.assertTrue(eventArrived); executionPlanRuntime.shutdown(); }