use of net.sf.jsqlparser.expression.Expression in project JSqlParser by JSQLParser.
the class ExpressionDeParserTest method shouldDeParseAnalyticExpressionWithExpression.
@Test
public void shouldDeParseAnalyticExpressionWithExpression() {
AnalyticExpression analyticExpression = new AnalyticExpression();
Expression expression = mock(Expression.class);
analyticExpression.setName("name");
analyticExpression.setExpression(expression);
will(appendToBuffer("expression")).given(expression).accept(expressionDeParser);
expressionDeParser.visit(analyticExpression);
assertEquals("name(expression) OVER ()", buffer.toString());
}
use of net.sf.jsqlparser.expression.Expression in project JSqlParser by JSQLParser.
the class ExpressionDeParserTest method shouldDeParseAnalyticExpressionWithOffset.
@Test
public void shouldDeParseAnalyticExpressionWithOffset() {
AnalyticExpression analyticExpression = new AnalyticExpression();
Expression expression = mock(Expression.class);
Expression offset = mock(Expression.class);
analyticExpression.setName("name");
analyticExpression.setExpression(expression);
analyticExpression.setOffset(offset);
will(appendToBuffer("expression")).given(expression).accept(expressionDeParser);
will(appendToBuffer("offset")).given(offset).accept(expressionDeParser);
expressionDeParser.visit(analyticExpression);
assertEquals("name(expression, offset) OVER ()", buffer.toString());
}
use of net.sf.jsqlparser.expression.Expression in project JSqlParser by JSQLParser.
the class ExpressionDeParserTest method shouldDeParseComplexAnalyticExpressionWithPartitionExpressionList.
@Test
public void shouldDeParseComplexAnalyticExpressionWithPartitionExpressionList() {
AnalyticExpression analyticExpression = new AnalyticExpression();
ExpressionList partitionExpressionList = new ExpressionList();
List<Expression> partitionExpressions = new ArrayList<Expression>();
Expression partitionExpression1 = mock(Expression.class);
Expression partitionExpression2 = mock(Expression.class);
analyticExpression.setName("name");
analyticExpression.setPartitionExpressionList(partitionExpressionList);
partitionExpressionList.setExpressions(partitionExpressions);
partitionExpressions.add(partitionExpression1);
partitionExpressions.add(partitionExpression2);
will(appendToBuffer("partition expression 1")).given(partitionExpression1).accept(expressionDeParser);
will(appendToBuffer("partition expression 2")).given(partitionExpression2).accept(expressionDeParser);
expressionDeParser.visit(analyticExpression);
assertEquals("name() OVER (PARTITION BY partition expression 1, partition expression 2 )", buffer.toString());
}
use of net.sf.jsqlparser.expression.Expression in project JSqlParser by JSQLParser.
the class StatementDeParserTest method shouldUseProvidedDeParsersWhenDeParsingUpdateUsingSelect.
@Test
@SuppressWarnings("PMD.JUnitTestsShouldIncludeAssert")
public void shouldUseProvidedDeParsersWhenDeParsingUpdateUsingSelect() {
Update update = new Update();
List<Column> columns = new ArrayList<Column>();
Select select = new Select();
Expression where = mock(Expression.class);
List<OrderByElement> orderByElements = new ArrayList<OrderByElement>();
Column column1 = new Column();
Column column2 = new Column();
SelectBody selectBody = mock(SelectBody.class);
OrderByElement orderByElement1 = new OrderByElement();
OrderByElement orderByElement2 = new OrderByElement();
Expression orderByElement1Expression = mock(Expression.class);
Expression orderByElement2Expression = mock(Expression.class);
update.setUseSelect(true);
update.setColumns(columns);
update.setSelect(select);
update.setWhere(where);
update.setOrderByElements(orderByElements);
columns.add(column1);
columns.add(column2);
select.setSelectBody(selectBody);
orderByElements.add(orderByElement1);
orderByElements.add(orderByElement2);
orderByElement1.setExpression(orderByElement1Expression);
orderByElement2.setExpression(orderByElement2Expression);
statementDeParser.visit(update);
then(expressionDeParser).should().visit(column1);
then(expressionDeParser).should().visit(column2);
then(selectBody).should().accept(selectDeParser);
then(where).should().accept(expressionDeParser);
then(orderByElement1Expression).should().accept(expressionDeParser);
then(orderByElement2Expression).should().accept(expressionDeParser);
}
use of net.sf.jsqlparser.expression.Expression in project JSqlParser by JSQLParser.
the class StatementDeParserTest method shouldUseProvidedDeParsersWhenDeParsingUpdateNotUsingSelect.
@Test
@SuppressWarnings("PMD.JUnitTestsShouldIncludeAssert")
public void shouldUseProvidedDeParsersWhenDeParsingUpdateNotUsingSelect() {
Update update = new Update();
List<Column> columns = new ArrayList<Column>();
List<Expression> expressions = new ArrayList<Expression>();
Expression where = mock(Expression.class);
List<OrderByElement> orderByElements = new ArrayList<OrderByElement>();
Column column1 = new Column();
Column column2 = new Column();
Expression expression1 = mock(Expression.class);
Expression expression2 = mock(Expression.class);
OrderByElement orderByElement1 = new OrderByElement();
OrderByElement orderByElement2 = new OrderByElement();
Expression orderByElement1Expression = mock(Expression.class);
Expression orderByElement2Expression = mock(Expression.class);
update.setColumns(columns);
update.setExpressions(expressions);
update.setWhere(where);
update.setOrderByElements(orderByElements);
columns.add(column1);
columns.add(column2);
expressions.add(expression1);
expressions.add(expression2);
orderByElements.add(orderByElement1);
orderByElements.add(orderByElement2);
orderByElement1.setExpression(orderByElement1Expression);
orderByElement2.setExpression(orderByElement2Expression);
statementDeParser.visit(update);
then(expressionDeParser).should().visit(column1);
then(expressionDeParser).should().visit(column2);
then(expression1).should().accept(expressionDeParser);
then(expression2).should().accept(expressionDeParser);
then(where).should().accept(expressionDeParser);
then(orderByElement1Expression).should().accept(expressionDeParser);
then(orderByElement2Expression).should().accept(expressionDeParser);
}
Aggregations