use of io.siddhi.query.api.definition.FunctionDefinition in project siddhi by wso2.
the class PartitionTestCase1 method testPartitionQuery46.
@Test(expectedExceptions = SiddhiAppValidationException.class)
public void testPartitionQuery46() {
log.info("Partition test46");
SiddhiApp siddhiApp = new SiddhiApp("plan46");
StreamDefinition streamDefinition = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute.Type.STRING).attribute("price", Attribute.Type.FLOAT).attribute("volume", Attribute.Type.INT);
siddhiApp.defineStream(streamDefinition);
FunctionDefinition functionDefinition = null;
siddhiApp.defineFunction(functionDefinition);
}
use of io.siddhi.query.api.definition.FunctionDefinition in project siddhi by wso2.
the class PartitionTestCase1 method testPartitionQuery48.
@Test(expectedExceptions = SiddhiAppValidationException.class)
public void testPartitionQuery48() {
log.info("Partition test48");
SiddhiApp siddhiApp = new SiddhiApp("plan48");
StreamDefinition streamDefinition = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute.Type.STRING).attribute("price", Attribute.Type.FLOAT).attribute("volume", Attribute.Type.INT);
siddhiApp.defineStream(streamDefinition);
FunctionDefinition functionDefinition = new FunctionDefinition();
siddhiApp.defineFunction(functionDefinition.id("e1").type(null));
}
use of io.siddhi.query.api.definition.FunctionDefinition in project siddhi by wso2.
the class PartitionTestCase1 method testPartitionQuery49.
@Test(expectedExceptions = SiddhiAppValidationException.class)
public void testPartitionQuery49() {
log.info("Partition test49");
SiddhiApp siddhiApp = new SiddhiApp("plan49");
StreamDefinition streamDefinition = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute.Type.STRING).attribute("price", Attribute.Type.FLOAT).attribute("volume", Attribute.Type.INT);
siddhiApp.defineStream(streamDefinition);
FunctionDefinition functionDefinition = new FunctionDefinition();
siddhiApp.defineFunction(functionDefinition.id("e1").type(Attribute.Type.STRING).body(null));
}
use of io.siddhi.query.api.definition.FunctionDefinition in project siddhi by wso2.
the class SimpleQueryTestCase method testFunctionDefinition.
@Test
public void testFunctionDefinition() throws SiddhiParserException {
FunctionDefinition functionDefinition = SiddhiCompiler.parseFunctionDefinition("define function concatFn[javascript] return string " + "{var str1 = data[0];};");
AssertJUnit.assertEquals(functionDefinition.getId(), "concatFn");
AssertJUnit.assertEquals(functionDefinition.getBody(), "var str1 = data[0]");
AssertJUnit.assertEquals(functionDefinition.getLanguage(), "javascript");
AssertJUnit.assertEquals(functionDefinition.getReturnType(), Attribute.Type.STRING);
}
use of io.siddhi.query.api.definition.FunctionDefinition in project siddhi by wso2.
the class SiddhiCompiler method parseFunctionDefinition.
public static FunctionDefinition parseFunctionDefinition(String functionDefinition) throws SiddhiParserException {
CharStream input = CharStreams.fromString(functionDefinition);
SiddhiQLLexer lexer = new SiddhiQLLexer(input);
lexer.removeErrorListeners();
lexer.addErrorListener(SiddhiErrorListener.INSTANCE);
CommonTokenStream tokens = new CommonTokenStream(lexer);
SiddhiQLParser parser = new SiddhiQLParser(tokens);
parser.removeErrorListeners();
parser.addErrorListener(SiddhiErrorListener.INSTANCE);
ParseTree tree = parser.definition_function_final();
SiddhiQLVisitor eval = new SiddhiQLBaseVisitorImpl();
return (FunctionDefinition) eval.visit(tree);
}
Aggregations