Search in sources :

Example 1 with SimpleCaseExpression

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

the class ExpressionFormatterTest method shouldFormatSimpleCaseExpression.

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

Example 2 with SimpleCaseExpression

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

the class ExpressionFormatterTest method shouldFormatSimpleCaseExpressionWithDefaultValue.

@Test
public void shouldFormatSimpleCaseExpressionWithDefaultValue() {
    final SimpleCaseExpression expression = new SimpleCaseExpression(new StringLiteral("operand"), Collections.singletonList(new WhenClause(new StringLiteral("foo"), new LongLiteral("1"))), Optional.of(new LongLiteral("2")));
    assertThat(ExpressionFormatter.formatExpression(expression), equalTo("(CASE 'operand' WHEN 'foo' THEN 1 ELSE 2 END)"));
}
Also used : SimpleCaseExpression(io.confluent.ksql.parser.tree.SimpleCaseExpression) WhenClause(io.confluent.ksql.parser.tree.WhenClause) 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 SimpleCaseExpression (io.confluent.ksql.parser.tree.SimpleCaseExpression)2 StringLiteral (io.confluent.ksql.parser.tree.StringLiteral)2 WhenClause (io.confluent.ksql.parser.tree.WhenClause)2 Test (org.junit.Test)2