Search in sources :

Example 46 with And

use of org.wso2.siddhi.query.api.expression.condition.And in project siddhi by wso2.

the class FilterTestCase1 method testFilterQuery22.

@Test
public void testFilterQuery22() throws InterruptedException {
    log.info("Filter test22");
    SiddhiManager siddhiManager = new SiddhiManager();
    String cseEventStream = "define stream cseEventStream (symbol string, price float, volume double);";
    String query = "@info(name = 'query1') from cseEventStream[volume > 12L and price < 56] select symbol,price," + "volume 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);
            AssertJUnit.assertEquals(100d, inEvents[0].getData(2));
            count = count + inEvents.length;
        }
    });
    InputHandler inputHandler = siddhiAppRuntime.getInputHandler("cseEventStream");
    siddhiAppRuntime.start();
    inputHandler.send(new Object[] { "WSO2", 55.6f, 100d });
    inputHandler.send(new Object[] { "WSO2", 57.6f, 10d });
    Thread.sleep(100);
    AssertJUnit.assertEquals(1, count);
    siddhiAppRuntime.shutdown();
}
Also used : InputHandler(org.wso2.siddhi.core.stream.input.InputHandler) SiddhiAppRuntime(org.wso2.siddhi.core.SiddhiAppRuntime) Event(org.wso2.siddhi.core.event.Event) SiddhiManager(org.wso2.siddhi.core.SiddhiManager) QueryCallback(org.wso2.siddhi.core.query.output.callback.QueryCallback) Test(org.testng.annotations.Test)

Example 47 with And

use of org.wso2.siddhi.query.api.expression.condition.And in project siddhi by wso2.

the class FilterTestCase1 method testFilterQuery26.

@Test
public void testFilterQuery26() throws InterruptedException {
    log.info("Filter test26");
    SiddhiManager siddhiManager = new SiddhiManager();
    String cseEventStream = "define stream cseEventStream (symbol string, price float, volume long);";
    String query = "@info(name = 'query1') from cseEventStream[volume != 100 and volume != 70d] select symbol," + "price,volume 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 = count + inEvents.length;
        }
    });
    InputHandler inputHandler = siddhiAppRuntime.getInputHandler("cseEventStream");
    siddhiAppRuntime.start();
    inputHandler.send(new Object[] { "WSO2", 55.6f, 100L });
    inputHandler.send(new Object[] { "IBM", 57.6f, 10L });
    Thread.sleep(100);
    AssertJUnit.assertEquals(1, count);
    siddhiAppRuntime.shutdown();
}
Also used : InputHandler(org.wso2.siddhi.core.stream.input.InputHandler) SiddhiAppRuntime(org.wso2.siddhi.core.SiddhiAppRuntime) Event(org.wso2.siddhi.core.event.Event) SiddhiManager(org.wso2.siddhi.core.SiddhiManager) QueryCallback(org.wso2.siddhi.core.query.output.callback.QueryCallback) Test(org.testng.annotations.Test)

Example 48 with And

use of org.wso2.siddhi.query.api.expression.condition.And in project siddhi by wso2.

the class FilterTestCase1 method testFilterQuery32.

@Test
public void testFilterQuery32() throws InterruptedException {
    log.info("Filter test32");
    SiddhiManager siddhiManager = new SiddhiManager();
    String cseEventStream = "define stream cseEventStream (symbol string, price float, volume int);";
    String query = "@info(name = 'query1') from cseEventStream[price != 50 and volume != 50L] select symbol," + "price,volume 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 = count + inEvents.length;
        }
    });
    InputHandler inputHandler = siddhiAppRuntime.getInputHandler("cseEventStream");
    siddhiAppRuntime.start();
    inputHandler.send(new Object[] { "WSO2", 55.5f, 40 });
    inputHandler.send(new Object[] { "WSO2", 53.5f, 50 });
    Thread.sleep(100);
    AssertJUnit.assertEquals(1, count);
    siddhiAppRuntime.shutdown();
}
Also used : InputHandler(org.wso2.siddhi.core.stream.input.InputHandler) SiddhiAppRuntime(org.wso2.siddhi.core.SiddhiAppRuntime) Event(org.wso2.siddhi.core.event.Event) SiddhiManager(org.wso2.siddhi.core.SiddhiManager) QueryCallback(org.wso2.siddhi.core.query.output.callback.QueryCallback) Test(org.testng.annotations.Test)

Example 49 with And

use of org.wso2.siddhi.query.api.expression.condition.And in project siddhi by wso2.

the class FilterTestCase1 method testFilterQuery29.

@Test
public void testFilterQuery29() throws InterruptedException {
    log.info("Filter test29");
    SiddhiManager siddhiManager = new SiddhiManager();
    String cseEventStream = "define stream cseEventStream (symbol string, price float, volume int);";
    String query = "@info(name = 'query1') from cseEventStream[volume != 40d and volume != 400d] select symbol," + "price,volume 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 = count + inEvents.length;
        }
    });
    InputHandler inputHandler = siddhiAppRuntime.getInputHandler("cseEventStream");
    siddhiAppRuntime.start();
    inputHandler.send(new Object[] { "WSO2", 55.5f, 40 });
    inputHandler.send(new Object[] { "WSO2", 53.5f, 50 });
    inputHandler.send(new Object[] { "WSO2", 50.5f, 400 });
    Thread.sleep(100);
    AssertJUnit.assertEquals(1, count);
    siddhiAppRuntime.shutdown();
}
Also used : InputHandler(org.wso2.siddhi.core.stream.input.InputHandler) SiddhiAppRuntime(org.wso2.siddhi.core.SiddhiAppRuntime) Event(org.wso2.siddhi.core.event.Event) SiddhiManager(org.wso2.siddhi.core.SiddhiManager) QueryCallback(org.wso2.siddhi.core.query.output.callback.QueryCallback) Test(org.testng.annotations.Test)

Example 50 with And

use of org.wso2.siddhi.query.api.expression.condition.And in project siddhi by wso2.

the class FilterTestCase1 method testFilterQuery44.

@Test(expectedExceptions = SiddhiAppCreationException.class)
public void testFilterQuery44() throws InterruptedException {
    log.info("Filter test44");
    SiddhiManager siddhiManager = new SiddhiManager();
    String cseEventStream = "define stream cseEventStream (symbol string, price float, volume long);";
    String query = "@info(name = 'query1') from cseEventStream[volume >= 50 and volume] select symbol,price," + "volume insert into outputStream ;";
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(cseEventStream + query);
}
Also used : SiddhiAppRuntime(org.wso2.siddhi.core.SiddhiAppRuntime) SiddhiManager(org.wso2.siddhi.core.SiddhiManager) Test(org.testng.annotations.Test)

Aggregations

Test (org.testng.annotations.Test)409 SiddhiAppRuntime (org.wso2.siddhi.core.SiddhiAppRuntime)337 SiddhiManager (org.wso2.siddhi.core.SiddhiManager)336 InputHandler (org.wso2.siddhi.core.stream.input.InputHandler)327 TestUtil (org.wso2.siddhi.core.TestUtil)204 Event (org.wso2.siddhi.core.event.Event)119 ArrayList (java.util.ArrayList)110 QueryCallback (org.wso2.siddhi.core.query.output.callback.QueryCallback)86 APIMgtDAOException (org.wso2.carbon.apimgt.core.exception.APIMgtDAOException)77 HashMap (java.util.HashMap)61 PreparedStatement (java.sql.PreparedStatement)55 SQLException (java.sql.SQLException)51 IOException (java.io.IOException)45 Connection (java.sql.Connection)45 ActivityInterface (org.wso2.carbon.bpel.ui.bpel2svg.ActivityInterface)44 APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)43 API (org.wso2.carbon.apimgt.core.models.API)39 ResultSet (java.sql.ResultSet)35 Map (java.util.Map)33 CharonException (org.wso2.charon3.core.exceptions.CharonException)33