Search in sources :

Example 51 with SiddhiAppCreationException

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

the class DelayWindowTestCase method delayWindowTest1.

@Test(description = "Check if Siddhi App Creation fails when more than one parameter is included", expectedExceptions = SiddhiAppCreationException.class)
public void delayWindowTest1() {
    log.info("DelayWindow Test1 : Testing window parameter definition2");
    SiddhiManager siddhiManager = new SiddhiManager();
    String query = "define window eventWindow(symbol string, price int, volume float) delay(2,3) ";
    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 " + "'<INT, INT>'. 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)

Example 52 with SiddhiAppCreationException

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

the class SessionWindowTestCase method testSessionWindow2.

@Test(description = "This test checks if Siddhi App creation fails when session gap parameter is dynamic", expectedExceptions = SiddhiAppCreationException.class)
public void testSessionWindow2() {
    log.info("SessionWindow Test2: Testing session window with providing session gap parameter as a dynamic one");
    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(item_number, user, 2 sec) " + "select * " + "insert all events into outputStream ;";
    try {
        siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(purchaseEventStream + query);
    } catch (SiddhiAppCreationException e) {
        AssertJUnit.assertEquals("The 'session' expects input parameter 'session.gap' at position '0' " + "to be static, but found a dynamic attribute.", 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 53 with SiddhiAppCreationException

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

the class SessionWindowTestCase method testSessionWindow9.

@Test(description = "This test checks if Siddhi App creation fails when" + " provided 2 paramters and 2nd parameter allowedLatency with wrong data type", expectedExceptions = SiddhiAppCreationException.class)
public void testSessionWindow9() {
    log.info("SessionWindow Test9: Testing session window " + "with providing 2 parameters and 2nd parameter allowedLatency 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, '5') " + "select * " + "insert all events into outputStream ;";
    try {
        siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(purchaseEventStream + query);
    } catch (SiddhiAppCreationException e) {
        AssertJUnit.assertEquals("Session window's allowedLatency parameter should be either int or long," + " but found STRING", 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 54 with SiddhiAppCreationException

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

the class SessionWindowTestCase method testSessionWindow6.

@Test(description = "This test checks if Siddhi App creation fails when" + " allowedLatency parameter with a dynamic value", expectedExceptions = SiddhiAppCreationException.class)
public void testSessionWindow6() {
    log.info("SessionWindow Test6: Testing session window " + "with providing dynamic value 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, item_number) " + "select * " + "insert all events into outputStream ;";
    try {
        siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(purchaseEventStream + query);
    } catch (SiddhiAppCreationException e) {
        AssertJUnit.assertEquals("The 'session' expects input parameter 'allowed.latency' at position " + "'2' to be static, but found a dynamic attribute.", 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