Search in sources :

Example 46 with SiddhiAppCreationException

use of io.siddhi.core.exception.SiddhiAppCreationException in project siddhi by wso2.

the class SessionWindowTestCase method testSessionWindow8.

@Test(description = "This test checks if Siddhi App creation fails when" + " provided 2 paramters and 2nd parameter with wrong data type", expectedExceptions = SiddhiAppCreationException.class)
public void testSessionWindow8() {
    log.info("SessionWindow Test8: Testing session window " + "with providing 2 parameters and 2nd parameter type is wrong");
    SiddhiManager siddhiManager = new SiddhiManager();
    SiddhiAppRuntime siddhiAppRuntime = null;
    String purchaseEventStream = "" + "define stream purchaseEventStream (user string, item_number int, price float, quantity int);";
    String query = "" + "@info(name = 'query0') " + "from purchaseEventStream#window.session(5 sec, item_number) " + "select * " + "insert all events into outputStream ;";
    try {
        siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(purchaseEventStream + query);
    } catch (SiddhiAppCreationException e) {
        AssertJUnit.assertEquals("There is no parameterOverload for 'session' that matches attribute types" + " '<LONG, INT>'. Supported parameter overloads are (<INT|LONG|TIME> session.gap), " + "(<INT|LONG|TIME> session.gap, <STRING> session.key), (<INT|LONG|TIME> session.gap, " + "<STRING> session.key, <INT|LONG|TIME> allowed.latency).", e.getCause().getMessage());
        throw e;
    } finally {
        if (siddhiAppRuntime != null) {
            siddhiAppRuntime.shutdown();
        }
    }
}
Also used : SiddhiAppCreationException(io.siddhi.core.exception.SiddhiAppCreationException) SiddhiAppRuntime(io.siddhi.core.SiddhiAppRuntime) SiddhiManager(io.siddhi.core.SiddhiManager) Test(org.testng.annotations.Test)

Example 47 with SiddhiAppCreationException

use of io.siddhi.core.exception.SiddhiAppCreationException in project siddhi by wso2.

the class SessionWindowTestCase method testSessionWindow1.

@Test(description = "This test checks if Siddhi App creation fails when more than three parameters are provided'", expectedExceptions = SiddhiAppCreationException.class)
public void testSessionWindow1() {
    log.info("SessionWindow Test1: Testing session window with more than defined parameters");
    SiddhiManager siddhiManager = new SiddhiManager();
    SiddhiAppRuntime siddhiAppRuntime = null;
    String purchaseEventStream = "" + "define stream purchaseEventStream (user string, item_number int, price float, quantity int);";
    String query = "" + "@info(name = 'query0') " + "from purchaseEventStream#window.session(5 sec, user, 2 sec, 1) " + "select * " + "insert all events into outputStream ;";
    try {
        siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(purchaseEventStream + query);
    } catch (SiddhiAppCreationException e) {
        AssertJUnit.assertEquals("There is no parameterOverload for 'session' that matches attribute types " + "'<LONG, STRING, LONG, INT>'. Supported parameter overloads are " + "(<INT|LONG|TIME> session.gap), " + "(<INT|LONG|TIME> session.gap, <STRING> session.key), (<INT|LONG|TIME> session.gap, " + "<STRING> session.key, <INT|LONG|TIME> allowed.latency).", e.getCause().getMessage());
        throw e;
    } finally {
        if (siddhiAppRuntime != null) {
            siddhiAppRuntime.shutdown();
        }
    }
}
Also used : SiddhiAppCreationException(io.siddhi.core.exception.SiddhiAppCreationException) SiddhiAppRuntime(io.siddhi.core.SiddhiAppRuntime) SiddhiManager(io.siddhi.core.SiddhiManager) Test(org.testng.annotations.Test)

Example 48 with SiddhiAppCreationException

use of io.siddhi.core.exception.SiddhiAppCreationException in project siddhi by wso2.

the class SessionWindowTestCase method testSessionWindow4.

@Test(description = "This test checks if Siddhi App creation fails " + "when session key parameter with a constant value", expectedExceptions = SiddhiAppCreationException.class)
public void testSessionWindow4() {
    log.info("SessionWindow Test4: Testing session window " + "with providing a constant value for session key parameter ");
    SiddhiManager siddhiManager = new SiddhiManager();
    SiddhiAppRuntime siddhiAppRuntime = null;
    String purchaseEventStream = "" + "define stream purchaseEventStream (user string, item_number int, price float, quantity int);";
    String query = "" + "@info(name = 'query0') " + "from purchaseEventStream#window.session(5 sec, 'user', 2 sec) " + "select * " + "insert all events into outputStream ;";
    try {
        siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(purchaseEventStream + query);
    } catch (SiddhiAppCreationException e) {
        AssertJUnit.assertEquals("Session window's 2nd parameter, session key should be a " + "dynamic parameter attribute but found a constant attribute " + "io.siddhi.core.executor.ConstantExpressionExecutor", e.getCause().getMessage());
        throw e;
    } finally {
        if (siddhiAppRuntime != null) {
            siddhiAppRuntime.shutdown();
        }
    }
}
Also used : SiddhiAppCreationException(io.siddhi.core.exception.SiddhiAppCreationException) SiddhiAppRuntime(io.siddhi.core.SiddhiAppRuntime) SiddhiManager(io.siddhi.core.SiddhiManager) Test(org.testng.annotations.Test)

Example 49 with SiddhiAppCreationException

use of io.siddhi.core.exception.SiddhiAppCreationException in project siddhi by wso2.

the class SessionWindowTestCase method testSessionWindow7.

@Test(description = "This test checks if Siddhi App creation fails when" + " allowedLatency parameter with a wrong data type", expectedExceptions = SiddhiAppCreationException.class)
public void testSessionWindow7() {
    log.info("SessionWindow Test7: Testing session window " + "with providing wrong data type for allowedLatency");
    SiddhiManager siddhiManager = new SiddhiManager();
    SiddhiAppRuntime siddhiAppRuntime = null;
    String purchaseEventStream = "" + "define stream purchaseEventStream (user string, item_number int, price float, quantity int);";
    String query = "" + "@info(name = 'query0') " + "from purchaseEventStream#window.session(5 sec, user, '4') " + "select * " + "insert all events into outputStream ;";
    try {
        siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(purchaseEventStream + query);
    } catch (SiddhiAppCreationException e) {
        AssertJUnit.assertEquals("There is no parameterOverload for 'session' that matches attribute " + "types '<LONG, STRING, STRING>'. Supported parameter overloads are " + "(<INT|LONG|TIME> session.gap), " + "(<INT|LONG|TIME> session.gap, <STRING> session.key), " + "(<INT|LONG|TIME> session.gap, <STRING> session.key, " + "<INT|LONG|TIME> allowed.latency).", e.getCause().getMessage());
        throw e;
    } finally {
        if (siddhiAppRuntime != null) {
            siddhiAppRuntime.shutdown();
        }
    }
}
Also used : SiddhiAppCreationException(io.siddhi.core.exception.SiddhiAppCreationException) SiddhiAppRuntime(io.siddhi.core.SiddhiAppRuntime) SiddhiManager(io.siddhi.core.SiddhiManager) Test(org.testng.annotations.Test)

Example 50 with SiddhiAppCreationException

use of io.siddhi.core.exception.SiddhiAppCreationException in project siddhi by wso2.

the class DelayWindowTestCase method delayWindowTest2.

@Test(description = "Check if Siddhi App Creation fails when the type of parameter is neither int or long", expectedExceptions = SiddhiAppCreationException.class)
public void delayWindowTest2() {
    log.info("DelayWindow Test2 : Testing window parameter definition3");
    SiddhiManager siddhiManager = new SiddhiManager();
    String query = "define window eventWindow(symbol string, price int, volume float) delay('abc') ";
    SiddhiAppRuntime siddhiAppRuntime = null;
    try {
        siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(query);
    } catch (SiddhiAppCreationException e) {
        error = false;
        AssertJUnit.assertEquals("There is no parameterOverload for 'delay' that matches attribute types " + "'<STRING>'. Supported parameter overloads are (<INT|LONG|TIME> window.delay).", e.getCause().getMessage());
        throw e;
    } finally {
        if (siddhiAppRuntime != null) {
            siddhiAppRuntime.shutdown();
        }
    }
}
Also used : SiddhiAppCreationException(io.siddhi.core.exception.SiddhiAppCreationException) SiddhiAppRuntime(io.siddhi.core.SiddhiAppRuntime) SiddhiManager(io.siddhi.core.SiddhiManager) Test(org.testng.annotations.Test)

Aggregations

SiddhiAppCreationException (io.siddhi.core.exception.SiddhiAppCreationException)54 Attribute (io.siddhi.query.api.definition.Attribute)23 VariableExpressionExecutor (io.siddhi.core.executor.VariableExpressionExecutor)16 MetaStreamEvent (io.siddhi.core.event.stream.MetaStreamEvent)15 SiddhiAppRuntime (io.siddhi.core.SiddhiAppRuntime)12 SiddhiManager (io.siddhi.core.SiddhiManager)12 ArrayList (java.util.ArrayList)12 Expression (io.siddhi.query.api.expression.Expression)11 MetaStateEvent (io.siddhi.core.event.state.MetaStateEvent)10 ConstantExpressionExecutor (io.siddhi.core.executor.ConstantExpressionExecutor)10 ExpressionExecutor (io.siddhi.core.executor.ExpressionExecutor)10 Annotation (io.siddhi.query.api.annotation.Annotation)10 Variable (io.siddhi.query.api.expression.Variable)10 ConfigReader (io.siddhi.core.util.config.ConfigReader)9 HashMap (java.util.HashMap)9 Test (org.testng.annotations.Test)9 Element (io.siddhi.query.api.annotation.Element)8 OutputAttribute (io.siddhi.query.api.execution.query.selection.OutputAttribute)8 Table (io.siddhi.core.table.Table)7 MatchingMetaInfoHolder (io.siddhi.core.util.collection.operator.MatchingMetaInfoHolder)7