Search in sources :

Example 1 with SearchedCaseExpression

use of io.confluent.ksql.parser.tree.SearchedCaseExpression in project ksql by confluentinc.

the class ExpressionFormatterTest method shouldFormatSearchedCaseExpression.

@Test
public void shouldFormatSearchedCaseExpression() {
    final SearchedCaseExpression expression = new SearchedCaseExpression(Collections.singletonList(new WhenClause(new StringLiteral("foo"), new LongLiteral("1"))), Optional.empty());
    assertThat(ExpressionFormatter.formatExpression(expression), equalTo("(CASE WHEN 'foo' THEN 1 END)"));
}
Also used : WhenClause(io.confluent.ksql.parser.tree.WhenClause) SearchedCaseExpression(io.confluent.ksql.parser.tree.SearchedCaseExpression) StringLiteral(io.confluent.ksql.parser.tree.StringLiteral) LongLiteral(io.confluent.ksql.parser.tree.LongLiteral) Test(org.junit.Test)

Example 2 with SearchedCaseExpression

use of io.confluent.ksql.parser.tree.SearchedCaseExpression in project ksql by confluentinc.

the class ExpressionFormatterTest method shouldFormatSearchedCaseExpressionWithDefaultValue.

@Test
public void shouldFormatSearchedCaseExpressionWithDefaultValue() {
    final SearchedCaseExpression expression = new SearchedCaseExpression(Collections.singletonList(new WhenClause(new StringLiteral("foo"), new LongLiteral("1"))), Optional.of(new LongLiteral("2")));
    assertThat(ExpressionFormatter.formatExpression(expression), equalTo("(CASE WHEN 'foo' THEN 1 ELSE 2 END)"));
}
Also used : WhenClause(io.confluent.ksql.parser.tree.WhenClause) SearchedCaseExpression(io.confluent.ksql.parser.tree.SearchedCaseExpression) StringLiteral(io.confluent.ksql.parser.tree.StringLiteral) LongLiteral(io.confluent.ksql.parser.tree.LongLiteral) Test(org.junit.Test)

Aggregations

LongLiteral (io.confluent.ksql.parser.tree.LongLiteral)2 SearchedCaseExpression (io.confluent.ksql.parser.tree.SearchedCaseExpression)2 StringLiteral (io.confluent.ksql.parser.tree.StringLiteral)2 WhenClause (io.confluent.ksql.parser.tree.WhenClause)2 Test (org.junit.Test)2