Search in sources :

Example 16 with SiddhiParserException

use of org.wso2.siddhi.query.compiler.exception.SiddhiParserException in project siddhi by wso2.

the class DefineStreamTestCase method test1.

@Test
public void test1() throws SiddhiParserException {
    StreamDefinition streamDefinition = SiddhiCompiler.parseStreamDefinition("define stream cseStream ( symbol " + "string, price int, volume float )");
    AssertJUnit.assertEquals(StreamDefinition.id("cseStream").attribute("symbol", Attribute.Type.STRING).attribute("price", Attribute.Type.INT).attribute("volume", Attribute.Type.FLOAT).toString(), streamDefinition.toString());
}
Also used : StreamDefinition(org.wso2.siddhi.query.api.definition.StreamDefinition) Test(org.testng.annotations.Test)

Example 17 with SiddhiParserException

use of org.wso2.siddhi.query.compiler.exception.SiddhiParserException in project siddhi by wso2.

the class DefineStreamTestCase method testMultilevelNestedAnnotations1.

@Test
public void testMultilevelNestedAnnotations1() throws SiddhiParserException {
    StreamDefinition streamDefinition = SiddhiCompiler.parseStreamDefinition("@sink(url='http://foo.com/test/{{data}}', " + "   @map(type='xml', " + "@payload('<test><time>{{time}}</time></test>')" + "   )" + ") " + "define stream fooStream (id int, name string);");
    AssertJUnit.assertEquals(StreamDefinition.id("fooStream").attribute("id", Attribute.Type.INT).attribute("name", Attribute.Type.STRING).annotation(Annotation.annotation("sink").element("url", "http://foo.com/test/{{data}}").annotation(Annotation.annotation("map").element("type", "xml").annotation(Annotation.annotation("payload").element("<test><time>{{time}}</time></test>")))), streamDefinition);
}
Also used : StreamDefinition(org.wso2.siddhi.query.api.definition.StreamDefinition) Test(org.testng.annotations.Test)

Example 18 with SiddhiParserException

use of org.wso2.siddhi.query.compiler.exception.SiddhiParserException in project siddhi by wso2.

the class DefineStreamTestCase method test2.

@Test
public void test2() throws SiddhiParserException {
    StreamDefinition streamDefinition = SiddhiCompiler.parseStreamDefinition("define stream `define` ( `string` " + "string, price int, volume float );");
    AssertJUnit.assertEquals(StreamDefinition.id("define").attribute("string", Attribute.Type.STRING).attribute("price", Attribute.Type.INT).attribute("volume", Attribute.Type.FLOAT).toString(), streamDefinition.toString());
}
Also used : StreamDefinition(org.wso2.siddhi.query.api.definition.StreamDefinition) Test(org.testng.annotations.Test)

Example 19 with SiddhiParserException

use of org.wso2.siddhi.query.compiler.exception.SiddhiParserException in project siddhi by wso2.

the class DefineStreamTestCase method testEqualObjects.

@Test
public void testEqualObjects() throws SiddhiParserException {
    StreamDefinition streamDefinition = SiddhiCompiler.parseStreamDefinition("@Foo(name='bar','Custom')define " + "stream cseStream ( symbol string, price int, volume float )");
    AssertJUnit.assertEquals(StreamDefinition.id("cseStream").attribute("symbol", Attribute.Type.STRING).attribute("price", Attribute.Type.INT).attribute("volume", Attribute.Type.FLOAT).annotation(Annotation.annotation("Foo").element("name", "bar").element("Custom")), streamDefinition);
}
Also used : StreamDefinition(org.wso2.siddhi.query.api.definition.StreamDefinition) Test(org.testng.annotations.Test)

Example 20 with SiddhiParserException

use of org.wso2.siddhi.query.compiler.exception.SiddhiParserException in project siddhi by wso2.

the class DefineStreamTestCase method testMultilevelNestedAnnotations2.

@Test
public void testMultilevelNestedAnnotations2() throws SiddhiParserException {
    StreamDefinition streamDefinition = SiddhiCompiler.parseStreamDefinition("" + "@source(" + "   type='http', " + "   context='/test', " + "   transport='http,https', " + "   @map(" + "       type='xml', " + "       namespace = \"h=uri, a=uri\", " + "       @attributes(" + "           '//h:time', " + "           '//h:data'" + "       )" + "   )" + ") " + "define stream fooStream (id int, name string);");
    AssertJUnit.assertEquals(StreamDefinition.id("fooStream").attribute("id", Attribute.Type.INT).attribute("name", Attribute.Type.STRING).annotation(Annotation.annotation("source").element("type", "http").element("context", "/test").element("transport", "http,https").annotation(Annotation.annotation("map").element("type", "xml").element("namespace", "h=uri, a=uri").annotation(Annotation.annotation("attributes").element("//h:time").element("//h:data")))), streamDefinition);
}
Also used : StreamDefinition(org.wso2.siddhi.query.api.definition.StreamDefinition) Test(org.testng.annotations.Test)

Aggregations

Test (org.testng.annotations.Test)21 Query (org.wso2.siddhi.query.api.execution.query.Query)11 ANTLRInputStream (org.antlr.v4.runtime.ANTLRInputStream)7 CommonTokenStream (org.antlr.v4.runtime.CommonTokenStream)7 ParseTree (org.antlr.v4.runtime.tree.ParseTree)7 SiddhiQLBaseVisitorImpl (org.wso2.siddhi.query.compiler.internal.SiddhiQLBaseVisitorImpl)7 StreamDefinition (org.wso2.siddhi.query.api.definition.StreamDefinition)5 TableDefinition (org.wso2.siddhi.query.api.definition.TableDefinition)5 AggregationDefinition (org.wso2.siddhi.query.api.definition.AggregationDefinition)3 StoreQuery (org.wso2.siddhi.query.api.execution.query.StoreQuery)3 Partition (org.wso2.siddhi.query.api.execution.partition.Partition)2 TimeConstant (org.wso2.siddhi.query.api.expression.constant.TimeConstant)2 ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)1 ArrayList (java.util.ArrayList)1 SiddhiAppContext (org.wso2.siddhi.core.config.SiddhiAppContext)1 SiddhiAppCreationException (org.wso2.siddhi.core.exception.SiddhiAppCreationException)1 PartitionRuntime (org.wso2.siddhi.core.partition.PartitionRuntime)1 QueryRuntime (org.wso2.siddhi.core.query.QueryRuntime)1 ElementIdGenerator (org.wso2.siddhi.core.util.ElementIdGenerator)1 SiddhiAppRuntimeBuilder (org.wso2.siddhi.core.util.SiddhiAppRuntimeBuilder)1