Search in sources :

Example 81 with Attribute

use of org.wso2.balana.ctx.Attribute in project siddhi by wso2.

the class EventTestCase method testConditionExpressionExecutorValidation.

@Test(expectedExceptions = OperationNotSupportedException.class)
public void testConditionExpressionExecutorValidation() {
    // StreamDefinition streamDefinition = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute
    // .Type.STRING).attribute("price", Attribute.Type.FLOAT).attribute("volume", Attribute.Type.INT);
    VariableExpressionExecutor volumeVariableExpressionExecutor = new VariableExpressionExecutor(new Attribute("volume", Attribute.Type.INT), 0, 0);
    volumeVariableExpressionExecutor.setPosition(new int[] { 0, SiddhiConstants.UNKNOWN_STATE, SiddhiConstants.OUTPUT_DATA_INDEX, 2 });
    ConstantExpressionExecutor constantExpressionExecutor = new ConstantExpressionExecutor(10f, Attribute.Type.FLOAT);
    ExpressionExecutor compareGreaterThanExecutor = new GreaterThanCompareConditionExpressionExecutorIntInt(new ConstantExpressionExecutor(10, Attribute.Type.INT), volumeVariableExpressionExecutor);
    ExpressionExecutor andExecutor = new AndConditionExpressionExecutor(constantExpressionExecutor, compareGreaterThanExecutor);
}
Also used : VariableExpressionExecutor(org.wso2.siddhi.core.executor.VariableExpressionExecutor) AndConditionExpressionExecutor(org.wso2.siddhi.core.executor.condition.AndConditionExpressionExecutor) ConstantExpressionExecutor(org.wso2.siddhi.core.executor.ConstantExpressionExecutor) ExpressionExecutor(org.wso2.siddhi.core.executor.ExpressionExecutor) Attribute(org.wso2.siddhi.query.api.definition.Attribute) VariableExpressionExecutor(org.wso2.siddhi.core.executor.VariableExpressionExecutor) GreaterThanCompareConditionExpressionExecutorIntInt(org.wso2.siddhi.core.executor.condition.compare.greaterthan.GreaterThanCompareConditionExpressionExecutorIntInt) ConstantExpressionExecutor(org.wso2.siddhi.core.executor.ConstantExpressionExecutor) AndConditionExpressionExecutor(org.wso2.siddhi.core.executor.condition.AndConditionExpressionExecutor) Test(org.testng.annotations.Test)

Example 82 with Attribute

use of org.wso2.balana.ctx.Attribute in project siddhi by wso2.

the class DefineStreamTestCase method testCreatingStreamDefinition.

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

Example 83 with Attribute

use of org.wso2.balana.ctx.Attribute in project siddhi by wso2.

the class DefineTableTestCase method test4.

@Test
public void test4() throws SiddhiParserException {
    TableDefinition streamDefinition = SiddhiCompiler.parseTableDefinition("" + " @from(datasource='MyDatabase','CUSTOM')" + " define table cseStream ( symbol string, price int, volume float )");
    AssertJUnit.assertEquals(TableDefinition.id("cseStream").attribute("symbol", Attribute.Type.STRING).attribute("price", Attribute.Type.INT).attribute("volume", Attribute.Type.FLOAT).annotation(Annotation.annotation("from").element("datasource", "MyDatabase").element("CUSTOM")).toString(), streamDefinition.toString());
}
Also used : TableDefinition(org.wso2.siddhi.query.api.definition.TableDefinition) Test(org.testng.annotations.Test)

Example 84 with Attribute

use of org.wso2.balana.ctx.Attribute in project siddhi by wso2.

the class DefineTableTestCase method test2.

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

Example 85 with Attribute

use of org.wso2.balana.ctx.Attribute in project siddhi by wso2.

the class DefineTableTestCase method test1.

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

Aggregations

Test (org.testng.annotations.Test)152 ArrayList (java.util.ArrayList)137 HashMap (java.util.HashMap)112 StreamDefinition (org.wso2.siddhi.query.api.definition.StreamDefinition)103 SimpleAttribute (org.wso2.charon3.core.attributes.SimpleAttribute)99 ComplexAttribute (org.wso2.charon3.core.attributes.ComplexAttribute)94 SiddhiAppRuntime (org.wso2.siddhi.core.SiddhiAppRuntime)89 SiddhiManager (org.wso2.siddhi.core.SiddhiManager)89 Event (org.wso2.siddhi.core.event.Event)85 InputHandler (org.wso2.siddhi.core.stream.input.InputHandler)83 SiddhiApp (org.wso2.siddhi.query.api.SiddhiApp)83 Query (org.wso2.siddhi.query.api.execution.query.Query)83 MultiValuedAttribute (org.wso2.charon3.core.attributes.MultiValuedAttribute)82 Attribute (org.wso2.charon3.core.attributes.Attribute)73 QueryCallback (org.wso2.siddhi.core.query.output.callback.QueryCallback)73 CharonException (org.wso2.charon3.core.exceptions.CharonException)68 Map (java.util.Map)66 BadRequestException (org.wso2.charon3.core.exceptions.BadRequestException)62 OMAttribute (org.apache.axiom.om.OMAttribute)51 List (java.util.List)50