use of org.wso2.ballerinalang.compiler.semantics.analyzer.Types in project siddhi by wso2.
the class ConvertFunctionTestCase method convertFunctionTest2.
@Test
public void convertFunctionTest2() throws InterruptedException {
log.info("convert function test 2");
SiddhiManager siddhiManager = new SiddhiManager();
String cseEventStream = "" + "" + "define stream typeStream (typeS string, typeF float, typeD double, typeI int, typeL long, typeB " + "bool) ;";
String query = "" + "@info(name = 'query1') " + "from typeStream " + "select convert(typeS,'string') as valueS1, convert(typeS,'float') as valueF1, convert(typeS," + "'double') as valueD1, convert(typeS,'int') as valueI1 , convert(typeS,'long') as valueL1 , convert" + "(typeS,'bool') as valueB1, " + " convert(typeF,'string') as valueS2, convert(typeF,'float') as valueF2, convert(typeF," + "'double') as valueD2, convert(typeF,'int') as valueI2 , convert(typeF,'long') as valueL2 , convert" + "(typeF,'bool') as valueB2, " + " convert(typeD,'string') as valueS3, convert(typeD,'float') as valueF3, convert(typeD," + "'double') as valueD3, convert(typeD,'int') as valueI3 , convert(typeD,'long') as valueL3 , convert" + "(typeD,'bool') as valueB3, " + " convert(typeI,'string') as valueS4, convert(typeI,'float') as valueF4, convert(typeI," + "'double') as valueD4, convert(typeI,'int') as valueI4 , convert(typeI,'long') as valueL4 , convert" + "(typeI,'bool') as valueB4, " + " convert(typeL,'string') as valueS5, convert(typeL,'float') as valueF5, convert(typeL," + "'double') as valueD5, convert(typeL,'int') as valueI5 , convert(typeL,'long') as valueL5 , convert" + "(typeL,'bool') as valueB5, " + " convert(typeB,'string') as valueS6, convert(typeB,'float') as valueF6, convert(typeB," + "'double') as valueD6, convert(typeB,'int') as valueI6 , convert(typeB,'long') as valueL6 , convert" + "(typeB,'bool') as valueB6 " + "insert into outputStream ;";
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(cseEventStream + query);
siddhiAppRuntime.addCallback("query1", new QueryCallback() {
@Override
public void receive(long timestamp, Event[] inEvents, Event[] removeEvents) {
EventPrinter.print(timestamp, inEvents, removeEvents);
count++;
AssertJUnit.assertTrue(inEvents[0].getData(0) instanceof String);
AssertJUnit.assertTrue(inEvents[0].getData(1) == null);
AssertJUnit.assertTrue(inEvents[0].getData(2) == null);
AssertJUnit.assertTrue(inEvents[0].getData(3) == null);
AssertJUnit.assertTrue(inEvents[0].getData(4) == null);
AssertJUnit.assertTrue(inEvents[0].getData(5) instanceof Boolean && !((Boolean) inEvents[0].getData(5)));
AssertJUnit.assertTrue(inEvents[0].getData(6) instanceof String);
AssertJUnit.assertTrue(inEvents[0].getData(7) instanceof Float);
AssertJUnit.assertTrue(inEvents[0].getData(8) instanceof Double);
AssertJUnit.assertTrue(inEvents[0].getData(9) instanceof Integer);
AssertJUnit.assertTrue(inEvents[0].getData(10) instanceof Long);
AssertJUnit.assertTrue(inEvents[0].getData(11) instanceof Boolean && !((Boolean) inEvents[0].getData(11)));
AssertJUnit.assertTrue(inEvents[0].getData(12) instanceof String);
AssertJUnit.assertTrue(inEvents[0].getData(13) instanceof Float);
AssertJUnit.assertTrue(inEvents[0].getData(14) instanceof Double);
AssertJUnit.assertTrue(inEvents[0].getData(15) instanceof Integer);
AssertJUnit.assertTrue(inEvents[0].getData(16) instanceof Long);
AssertJUnit.assertTrue(inEvents[0].getData(17) instanceof Boolean && !((Boolean) inEvents[0].getData(17)));
AssertJUnit.assertTrue(inEvents[0].getData(18) instanceof String);
AssertJUnit.assertTrue(inEvents[0].getData(19) instanceof Float);
AssertJUnit.assertTrue(inEvents[0].getData(20) instanceof Double);
AssertJUnit.assertTrue(inEvents[0].getData(21) instanceof Integer);
AssertJUnit.assertTrue(inEvents[0].getData(22) instanceof Long);
AssertJUnit.assertTrue(inEvents[0].getData(23) instanceof Boolean && !((Boolean) inEvents[0].getData(23)));
AssertJUnit.assertTrue(inEvents[0].getData(24) instanceof String);
AssertJUnit.assertTrue(inEvents[0].getData(25) instanceof Float);
AssertJUnit.assertTrue(inEvents[0].getData(26) instanceof Double);
AssertJUnit.assertTrue(inEvents[0].getData(27) instanceof Integer);
AssertJUnit.assertTrue(inEvents[0].getData(28) instanceof Long);
AssertJUnit.assertTrue(inEvents[0].getData(29) instanceof Boolean && !((Boolean) inEvents[0].getData(29)));
AssertJUnit.assertTrue(inEvents[0].getData(30) instanceof String);
AssertJUnit.assertTrue(inEvents[0].getData(31) instanceof Float);
AssertJUnit.assertTrue(inEvents[0].getData(32) instanceof Double);
AssertJUnit.assertTrue(inEvents[0].getData(33) instanceof Integer);
AssertJUnit.assertTrue(inEvents[0].getData(34) instanceof Long);
AssertJUnit.assertTrue(inEvents[0].getData(35) instanceof Boolean && ((Boolean) inEvents[0].getData(35)));
}
});
InputHandler inputHandler = siddhiAppRuntime.getInputHandler("typeStream");
siddhiAppRuntime.start();
inputHandler.send(new Object[] { "WSO2", 2f, 3d, 4, 5L, true });
Thread.sleep(100);
AssertJUnit.assertEquals(1, count);
siddhiAppRuntime.shutdown();
}
use of org.wso2.ballerinalang.compiler.semantics.analyzer.Types in project siddhi by wso2.
the class ConvertFunctionTestCase method convertFunctionExceptionTest7.
@Test(expectedExceptions = SiddhiAppCreationException.class)
public void convertFunctionExceptionTest7() throws InterruptedException {
log.info("convert function test 7");
SiddhiManager siddhiManager = new SiddhiManager();
String cseEventStream = "define stream typeStream (typeS string, typeF float, typeD double, typeI int, typeL " + "long, typeB bool, typeN double) ;";
String query = "" + "@info(name = 'query1') " + "from typeStream " + "select convert(typeS,'234') as valueS, convert(typeF,'float') as valueF, convert(typeD," + "'double') as valueD , convert(typeI,'int') as valueI , convert(typeL,'long') as valueL , " + "convert(typeB,'bool') as valueB, convert(typeN,'string') as valueN " + "insert into outputStream ;";
siddhiManager.createSiddhiAppRuntime(cseEventStream + query);
}
use of org.wso2.ballerinalang.compiler.semantics.analyzer.Types in project siddhi by wso2.
the class ConvertFunctionTestCase method convertFunctionExceptionTest8.
@Test(expectedExceptions = SiddhiAppCreationException.class)
public void convertFunctionExceptionTest8() throws InterruptedException {
log.info("convert function test 8");
SiddhiManager siddhiManager = new SiddhiManager();
String cseEventStream = "define stream typeStream (typeS string, typeF float, typeD double, typeI int, typeL " + "long, typeB bool, typeN double) ;";
String query = "" + "@info(name = 'query1') " + "from typeStream " + "select convert(typeS,123) as valueS, convert(typeF,'float') as valueF, convert(typeD," + "'double') as valueD , convert(typeI,'int') as valueI , convert(typeL,'long') as valueL , " + "convert(typeB,'bool') as valueB, convert(typeN,'string') as valueN " + "insert into outputStream ;";
siddhiManager.createSiddhiAppRuntime(cseEventStream + query);
}
use of org.wso2.ballerinalang.compiler.semantics.analyzer.Types in project siddhi by wso2.
the class ConvertFunctionTestCase method convertFunctionTest5.
@Test(expectedExceptions = SiddhiAppCreationException.class)
public void convertFunctionTest5() throws InterruptedException {
log.info("convert function test 5");
SiddhiManager siddhiManager = new SiddhiManager();
String cseEventStream = "" + "" + "define stream typeStream (typeS string, typeF float, typeD double, typeI int, typeL long, typeB " + "bool) ;";
String query = "" + "@info(name = 'query1') " + "from typeStream " + "select convert(typeS,'string','int') as valueB1 " + "insert into outputStream ;";
siddhiManager.createSiddhiAppRuntime(cseEventStream + query);
}
use of org.wso2.ballerinalang.compiler.semantics.analyzer.Types in project siddhi by wso2.
the class ConvertFunctionTestCase method convertFunctionExceptionTest10.
@Test(expectedExceptions = SiddhiAppCreationException.class)
public void convertFunctionExceptionTest10() throws InterruptedException {
log.info("convert function test 10");
SiddhiManager siddhiManager = new SiddhiManager();
String cseEventStream = "define stream typeStream (typeS string, typeF float, typeD double, typeI int, typeL " + "long, typeB bool, typeN double) ;";
String query = "" + "@info(name = 'query1') " + "from typeStream " + "select convert(typeS,'invalidType') as valueS, convert(typeF,'float') as valueF, convert" + "(typeD," + "'double') as valueD , convert(typeI,'int') as valueI , convert(typeL,'long') as valueL , " + "convert(typeB,'bool') as valueB, convert(typeN,'string') as valueN " + "insert into outputStream ;";
siddhiManager.createSiddhiAppRuntime(cseEventStream + query);
}
Aggregations