use of io.siddhi.core.util.config.ConfigManager in project siddhi by wso2.
the class Aggregation2TestCase method incrementalStreamProcessorTest5SGTTimeZoneHour2.
@Test(dependsOnMethods = { "incrementalStreamProcessorTest5SGTTimeZoneHour" })
public void incrementalStreamProcessorTest5SGTTimeZoneHour2() throws InterruptedException {
// feb 29 leap end hour
LOG.info("incrementalStreamProcessorTest5");
SiddhiManager siddhiManager = new SiddhiManager();
Map<String, String> systemConfigs = new HashMap<>();
systemConfigs.put("aggTimeZone", "Asia/Singapore");
ConfigManager configManager = new InMemoryConfigManager(null, null, systemConfigs);
siddhiManager.setConfigManager(configManager);
String stockStream = "define stream stockStream (symbol string, price float, timestamp long);";
String query = " define aggregation stockAggregation " + "from stockStream " + "select symbol, avg(price) as avgPrice " + "group by symbol " + "aggregate by timestamp every hour ;";
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(stockStream + query);
InputHandler stockStreamInputHandler = siddhiAppRuntime.getInputHandler("stockStream");
siddhiAppRuntime.start();
// Saturday February 29, 2020 23:00:01 (pm) in time zone Asia/Singapore (+08)
stockStreamInputHandler.send(new Object[] { "WSO2", 50f, 1582988401000L });
// Saturday February 29, 2020 23:59:59 (pm) in time zone Asia/Singapore (+08)
stockStreamInputHandler.send(new Object[] { "WSO2", 70f, 1582991999000L });
// Sunday March 01, 2020 00:00:01 (am) in time zone Asia/Singapore (+08)
stockStreamInputHandler.send(new Object[] { "WSO2", 80f, 1582992001000L });
Thread.sleep(2000);
Event[] events = siddhiAppRuntime.query("from stockAggregation " + "within \"2020-**-** **:**:**\" " + "per \"hour\"");
EventPrinter.print(events);
Assert.assertNotNull(events, "Queried results cannot be null.");
AssertJUnit.assertEquals(2, events.length);
List<Object[]> eventsOutputList = new ArrayList<>();
for (Event event : events) {
eventsOutputList.add(event.getData());
}
List<Object[]> expected = Arrays.asList(new Object[] { 1582988400000L, "WSO2", 60.0 }, new Object[] { 1582992000000L, "WSO2", 80.0 });
AssertJUnit.assertTrue("In events matched", SiddhiTestHelper.isUnsortedEventsMatch(eventsOutputList, expected));
siddhiAppRuntime.shutdown();
}
Aggregations