use of com.haulmont.cuba.core.sys.jpql.antlr2.JPA2Lexer in project cuba by cuba-platform.
the class Jpa2GrammarTest method testEscape.
@Test
public void testEscape() throws Exception {
String query = "c.name like :pattern escape '/'";
CharStream cs = new AntlrNoCaseStringStream(query);
JPA2Lexer lexer = new JPA2Lexer(cs);
TokenStream tstream = new CommonTokenStream(lexer);
JPA2Parser jpa2Parser = new JPA2Parser(tstream);
JPA2Parser.like_expression_return aReturn = jpa2Parser.like_expression();
Assert.assertNotNull(aReturn);
query = "c.name like :pattern escape '.'";
cs = new AntlrNoCaseStringStream(query);
lexer = new JPA2Lexer(cs);
tstream = new CommonTokenStream(lexer);
jpa2Parser = new JPA2Parser(tstream);
aReturn = jpa2Parser.like_expression();
Assert.assertTrue(isValid((CommonTree) aReturn.getTree()));
}
use of com.haulmont.cuba.core.sys.jpql.antlr2.JPA2Lexer in project cuba by cuba-platform.
the class Jpa2GrammarTest method testUpdate.
@Test
public void testUpdate() throws Exception {
String query = "update sec$User u set u.group = :group where u.id = :userId";
CharStream cs = new AntlrNoCaseStringStream(query);
JPA2Lexer lexer = new JPA2Lexer(cs);
TokenStream tstream = new CommonTokenStream(lexer);
JPA2Parser jpa2Parser = new JPA2Parser(tstream);
JPA2Parser.update_statement_return aReturn = jpa2Parser.update_statement();
Assert.assertTrue(isValid((CommonTree) aReturn.getTree()));
}
use of com.haulmont.cuba.core.sys.jpql.antlr2.JPA2Lexer in project cuba by cuba-platform.
the class Jpa2GrammarTest method testTypeField.
@Test
public void testTypeField() throws Exception {
String query = "where e.model.type = :component$filter.model_type89015";
CharStream cs = new AntlrNoCaseStringStream(query);
JPA2Lexer lexer = new JPA2Lexer(cs);
TokenStream tstream = new CommonTokenStream(lexer);
JPA2Parser jpa2Parser = new JPA2Parser(tstream);
JPA2Parser.where_clause_return aReturn = jpa2Parser.where_clause();
Assert.assertTrue(isValid((CommonTree) aReturn.getTree()));
}
use of com.haulmont.cuba.core.sys.jpql.antlr2.JPA2Lexer in project cuba by cuba-platform.
the class Jpa2GrammarTest method testMemberOf.
@Test
@Ignore
public void testMemberOf() throws Exception {
String query = "where p.owner.id = :userParam or (select u from tamsy$User u where u.id = :userParam) member of p.developers";
CharStream cs = new AntlrNoCaseStringStream(query);
JPA2Lexer lexer = new JPA2Lexer(cs);
TokenStream tstream = new CommonTokenStream(lexer);
JPA2Parser jpa2Parser = new JPA2Parser(tstream);
JPA2Parser.where_clause_return aReturn = jpa2Parser.where_clause();
Assert.assertTrue(isValid((CommonTree) aReturn.getTree()));
testQuery("SELECT d FROM app$Department d WHERE (select e from app$Employee e where e.id = :eParam) MEMBER OF e.employees");
testQuery("SELECT e FROM app$Employee e WHERE 'write code' MEMBER OF e.codes");
testQuery("SELECT e FROM app$Employee e WHERE 'write code' NOT MEMBER OF e.codes");
}
use of com.haulmont.cuba.core.sys.jpql.antlr2.JPA2Lexer in project cuba by cuba-platform.
the class Jpa2GrammarTest method testQuery.
private void testQuery(String query) throws RecognitionException {
CharStream cs = new AntlrNoCaseStringStream(query);
JPA2Lexer lexer = new JPA2Lexer(cs);
TokenStream tstream = new CommonTokenStream(lexer);
JPA2Parser jpa2Parser = new JPA2Parser(tstream);
JPA2Parser.ql_statement_return aReturn = jpa2Parser.ql_statement();
Assert.assertTrue(isValid((CommonTree) aReturn.getTree()));
}
Aggregations