use of org.wso2.siddhi.query.api.execution.query.output.stream.OutputStream in project siddhi by wso2.
the class InstanceOfFunctionTestCase method testInstanceOfStringFunctionExtensionExceptionTestCase.
@Test(expectedExceptions = SiddhiAppCreationException.class)
public void testInstanceOfStringFunctionExtensionExceptionTestCase() throws InterruptedException {
log.info("testInstanceOfStringFunctionExtensionException TestCase");
SiddhiManager siddhiManager = new SiddhiManager();
String sensorEventStream = "define stream sensorEventStream (timestamp long, " + "isPowerSaverEnabled bool, sensorId int , sensorName string, longitude double, " + "latitude double, " + "humidity float, sensorValue double);";
String query = ("@info(name = 'query1') " + "from sensorEventStream " + "select sensorName ,instanceOfString(sensorName,sensorId) as valid " + "insert into outputStream;");
siddhiManager.createSiddhiAppRuntime(sensorEventStream + query);
}
use of org.wso2.siddhi.query.api.execution.query.output.stream.OutputStream in project siddhi by wso2.
the class InstanceOfFunctionTestCase method testInstanceOfIntegerFunctionExtensionTestCase.
@Test
public void testInstanceOfIntegerFunctionExtensionTestCase() throws InterruptedException {
log.info("testInstanceOfIntegerFunctionExtension TestCase");
SiddhiManager siddhiManager = new SiddhiManager();
String sensorEventStream = "define stream sensorEventStream (timestamp long, " + "isPowerSaverEnabled bool, sensorId int , sensorName string, longitude double, latitude double, " + "humidity float, sensorValue double);";
String query = ("@info(name = 'query1') " + "from sensorEventStream " + "select sensorName ,instanceOfInteger(sensorId) as valid, sensorId " + "insert into outputStream;");
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(sensorEventStream + query);
siddhiAppRuntime.addCallback("query1", new QueryCallback() {
@Override
public void receive(long timestamp, Event[] inEvents, Event[] removeEvents) {
EventPrinter.print(timestamp, inEvents, removeEvents);
for (Event inEvent : inEvents) {
count++;
if (count == 1) {
AssertJUnit.assertEquals(true, inEvent.getData(1));
}
if (count == 2) {
AssertJUnit.assertEquals(false, inEvent.getData(1));
}
eventArrived = true;
}
}
});
InputHandler inputHandler = siddhiAppRuntime.getInputHandler("sensorEventStream");
siddhiAppRuntime.start();
inputHandler.send(new Object[] { 19900813115534L, false, 601, "temperature", 90.34344, 20.44345, 2.3f, 20.44345 });
inputHandler.send(new Object[] { 19900813115534L, true, 60232434.657, "temperature", 90.34344, 20.44345, 2.3f, 20.44345 });
Thread.sleep(100);
org.testng.AssertJUnit.assertEquals(2, count);
AssertJUnit.assertTrue(eventArrived);
siddhiAppRuntime.shutdown();
}
use of org.wso2.siddhi.query.api.execution.query.output.stream.OutputStream in project siddhi by wso2.
the class InstanceOfFunctionTestCase method testInstanceOfLongFunctionExtensionTestCase.
@Test
public void testInstanceOfLongFunctionExtensionTestCase() throws InterruptedException {
log.info("testInstanceOfLongFunctionExtension TestCase");
SiddhiManager siddhiManager = new SiddhiManager();
String sensorEventStream = "define stream sensorEventStream (timestamp long, " + "isPowerSaverEnabled bool, sensorId int , sensorName string, longitude double, latitude double, " + "humidity float, sensorValue double);";
String query = ("@info(name = 'query1') " + "from sensorEventStream " + "select sensorName ,instanceOfLong(timestamp) as valid, timestamp " + "insert into outputStream;");
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(sensorEventStream + query);
siddhiAppRuntime.addCallback("query1", new QueryCallback() {
@Override
public void receive(long timestamp, Event[] inEvents, Event[] removeEvents) {
EventPrinter.print(timestamp, inEvents, removeEvents);
for (Event inEvent : inEvents) {
count++;
if (count == 1) {
AssertJUnit.assertEquals(true, inEvent.getData(1));
}
if (count == 2) {
AssertJUnit.assertEquals(false, inEvent.getData(1));
}
eventArrived = true;
}
}
});
InputHandler inputHandler = siddhiAppRuntime.getInputHandler("sensorEventStream");
siddhiAppRuntime.start();
inputHandler.send(new Object[] { 19900813115534L, false, 601, "temperature", 90.34344, 20.44345, 2.3f, 20.44345 });
inputHandler.send(new Object[] { 1990, false, 602, "temperature", 90.34344, 20.44345, 2.3f, 20.44345 });
Thread.sleep(100);
org.testng.AssertJUnit.assertEquals(2, count);
AssertJUnit.assertTrue(eventArrived);
siddhiAppRuntime.shutdown();
}
use of org.wso2.siddhi.query.api.execution.query.output.stream.OutputStream in project siddhi by wso2.
the class InstanceOfFunctionTestCase method testInstanceOfFloatFunctionExtensionTestCase.
@Test
public void testInstanceOfFloatFunctionExtensionTestCase() throws InterruptedException {
log.info("testInstanceOfFloatFunctionExtension TestCase");
SiddhiManager siddhiManager = new SiddhiManager();
String sensorEventStream = "define stream sensorEventStream (timestamp long, " + "isPowerSaverEnabled bool, sensorId int , sensorName string, longitude double, latitude double, " + "humidity float, sensorValue double);";
String query = ("@info(name = 'query1') " + "from sensorEventStream " + "select sensorName ,instanceOfFloat(humidity) as valid, longitude " + "insert into outputStream;");
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(sensorEventStream + query);
siddhiAppRuntime.addCallback("query1", new QueryCallback() {
@Override
public void receive(long timestamp, Event[] inEvents, Event[] removeEvents) {
EventPrinter.print(timestamp, inEvents, removeEvents);
for (Event inEvent : inEvents) {
count++;
if (count == 1) {
AssertJUnit.assertEquals(true, inEvent.getData(1));
}
if (count == 2) {
AssertJUnit.assertEquals(false, inEvent.getData(1));
}
eventArrived = true;
}
}
});
InputHandler inputHandler = siddhiAppRuntime.getInputHandler("sensorEventStream");
siddhiAppRuntime.start();
inputHandler.send(new Object[] { 19900813115534L, false, 601, "temperature", 90.34344, 20.44345, 2.3f, 20.44345 });
inputHandler.send(new Object[] { 19900813115534L, true, 602, "temperature", 90.34344, 20.44345, 2.3, 20.44345 });
Thread.sleep(100);
org.testng.AssertJUnit.assertEquals(2, count);
AssertJUnit.assertTrue(eventArrived);
siddhiAppRuntime.shutdown();
}
use of org.wso2.siddhi.query.api.execution.query.output.stream.OutputStream in project siddhi by wso2.
the class InstanceOfFunctionTestCase method testInstanceOfFloatFunctionExtensionExceptionTestCase.
@Test(expectedExceptions = SiddhiAppCreationException.class)
public void testInstanceOfFloatFunctionExtensionExceptionTestCase() throws InterruptedException {
log.info("testInstanceOfFloatFunctionExtensionException TestCase");
SiddhiManager siddhiManager = new SiddhiManager();
String sensorEventStream = "define stream sensorEventStream (timestamp long, " + "isPowerSaverEnabled bool, sensorId int , sensorName string, longitude double, " + "latitude double, " + "humidity float, sensorValue double);";
String query = ("@info(name = 'query1') " + "from sensorEventStream " + "select sensorName ,instanceOfFloat(humidity,sensorName) as valid, longitude " + "insert into outputStream;");
siddhiManager.createSiddhiAppRuntime(sensorEventStream + query);
}
Aggregations