use of net.sf.jsqlparser.expression.Expression in project JSqlParser by JSQLParser.
the class CNFTest method test5.
/**
* This is the case when we test the tree that only contains AND
* operator without having an OR operator.
*
* Here is the original expression tree:
* NOT
* |
* ( )
* |
* OR
* / \
* ( ) ( )
* | |
* NOT OR
* | / \
* AND LIKE =
* / \ / \ / \
* > < S.C "%%" S.D {t '12:04:34'}
* / \ / \
* S.A 3.5 S.B 4
*
* Here is the converted expression tree:
*
* AND
* / \
* AND =
* / \ / \
* AND NOT LIKE S.D {t '12:04:34'}
* / \ / \
* > < S.C "%%"
* / \ / \
* S.A 3.5 S.B 4
*/
@Test
public void test5() throws Exception {
Expression expr = CCJSqlParserUtil.parseCondExpression("NOT ((NOT (S.A > 3.5 AND S.B < 4)) OR " + "(S.C LIKE '\"%%\"' OR S.D = {t '12:04:34'}))");
Expression expected = CCJSqlParserUtil.parseCondExpression("S.A > 3.5 AND S.B < 4 AND S.C NOT LIKE '\"%%\"' " + "AND NOT S.D = {t '12:04:34'}");
Expression result = CNFConverter.convertToCNF(expr);
assertEquals(expected.toString(), result.toString());
}
use of net.sf.jsqlparser.expression.Expression in project JSqlParser by JSQLParser.
the class ExecuteDeParserTest method shouldUseProvidedExpressionVisitorWhenDeParsingExecute.
@Test
public void shouldUseProvidedExpressionVisitorWhenDeParsingExecute() {
Execute execute = new Execute();
String name = "name";
ExpressionList exprList = new ExpressionList();
List<Expression> expressions = new ArrayList<Expression>();
Expression expression1 = mock(Expression.class);
Expression expression2 = mock(Expression.class);
execute.setName(name);
execute.setExprList(exprList);
exprList.setExpressions(expressions);
expressions.add(expression1);
expressions.add(expression2);
executeDeParser.deParse(execute);
then(expression1).should().accept(expressionVisitor);
then(expression2).should().accept(expressionVisitor);
}
use of net.sf.jsqlparser.expression.Expression in project JSqlParser by JSQLParser.
the class ExpressionDeParserTest method shouldDeParseAnalyticExpressionWithDefaultValue.
@Test
public void shouldDeParseAnalyticExpressionWithDefaultValue() {
AnalyticExpression analyticExpression = new AnalyticExpression();
Expression expression = mock(Expression.class);
Expression offset = mock(Expression.class);
Expression defaultValue = mock(Expression.class);
analyticExpression.setName("name");
analyticExpression.setExpression(expression);
analyticExpression.setOffset(offset);
analyticExpression.setDefaultValue(defaultValue);
will(appendToBuffer("expression")).given(expression).accept(expressionDeParser);
will(appendToBuffer("offset")).given(offset).accept(expressionDeParser);
will(appendToBuffer("default value")).given(defaultValue).accept(expressionDeParser);
expressionDeParser.visit(analyticExpression);
assertEquals("name(expression, offset, default value) OVER ()", buffer.toString());
}
use of net.sf.jsqlparser.expression.Expression in project JSqlParser by JSQLParser.
the class StatementDeParserTest method shouldUseProvidedDeParsersWhenDeParsingReplaceWithoutItemsList.
@Test
@SuppressWarnings("PMD.JUnitTestsShouldIncludeAssert")
public void shouldUseProvidedDeParsersWhenDeParsingReplaceWithoutItemsList() {
Replace replace = new Replace();
Table table = new Table();
List<Column> columns = new ArrayList<Column>();
List<Expression> expressions = new ArrayList<Expression>();
Column column1 = new Column();
Column column2 = new Column();
Expression expression1 = mock(Expression.class);
Expression expression2 = mock(Expression.class);
replace.setTable(table);
replace.setColumns(columns);
replace.setExpressions(expressions);
columns.add(column1);
columns.add(column2);
expressions.add(expression1);
expressions.add(expression2);
statementDeParser.visit(replace);
then(expression1).should().accept(expressionDeParser);
then(expression2).should().accept(expressionDeParser);
}
use of net.sf.jsqlparser.expression.Expression in project JSqlParser by JSQLParser.
the class StatementDeParserTest method shouldUseProvidedDeparsersWhenDeParsingDelete.
@Test
@SuppressWarnings("PMD.JUnitTestsShouldIncludeAssert")
public void shouldUseProvidedDeparsersWhenDeParsingDelete() {
Delete delete = new Delete();
Table table = new Table();
Expression where = mock(Expression.class);
List<OrderByElement> orderByElements = new ArrayList<OrderByElement>();
OrderByElement orderByElement1 = new OrderByElement();
OrderByElement orderByElement2 = new OrderByElement();
Expression orderByElement1Expression = mock(Expression.class);
Expression orderByElement2Expression = mock(Expression.class);
delete.setTable(table);
delete.setWhere(where);
delete.setOrderByElements(orderByElements);
orderByElements.add(orderByElement1);
orderByElements.add(orderByElement2);
orderByElement1.setExpression(orderByElement1Expression);
orderByElement2.setExpression(orderByElement2Expression);
statementDeParser.visit(delete);
then(where).should().accept(expressionDeParser);
then(orderByElement1Expression).should().accept(expressionDeParser);
then(orderByElement2Expression).should().accept(expressionDeParser);
}
Aggregations