use of io.siddhi.query.api.definition.Attribute in project siddhi by wso2.
the class OnDemandQueryTableTestCase method test12.
@Test
public void test12() throws InterruptedException {
log.info("Test12 - Test output attributes and its types for table");
SiddhiManager siddhiManager = new SiddhiManager();
String streams = "" + "define stream StockStream (symbol string, price float, volume long);" + "@PrimaryKey('symbol') " + "define table StockTable (symbol string, price float, volume long); ";
String onDemandQuery = "" + "from StockTable " + "select * ;";
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(streams);
siddhiAppRuntime.start();
Attribute[] actualAttributeArray = siddhiAppRuntime.getOnDemandQueryOutputAttributes(SiddhiCompiler.parseOnDemandQuery(onDemandQuery));
Attribute symbolAttribute = new Attribute("symbol", Attribute.Type.STRING);
Attribute priceAttribute = new Attribute("price", Attribute.Type.FLOAT);
Attribute volumeAttribute = new Attribute("volume", Attribute.Type.LONG);
Attribute[] expectedAttributeArray = new Attribute[] { symbolAttribute, priceAttribute, volumeAttribute };
AssertJUnit.assertArrayEquals(expectedAttributeArray, actualAttributeArray);
onDemandQuery = "" + "from StockTable " + "select symbol, sum(volume) as totalVolume ;";
actualAttributeArray = siddhiAppRuntime.getOnDemandQueryOutputAttributes(SiddhiCompiler.parseOnDemandQuery(onDemandQuery));
Attribute totalVolumeAttribute = new Attribute("totalVolume", Attribute.Type.LONG);
expectedAttributeArray = new Attribute[] { symbolAttribute, totalVolumeAttribute };
siddhiAppRuntime.shutdown();
AssertJUnit.assertArrayEquals(expectedAttributeArray, actualAttributeArray);
}
Aggregations