Search in sources :

Example 71 with Not

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

the class AbsentSequenceTestCase method testQueryAbsent22.

@Test
public void testQueryAbsent22() throws InterruptedException {
    log.info("Test the query e1, e2, not e3 for 1 sec, e4 with e1, e2, e3, and e4");
    SiddhiManager siddhiManager = new SiddhiManager();
    String streams = "" + "define stream Stream1 (symbol string, price float, volume int); " + "define stream Stream2 (symbol string, price float, volume int); " + "define stream Stream3 (symbol string, price float, volume int); " + "define stream Stream4 (symbol string, price float, volume int); ";
    String query = "" + "@info(name = 'query1') " + "from e1=Stream1[price>10], e2=Stream2[price>20], not Stream3[price>30] for 1 sec, " + "e4=Stream4[price>40] " + "select e1.symbol as symbol1, e2.symbol as symbol2, e4.symbol as symbol4 " + "insert into OutputStream ;";
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(streams + query);
    TestUtil.TestCallback callback = TestUtil.addQueryCallback(siddhiAppRuntime, "query1");
    InputHandler stream1 = siddhiAppRuntime.getInputHandler("Stream1");
    InputHandler stream2 = siddhiAppRuntime.getInputHandler("Stream2");
    InputHandler stream3 = siddhiAppRuntime.getInputHandler("Stream3");
    InputHandler stream4 = siddhiAppRuntime.getInputHandler("Stream4");
    siddhiAppRuntime.start();
    stream1.send(new Object[] { "WSO2", 15.6f, 100 });
    Thread.sleep(100);
    stream2.send(new Object[] { "IBM", 28.7f, 100 });
    Thread.sleep(100);
    stream3.send(new Object[] { "GOOGLE", 38.7f, 100 });
    Thread.sleep(1100);
    stream4.send(new Object[] { "ORACLE", 44.7f, 100 });
    Thread.sleep(100);
    callback.throwAssertionErrors();
    AssertJUnit.assertEquals("Number of success events", 0, callback.getInEventCount());
    AssertJUnit.assertEquals("Number of remove events", 0, callback.getRemoveEventCount());
    AssertJUnit.assertFalse("Event arrived", callback.isEventArrived());
    siddhiAppRuntime.shutdown();
}
Also used : InputHandler(org.wso2.siddhi.core.stream.input.InputHandler) TestUtil(org.wso2.siddhi.core.TestUtil) SiddhiAppRuntime(org.wso2.siddhi.core.SiddhiAppRuntime) SiddhiManager(org.wso2.siddhi.core.SiddhiManager) Test(org.testng.annotations.Test)

Example 72 with Not

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

the class AbsentSequenceTestCase method testQueryAbsent27.

@Test
public void testQueryAbsent27() throws InterruptedException {
    log.info("Test the query not e1, e2 without e1");
    SiddhiManager siddhiManager = new SiddhiManager();
    String streams = "" + "define stream Stream1 (symbol string, price float, volume int); " + "define stream Stream2 (symbol string, price float, volume int); ";
    String query = "" + "@info(name = 'query1') " + "from not Stream1[price>20] for 1 sec, e2=Stream2[price>30] " + "select e2.symbol as symbol " + "insert into OutputStream ;";
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(streams + query);
    TestUtil.TestCallback callback = TestUtil.addQueryCallback(siddhiAppRuntime, "query1");
    InputHandler stream2 = siddhiAppRuntime.getInputHandler("Stream2");
    siddhiAppRuntime.start();
    stream2.send(new Object[] { "IBM", 58.7f, 100 });
    Thread.sleep(100);
    callback.throwAssertionErrors();
    AssertJUnit.assertEquals("Number of success events", 0, callback.getInEventCount());
    AssertJUnit.assertEquals("Number of remove events", 0, callback.getRemoveEventCount());
    AssertJUnit.assertFalse("Event not arrived", callback.isEventArrived());
    siddhiAppRuntime.shutdown();
}
Also used : InputHandler(org.wso2.siddhi.core.stream.input.InputHandler) TestUtil(org.wso2.siddhi.core.TestUtil) SiddhiAppRuntime(org.wso2.siddhi.core.SiddhiAppRuntime) SiddhiManager(org.wso2.siddhi.core.SiddhiManager) Test(org.testng.annotations.Test)

Example 73 with Not

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

the class AbsentSequenceTestCase method testQueryAbsent24.

@Test
public void testQueryAbsent24() throws InterruptedException {
    log.info("Test the query not e1 for 1 sec, e2, not e3 for 1 sec, e4 with e2 after 1 sec e4");
    SiddhiManager siddhiManager = new SiddhiManager();
    String streams = "" + "define stream Stream1 (symbol string, price float, volume int); " + "define stream Stream2 (symbol string, price float, volume int); " + "define stream Stream3 (symbol string, price float, volume int); " + "define stream Stream4 (symbol string, price float, volume int); ";
    String query = "" + "@info(name = 'query1') " + "from not Stream1[price>10] for 1 sec, e2=Stream2[price>20], not Stream3[price>30] for 1 " + "sec, e4=Stream4[price>40] " + "select e2.symbol as symbol2, e4.symbol as symbol4 " + "insert into OutputStream ;";
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(streams + query);
    TestUtil.TestCallback callback = TestUtil.addQueryCallback(siddhiAppRuntime, "query1", new Object[] { "IBM", "ORACLE" });
    InputHandler stream2 = siddhiAppRuntime.getInputHandler("Stream2");
    InputHandler stream4 = siddhiAppRuntime.getInputHandler("Stream4");
    siddhiAppRuntime.start();
    Thread.sleep(1100);
    stream2.send(new Object[] { "IBM", 28.7f, 100 });
    Thread.sleep(1100);
    stream4.send(new Object[] { "ORACLE", 44.7f, 100 });
    Thread.sleep(100);
    callback.throwAssertionErrors();
    AssertJUnit.assertEquals("Number of success events", 1, callback.getInEventCount());
    AssertJUnit.assertEquals("Number of remove events", 0, callback.getRemoveEventCount());
    AssertJUnit.assertTrue("Event arrived", callback.isEventArrived());
    siddhiAppRuntime.shutdown();
}
Also used : InputHandler(org.wso2.siddhi.core.stream.input.InputHandler) TestUtil(org.wso2.siddhi.core.TestUtil) SiddhiAppRuntime(org.wso2.siddhi.core.SiddhiAppRuntime) SiddhiManager(org.wso2.siddhi.core.SiddhiManager) Test(org.testng.annotations.Test)

Example 74 with Not

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

the class AbsentSequenceTestCase method testQueryAbsent23.

@Test
public void testQueryAbsent23() throws InterruptedException {
    log.info("Test the query not e1 for 1 sec, e2, e3, e4 with e1, e2, e3, and e4");
    SiddhiManager siddhiManager = new SiddhiManager();
    String streams = "" + "define stream Stream1 (symbol string, price float, volume int); " + "define stream Stream2 (symbol string, price float, volume int); " + "define stream Stream3 (symbol string, price float, volume int); " + "define stream Stream4 (symbol string, price float, volume int); ";
    String query = "" + "@info(name = 'query1') " + "from not Stream1[price>10] for 1 sec, e2=Stream2[price>20], e3=Stream3[price>30], " + "e4=Stream4[price>40] " + "select e2.symbol as symbol2, e3.symbol as symbol3, e4.symbol as symbol4 " + "insert into OutputStream ;";
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(streams + query);
    TestUtil.TestCallback callback = TestUtil.addQueryCallback(siddhiAppRuntime, "query1");
    InputHandler stream1 = siddhiAppRuntime.getInputHandler("Stream1");
    InputHandler stream2 = siddhiAppRuntime.getInputHandler("Stream2");
    InputHandler stream3 = siddhiAppRuntime.getInputHandler("Stream3");
    InputHandler stream4 = siddhiAppRuntime.getInputHandler("Stream4");
    siddhiAppRuntime.start();
    stream1.send(new Object[] { "WSO2", 15.6f, 100 });
    Thread.sleep(100);
    stream2.send(new Object[] { "IBM", 28.7f, 100 });
    Thread.sleep(100);
    stream3.send(new Object[] { "GOOGLE", 38.7f, 100 });
    Thread.sleep(100);
    stream4.send(new Object[] { "ORACLE", 44.7f, 100 });
    Thread.sleep(100);
    callback.throwAssertionErrors();
    AssertJUnit.assertEquals("Number of success events", 0, callback.getInEventCount());
    AssertJUnit.assertEquals("Number of remove events", 0, callback.getRemoveEventCount());
    AssertJUnit.assertFalse("Event arrived", callback.isEventArrived());
    siddhiAppRuntime.shutdown();
}
Also used : InputHandler(org.wso2.siddhi.core.stream.input.InputHandler) TestUtil(org.wso2.siddhi.core.TestUtil) SiddhiAppRuntime(org.wso2.siddhi.core.SiddhiAppRuntime) SiddhiManager(org.wso2.siddhi.core.SiddhiManager) Test(org.testng.annotations.Test)

Example 75 with Not

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

the class AbsentSequenceTestCase method testQueryAbsent18.

@Test
public void testQueryAbsent18() throws InterruptedException {
    log.info("Test the query not e1 for 1 sec, e2, e3 with e1, e2 after 1 sec and e3");
    SiddhiManager siddhiManager = new SiddhiManager();
    String streams = "" + "define stream Stream1 (symbol string, price float, volume int); " + "define stream Stream2 (symbol string, price float, volume int); " + "define stream Stream3 (symbol string, price float, volume int); ";
    String query = "" + "@info(name = 'query1') " + "from not Stream1[price>10] for 1 sec, e2=Stream2[price>20], e3=Stream3[price>30] " + "select e2.symbol as symbol2, e3.symbol as symbol3 " + "insert into OutputStream ;";
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(streams + query);
    TestUtil.TestCallback callback = TestUtil.addQueryCallback(siddhiAppRuntime, "query1");
    InputHandler stream1 = siddhiAppRuntime.getInputHandler("Stream1");
    InputHandler stream2 = siddhiAppRuntime.getInputHandler("Stream2");
    InputHandler stream3 = siddhiAppRuntime.getInputHandler("Stream3");
    siddhiAppRuntime.start();
    stream1.send(new Object[] { "WSO2", 25.6f, 100 });
    Thread.sleep(1100);
    stream2.send(new Object[] { "IBM", 28.7f, 100 });
    Thread.sleep(100);
    stream3.send(new Object[] { "GOOGLE", 55.7f, 100 });
    Thread.sleep(100);
    callback.throwAssertionErrors();
    AssertJUnit.assertEquals("Number of success events", 0, callback.getInEventCount());
    AssertJUnit.assertEquals("Number of remove events", 0, callback.getRemoveEventCount());
    AssertJUnit.assertFalse("Event arrived", callback.isEventArrived());
    siddhiAppRuntime.shutdown();
}
Also used : InputHandler(org.wso2.siddhi.core.stream.input.InputHandler) TestUtil(org.wso2.siddhi.core.TestUtil) SiddhiAppRuntime(org.wso2.siddhi.core.SiddhiAppRuntime) SiddhiManager(org.wso2.siddhi.core.SiddhiManager) Test(org.testng.annotations.Test)

Aggregations

Test (org.testng.annotations.Test)579 SiddhiManager (org.wso2.siddhi.core.SiddhiManager)336 SiddhiAppRuntime (org.wso2.siddhi.core.SiddhiAppRuntime)334 InputHandler (org.wso2.siddhi.core.stream.input.InputHandler)334 TestUtil (org.wso2.siddhi.core.TestUtil)300 APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)171 HTTPCarbonMessage (org.wso2.transport.http.netty.message.HTTPCarbonMessage)157 HTTPTestRequest (org.ballerinalang.test.services.testutils.HTTPTestRequest)151 HashMap (java.util.HashMap)121 ErrorDTO (org.wso2.carbon.apimgt.rest.api.common.dto.ErrorDTO)115 HttpMessageDataStreamer (org.wso2.transport.http.netty.message.HttpMessageDataStreamer)112 ArrayList (java.util.ArrayList)92 BJSON (org.ballerinalang.model.values.BJSON)88 APIPublisher (org.wso2.carbon.apimgt.core.api.APIPublisher)63 IOException (java.io.IOException)62 APIMgtDAOException (org.wso2.carbon.apimgt.core.exception.APIMgtDAOException)58 Map (java.util.Map)47 APIStore (org.wso2.carbon.apimgt.core.api.APIStore)45 File (java.io.File)37 Response (javax.ws.rs.core.Response)37