use of org.wso2.charon3.core.attributes.Attribute in project siddhi by wso2.
the class FilterTestCase1 method testFilterQuery64.
@Test
public void testFilterQuery64() throws InterruptedException {
log.info("Filter test64");
SiddhiManager siddhiManager = new SiddhiManager();
StreamDefinition cseEventStream = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute.Type.STRING).attribute("price", Attribute.Type.FLOAT).attribute("volume", Attribute.Type.LONG);
Query query = new Query();
query.from(InputStream.stream("cseEventStream").filter(Expression.compare(Expression.variable("volume"), Compare.Operator.EQUAL, Expression.value(40f))));
query.annotation(Annotation.annotation("info").element("name", "query1"));
query.select(Selector.selector().select("symbol", Expression.variable("symbol")).select("price", Expression.variable("price")));
query.insertInto("outputStream");
SiddhiApp siddhiApp = new SiddhiApp("ep1");
siddhiApp.defineStream(cseEventStream);
siddhiApp.addQuery(query);
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp);
siddhiAppRuntime.addCallback("query1", new QueryCallback() {
@Override
public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
EventPrinter.print(timeStamp, inEvents, removeEvents);
count = count + inEvents.length;
}
});
InputHandler inputHandler = siddhiAppRuntime.getInputHandler("cseEventStream");
siddhiAppRuntime.start();
inputHandler.send(new Object[] { "WSO2", 50f, 60L });
inputHandler.send(new Object[] { "WSO2", 70f, 40L });
inputHandler.send(new Object[] { "WSO2", 44f, 200L });
Thread.sleep(100);
AssertJUnit.assertEquals(1, count);
siddhiAppRuntime.shutdown();
}
use of org.wso2.charon3.core.attributes.Attribute in project siddhi by wso2.
the class FilterTestCase1 method testFilterQuery82.
@Test
public void testFilterQuery82() throws InterruptedException {
log.info("Filter test82");
SiddhiManager siddhiManager = new SiddhiManager();
StreamDefinition cseEventStream = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute.Type.STRING).attribute("price", Attribute.Type.DOUBLE).attribute("volume", Attribute.Type.DOUBLE);
Query query = new Query();
query.from(InputStream.stream("cseEventStream").filter(Expression.compare(Expression.variable("price"), Compare.Operator.LESS_THAN, Expression.value(50))));
query.annotation(Annotation.annotation("info").element("name", "query1"));
query.select(Selector.selector().select("symbol", Expression.variable("symbol")).select("price", Expression.variable("price")));
query.insertInto("outputStream");
SiddhiApp siddhiApp = new SiddhiApp("ep1");
siddhiApp.defineStream(cseEventStream);
siddhiApp.addQuery(query);
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp);
siddhiAppRuntime.addCallback("query1", new QueryCallback() {
@Override
public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
EventPrinter.print(timeStamp, inEvents, removeEvents);
count = count + inEvents.length;
}
});
InputHandler inputHandler = siddhiAppRuntime.getInputHandler("cseEventStream");
siddhiAppRuntime.start();
inputHandler.send(new Object[] { "WSO2", 50d, 60d });
inputHandler.send(new Object[] { "WSO2", 70d, 40d });
inputHandler.send(new Object[] { "WSO2", 44d, 200d });
Thread.sleep(100);
AssertJUnit.assertEquals(1, count);
siddhiAppRuntime.shutdown();
}
use of org.wso2.charon3.core.attributes.Attribute in project siddhi by wso2.
the class FilterTestCase1 method testFilterQuery60.
@Test
public void testFilterQuery60() throws InterruptedException {
log.info("Filter test60");
SiddhiManager siddhiManager = new SiddhiManager();
StreamDefinition cseEventStream = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute.Type.STRING).attribute("price", Attribute.Type.FLOAT).attribute("volume", Attribute.Type.DOUBLE).attribute("quantity", Attribute.Type.INT);
Query query = new Query();
query.from(InputStream.stream("cseEventStream").filter(Expression.compare(Expression.variable("quantity"), Compare.Operator.EQUAL, Expression.value(2))));
query.annotation(Annotation.annotation("info").element("name", "query1"));
query.select(Selector.selector().select("symbol", Expression.variable("symbol")).select("price", Expression.variable("price")).select("quantity", Expression.variable("quantity")));
query.insertInto("outputStream");
SiddhiApp siddhiApp = new SiddhiApp("ep1");
siddhiApp.defineStream(cseEventStream);
siddhiApp.addQuery(query);
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp);
siddhiAppRuntime.addCallback("query1", new QueryCallback() {
@Override
public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
EventPrinter.print(timeStamp, inEvents, removeEvents);
count = count + inEvents.length;
}
});
InputHandler inputHandler = siddhiAppRuntime.getInputHandler("cseEventStream");
siddhiAppRuntime.start();
inputHandler.send(new Object[] { "WSO2", 50f, 60d, 5 });
inputHandler.send(new Object[] { "WSO2", 70f, 60d, 2 });
inputHandler.send(new Object[] { "WSO2", 60f, 200d, 4 });
Thread.sleep(100);
AssertJUnit.assertEquals(1, count);
siddhiAppRuntime.shutdown();
}
use of org.wso2.charon3.core.attributes.Attribute in project siddhi by wso2.
the class FilterTestCase1 method testFilterQuery76.
@Test
public void testFilterQuery76() throws InterruptedException {
log.info("Filter test76");
SiddhiManager siddhiManager = new SiddhiManager();
StreamDefinition cseEventStream = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute.Type.STRING).attribute("price", Attribute.Type.FLOAT).attribute("volume", Attribute.Type.LONG);
Query query = new Query();
query.from(InputStream.stream("cseEventStream").filter(Expression.compare(Expression.variable("volume"), Compare.Operator.LESS_THAN_EQUAL, Expression.value(50d))));
query.annotation(Annotation.annotation("info").element("name", "query1"));
query.select(Selector.selector().select("symbol", Expression.variable("symbol")).select("price", Expression.variable("price")));
query.insertInto("outputStream");
SiddhiApp siddhiApp = new SiddhiApp("ep1");
siddhiApp.defineStream(cseEventStream);
siddhiApp.addQuery(query);
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp);
siddhiAppRuntime.addCallback("query1", new QueryCallback() {
@Override
public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
EventPrinter.print(timeStamp, inEvents, removeEvents);
count = count + inEvents.length;
}
});
InputHandler inputHandler = siddhiAppRuntime.getInputHandler("cseEventStream");
siddhiAppRuntime.start();
inputHandler.send(new Object[] { "WSO2", 50f, 60L });
inputHandler.send(new Object[] { "WSO2", 70f, 40L });
inputHandler.send(new Object[] { "WSO2", 44f, 200L });
Thread.sleep(100);
AssertJUnit.assertEquals(1, count);
siddhiAppRuntime.shutdown();
}
use of org.wso2.charon3.core.attributes.Attribute in project siddhi by wso2.
the class FilterTestCase1 method testFilterQuery18.
@Test
public void testFilterQuery18() throws InterruptedException {
log.info("Filter test18");
SiddhiManager siddhiManager = new SiddhiManager();
StreamDefinition cseEventStream = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute.Type.STRING).attribute("price", Attribute.Type.FLOAT).attribute("volume", Attribute.Type.INT);
Query query = new Query();
query.from(InputStream.stream("cseEventStream").filter(Expression.compare(Expression.value(70), Compare.Operator.GREATER_THAN, Expression.variable("volume"))));
query.annotation(Annotation.annotation("info").element("name", "query1"));
query.select(Selector.selector().select("symbol", Expression.variable("symbol")).select("price", Expression.variable("price")));
query.insertInto("StockQuote");
SiddhiApp siddhiApp = new SiddhiApp("ep1");
siddhiApp.defineStream(cseEventStream);
siddhiApp.addQuery(query);
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp);
QueryCallback queryCallback = new QueryCallback() {
@Override
public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
EventPrinter.print(timeStamp, inEvents, removeEvents);
AssertJUnit.assertTrue("WSO2".equals(inEvents[0].getData(0)));
count = count + inEvents.length;
}
};
siddhiAppRuntime.addCallback("query1", queryCallback);
InputHandler inputHandler = siddhiAppRuntime.getInputHandler("cseEventStream");
siddhiAppRuntime.start();
inputHandler.send(new Object[] { "WSO2", 55.6f, 50 });
inputHandler.send(new Object[] { "IBM", 75.6f, 100 });
inputHandler.send(new Object[] { "WSO2", 57.6f, 30 });
Thread.sleep(100);
AssertJUnit.assertEquals(2, count);
siddhiAppRuntime.shutdown();
}
Aggregations