use of org.wso2.siddhi.query.api.expression.constant.Constant in project siddhi by wso2.
the class SetUpdateOrInsertInMemoryTableTestCase method updateFromTableTest3.
@Test
public void updateFromTableTest3() throws InterruptedException, SQLException {
log.info("SET-InMemory-update-or-insert test case 3: using a constant value as the assigment expression.");
SiddhiManager siddhiManager = new SiddhiManager();
String streams = "" + "define stream StockStream (symbol string, price float, volume long); " + "define stream UpdateStockStream (symbol string, price float, volume long); " + "define table StockTable (symbol string, price float, volume long); ";
String query = "" + "@info(name = 'query1') " + "from StockStream " + "insert into StockTable ;" + "" + "@info(name = 'query2') " + "from UpdateStockStream " + "update or insert into StockTable " + "set StockTable.price = 10 " + " on StockTable.symbol == symbol ;";
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(streams + query);
InputHandler stockStream = siddhiAppRuntime.getInputHandler("StockStream");
InputHandler updateStockStream = siddhiAppRuntime.getInputHandler("UpdateStockStream");
siddhiAppRuntime.start();
stockStream.send(new Object[] { "WSO2", 55.6f, 100L });
stockStream.send(new Object[] { "IBM", 75.6f, 100L });
stockStream.send(new Object[] { "WSO2", 57.6f, 100L });
updateStockStream.send(new Object[] { "IBM", 100f, 100L });
Thread.sleep(1000);
siddhiAppRuntime.shutdown();
}
use of org.wso2.siddhi.query.api.expression.constant.Constant in project ballerina by ballerina-lang.
the class DocumentationTest method testDocConstant.
@Test(description = "Test doc constant.")
public void testDocConstant() {
CompileResult compileResult = BCompileUtil.compile("test-src/documentation/constant.bal");
Assert.assertEquals(0, compileResult.getWarnCount());
PackageNode packageNode = compileResult.getAST();
List<BLangDocumentation> docNodes = ((BLangVariable) packageNode.getGlobalVariables().get(0)).docAttachments;
BLangDocumentation dNode = docNodes.get(0);
Assert.assertNotNull(dNode);
Assert.assertEquals(dNode.documentationText, " Documentation for testConst constant\n");
Assert.assertEquals(dNode.getAttributes().size(), 1);
Assert.assertEquals(dNode.getAttributes().get(0).documentationField.getValue(), "testConst");
Assert.assertEquals(dNode.getAttributes().get(0).documentationText, " constant variable `testConst`");
}
use of org.wso2.siddhi.query.api.expression.constant.Constant in project ballerina by ballerina-lang.
the class DocumentationTest method testInlineCodeEnclosedTripleBackTicks.
@Test(description = "Test doc inline code with triple backtics.")
public void testInlineCodeEnclosedTripleBackTicks() {
CompileResult compileResult = BCompileUtil.compile("test-src/documentation/doc_inline_triple.bal");
Assert.assertEquals(0, compileResult.getWarnCount());
PackageNode packageNode = compileResult.getAST();
BLangVariable constant = (BLangVariable) packageNode.getGlobalVariables().get(0);
List<BLangDocumentation> docNodes = constant.docAttachments;
BLangDocumentation dNode = docNodes.get(0);
Assert.assertNotNull(dNode);
Assert.assertEquals(dNode.getAttributes().size(), 0);
Assert.assertEquals(dNode.documentationText, "\n" + " Example of a string template:\n" + " ```string s = string `hello {{name}}`;```\n" + "\n" + " Example for an xml literal:\n" + " ```xml x = xml `<{{tagName}}>hello</{{tagName}}>`;```\n");
}
use of org.wso2.siddhi.query.api.expression.constant.Constant in project ballerina by ballerina-lang.
the class DocumentationTest method testNestedInline.
@Test(description = "Test doc nested inline.")
public void testNestedInline() {
CompileResult compileResult = BCompileUtil.compile("test-src/documentation/nested_inline.bal");
Assert.assertEquals(0, compileResult.getWarnCount());
PackageNode packageNode = compileResult.getAST();
BLangVariable constant = (BLangVariable) packageNode.getGlobalVariables().get(0);
List<BLangDocumentation> docNodes = constant.docAttachments;
BLangDocumentation dNode = docNodes.get(0);
Assert.assertNotNull(dNode);
Assert.assertEquals(dNode.getAttributes().size(), 0);
Assert.assertEquals(dNode.documentationText, "\n" + " Example of a string template:\n" + " ``` This starts ends triple backtick ``string s = string `hello {{name}}`;`` " + "ends triple backtick```\n" + "\n" + " Example for an xml literal:\n" + " ``xml x = xml `<{{tagName}}>hello</{{tagName}}>`;``\n");
}
use of org.wso2.siddhi.query.api.expression.constant.Constant in project ballerina by ballerina-lang.
the class ServiceTest method testConstantValueAsAnnAttributeVal.
@Test(description = "Test using constant as annotation attribute value")
public void testConstantValueAsAnnAttributeVal() {
HTTPTestRequest requestMsg = MessageUtils.generateHTTPMessage("/echo/constantPath", "GET");
HTTPCarbonMessage responseMsg = Services.invokeNew(compileResult, TEST_ENDPOINT_NAME, requestMsg);
Assert.assertNotNull(responseMsg);
String responseMsgPayload = StringUtils.getStringFromInputStream(new HttpMessageDataStreamer(responseMsg).getInputStream());
StringDataSource stringDataSource = new StringDataSource(responseMsgPayload);
Assert.assertNotNull(stringDataSource);
Assert.assertEquals(stringDataSource.getValue(), "constant path test");
}
Aggregations