use of org.ballerinalang.siddhi.query.api.execution.query.StoreQuery in project ballerina by ballerina-lang.
the class QueryStoreTestCase method test3.
@Test
public void test3() {
StoreQuery query = SiddhiCompiler.parseStoreQuery("" + "from StockTable " + "on price > 40 " + "select symbol, price " + "group by symbol " + "having (7 > price) ;");
AssertJUnit.assertNotNull(query);
StoreQuery api = StoreQuery.query().from(InputStore.store("StockTable").on(Expression.compare(Expression.variable("price"), Compare.Operator.GREATER_THAN, Expression.value(40)))).select(Selector.selector().select("symbol", Expression.variable("symbol")).select(Expression.variable("price")).groupBy(Expression.variable("symbol")).having(Expression.compare(Expression.value(7), Compare.Operator.GREATER_THAN, Expression.variable("price"))));
AssertJUnit.assertEquals(api, query);
}
use of org.ballerinalang.siddhi.query.api.execution.query.StoreQuery in project ballerina by ballerina-lang.
the class QueryStoreTestCase method test1.
@Test
public void test1() throws SiddhiParserException {
StoreQuery query = SiddhiCompiler.parseStoreQuery("" + "from StockTable " + "on price>3 " + "select symbol, avg(price) as avgPrice " + "group by symbol " + "having (price >= 20) ;");
AssertJUnit.assertNotNull(query);
StoreQuery api = StoreQuery.query().from(InputStore.store("StockTable").on(Expression.compare(Expression.variable("price"), Compare.Operator.GREATER_THAN, Expression.value(3)))).select(Selector.selector().select(Expression.variable("symbol")).select("avgPrice", Expression.function("avg", Expression.variable("price"))).groupBy(Expression.variable("symbol")).having(Expression.compare(Expression.variable("price"), Compare.Operator.GREATER_THAN_EQUAL, Expression.value(20))));
AssertJUnit.assertEquals(api, query);
}
Aggregations