use of io.siddhi.query.api.definition.FunctionDefinition in project siddhi by wso2.
the class DefineFunctionTestCase method testFunction1.
@Test
public void testFunction1() {
SiddhiApp siddhiApp = SiddhiApp.siddhiApp("test").defineFunction(new FunctionDefinition().id("foo").language("JS").type(Attribute.Type.STRING).body("return 'hello world!'"));
SiddhiApp siddhiApp1 = SiddhiApp.siddhiApp("test").defineFunction(new FunctionDefinition().id("foo").language("JS").type(Attribute.Type.STRING).body("return 'hello world!'"));
Assert.assertTrue(siddhiApp.getFunctionDefinitionMap().containsKey("foo"));
Assert.assertTrue(siddhiApp.equals(siddhiApp1));
Assert.assertEquals(siddhiApp.hashCode(), siddhiApp1.hashCode());
}
use of io.siddhi.query.api.definition.FunctionDefinition in project siddhi by wso2.
the class PartitionTestCase1 method testPartitionQuery47.
@Test(expectedExceptions = SiddhiAppValidationException.class)
public void testPartitionQuery47() {
log.info("Partition test47");
SiddhiApp siddhiApp = new SiddhiApp("plan47");
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(null));
}
use of io.siddhi.query.api.definition.FunctionDefinition in project siddhi by wso2.
the class SiddhiQLBaseVisitorImpl method visitDefinition_function.
@Override
public FunctionDefinition visitDefinition_function(@NotNull SiddhiQLParser.Definition_functionContext ctx) {
String functionName = (String) visitFunction_name(ctx.function_name());
String languageName = (String) visitLanguage_name(ctx.language_name());
Attribute.Type attributeType = (Attribute.Type) visit(ctx.attribute_type());
String functionBody = (String) visitFunction_body(ctx.function_body());
FunctionDefinition functionDefinition = new FunctionDefinition();
functionDefinition.id(functionName).language(languageName).type(attributeType).body(functionBody);
populateQueryContext(functionDefinition, ctx);
return functionDefinition;
}
Aggregations