Search in sources :

Example 86 with Remove

use of org.wso2.carbon.humantask.core.engine.commands.Remove in project siddhi by wso2.

the class LogicalAbsentPatternTestCase method testQueryAbsent15.

@Test(dependsOnMethods = { "testQueryAbsent14" })
public void testQueryAbsent15() throws InterruptedException {
    log.info("Test the query e1 -> not e2 for 1 sec or e3 with e1, e2 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 e1=Stream1[price>10] -> not Stream2[price>20] for 1 sec or e3=Stream3[price>30] " + "select e1.symbol as symbol1, e3.symbol as symbol3 " + "insert into OutputStream ;";
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(streams + query);
    TestUtil.TestCallback callback = TestUtil.addQueryCallback(siddhiAppRuntime, "query1", new Object[] { "WSO2", "GOOGLE" });
    InputHandler stream1 = siddhiAppRuntime.getInputHandler("Stream1");
    InputHandler stream2 = siddhiAppRuntime.getInputHandler("Stream2");
    InputHandler stream3 = siddhiAppRuntime.getInputHandler("Stream3");
    siddhiAppRuntime.start();
    stream1.send(new Object[] { "WSO2", 15.0f, 100 });
    Thread.sleep(100);
    stream2.send(new Object[] { "IBM", 25.0f, 100 });
    Thread.sleep(100);
    stream3.send(new Object[] { "GOOGLE", 35.0f, 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();
    Thread.sleep(2000);
}
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 87 with Remove

use of org.wso2.carbon.humantask.core.engine.commands.Remove in project siddhi by wso2.

the class LogicalAbsentPatternTestCase method testQueryAbsent63.

@Test(dependsOnMethods = { "testQueryAbsent62" })
public void testQueryAbsent63() throws InterruptedException {
    log.info("Test the query every (e1 and not e2 for 1 sec) -> e3 with only e3 after 2 seconds");
    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 every (e2=Stream2[price>20] and not Stream1[price>10] for 1 sec) -> " + "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 stream3 = siddhiAppRuntime.getInputHandler("Stream3");
    siddhiAppRuntime.start();
    Thread.sleep(1100);
    stream3.send(new Object[] { "WSO2", 35.0f, 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 88 with Remove

use of org.wso2.carbon.humantask.core.engine.commands.Remove in project siddhi by wso2.

the class LogicalAbsentPatternTestCase method testQueryAbsent31.

@Test(dependsOnMethods = { "testQueryAbsent30" })
public void testQueryAbsent31() throws InterruptedException {
    log.info("Test the query e1 -> (not e2 for 1 sec or not e3 for 1 sec) within 2 sec with e1 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 e1=Stream1[price>10] -> (not Stream2[price>20] for 1 sec or not Stream3[price>30] for 1 sec) " + "within 2 sec " + "select e1.symbol as symbol1 " + "insert into OutputStream ;";
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(streams + query);
    TestUtil.TestCallback callback = TestUtil.addQueryCallback(siddhiAppRuntime, "query1", new Object[] { "WSO2" });
    InputHandler stream1 = siddhiAppRuntime.getInputHandler("Stream1");
    InputHandler stream3 = siddhiAppRuntime.getInputHandler("Stream3");
    siddhiAppRuntime.start();
    stream1.send(new Object[] { "WSO2", 15.0f, 100 });
    Thread.sleep(100);
    stream3.send(new Object[] { "IBM", 35.0f, 102 });
    Thread.sleep(1100);
    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 89 with Remove

use of org.wso2.carbon.humantask.core.engine.commands.Remove in project siddhi by wso2.

the class LogicalAbsentPatternTestCase method testQueryAbsent6.

@Test(dependsOnMethods = { "testQueryAbsent5_2" })
public void testQueryAbsent6() throws InterruptedException {
    log.info("Test the query e1 -> not e2 for 1 sec and e3 with e1 and e3 within 1 sec");
    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 e1=Stream1[price>10] -> not Stream2[price>20] for 1 sec and e3=Stream3[price>30] " + "select e1.symbol as symbol1, 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 stream3 = siddhiAppRuntime.getInputHandler("Stream3");
    siddhiAppRuntime.start();
    stream1.send(new Object[] { "WSO2", 15.0f, 100 });
    Thread.sleep(100);
    stream3.send(new Object[] { "GOOGLE", 35.0f, 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 90 with Remove

use of org.wso2.carbon.humantask.core.engine.commands.Remove in project siddhi by wso2.

the class LogicalAbsentPatternTestCase method testQueryAbsent47.

@Test(dependsOnMethods = { "testQueryAbsent46" })
public void testQueryAbsent47() throws InterruptedException {
    log.info("Test the query every (not e1 for 1 sec or not e2 for 1 sec) -> e3 with two e3s");
    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 every (not Stream1[price>10] for 1 sec or not Stream2[price>20] for 1 sec) -> " + "e3=Stream3[price>30] " + "select e3.symbol as symbol " + "insert into OutputStream ;";
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(streams + query);
    TestUtil.TestCallback callback = TestUtil.addQueryCallback(siddhiAppRuntime, "query1", new Object[] { "WSO2" }, new Object[] { "WSO2" }, new Object[] { "IBM" }, new Object[] { "IBM" });
    InputHandler stream3 = siddhiAppRuntime.getInputHandler("Stream3");
    siddhiAppRuntime.start();
    Thread.sleep(1200);
    stream3.send(new Object[] { "WSO2", 35.0f, 100 });
    Thread.sleep(1200);
    stream3.send(new Object[] { "IBM", 55.0f, 100 });
    Thread.sleep(100);
    callback.throwAssertionErrors();
    AssertJUnit.assertEquals("Number of success events", 4, 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)

Aggregations

Test (org.testng.annotations.Test)624 SiddhiAppRuntime (org.wso2.siddhi.core.SiddhiAppRuntime)617 SiddhiManager (org.wso2.siddhi.core.SiddhiManager)617 InputHandler (org.wso2.siddhi.core.stream.input.InputHandler)617 Event (org.wso2.siddhi.core.event.Event)319 TestUtil (org.wso2.siddhi.core.TestUtil)298 QueryCallback (org.wso2.siddhi.core.query.output.callback.QueryCallback)254 ArrayList (java.util.ArrayList)73 StreamCallback (org.wso2.siddhi.core.stream.output.StreamCallback)65 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)52 HashMap (java.util.HashMap)34 Map (java.util.Map)22 JSONObject (org.json.simple.JSONObject)22 RegistryException (org.wso2.carbon.registry.core.exceptions.RegistryException)22 API (org.wso2.carbon.apimgt.api.model.API)17 List (java.util.List)15 APIIdentifier (org.wso2.carbon.apimgt.api.model.APIIdentifier)15 SubscribedAPI (org.wso2.carbon.apimgt.api.model.SubscribedAPI)15 HashSet (java.util.HashSet)14 GenericArtifactManager (org.wso2.carbon.governance.api.generic.GenericArtifactManager)14