use of io.confluent.ksql.parser.tree.AstNode in project ksql by confluentinc.
the class StatementRewriterTest method shouldUsePluginToRewrite.
@SuppressFBWarnings("RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT")
private void shouldUsePluginToRewrite(final AstNode original, final AstNode pluginResult) {
// Given:
when(mockPlugin.apply(any(), any())).thenReturn(Optional.of(pluginResult));
// When:
final AstNode rewritten = rewriter.rewrite(original, context);
// Then:
assertThat(rewritten, is(pluginResult));
verify(mockPlugin).apply(same(original), contextCaptor.capture());
final Context<Object> wrapped = contextCaptor.getValue();
assertThat(wrapped.getContext(), is(this.context));
}
use of io.confluent.ksql.parser.tree.AstNode in project ksql by confluentinc.
the class StatementRewriterTest method shouldRewriteInsertIntoWithPartitionBy.
@Test
public void shouldRewriteInsertIntoWithPartitionBy() {
// Given:
final InsertInto ii = new InsertInto(location, sourceName, query, insertIntoProperties);
when(mockRewriter.apply(query, context)).thenReturn(rewrittenQuery);
when(expressionRewriter.apply(expression, context)).thenReturn(rewrittenExpression);
// When:
final AstNode rewritten = rewriter.rewrite(ii, context);
// Then:
assertThat(rewritten, equalTo(new InsertInto(location, sourceName, rewrittenQuery, insertIntoProperties)));
}
use of io.confluent.ksql.parser.tree.AstNode in project ksql by confluentinc.
the class StatementRewriterTest method shouldNotRewriteExplainWithId.
@Test
public void shouldNotRewriteExplainWithId() {
// Given:
final Explain explain = new Explain(location, Optional.of("id"), Optional.empty());
// When:
final AstNode rewritten = rewriter.rewrite(explain, context);
// Then:
assertThat(rewritten, is(sameInstance(explain)));
}
use of io.confluent.ksql.parser.tree.AstNode in project ksql by confluentinc.
the class StatementRewriterTest method shouldRewriteExplainWithQuery.
@Test
public void shouldRewriteExplainWithQuery() {
// Given:
final Explain explain = new Explain(location, Optional.empty(), Optional.of(query));
when(mockRewriter.apply(query, context)).thenReturn(rewrittenQuery);
// When:
final AstNode rewritten = rewriter.rewrite(explain, context);
// Then:
assertThat(rewritten, is(new Explain(location, Optional.empty(), Optional.of(rewrittenQuery))));
}
use of io.confluent.ksql.parser.tree.AstNode in project ksql by confluentinc.
the class StatementRewriterTest method shouldRewriteWindowExpression.
@Test
public void shouldRewriteWindowExpression() {
// Given:
final KsqlWindowExpression ksqlWindowExpression = mock(KsqlWindowExpression.class);
final WindowExpression windowExpression = new WindowExpression(location, "name", ksqlWindowExpression);
// When:
final AstNode rewritten = rewriter.rewrite(windowExpression, context);
// Then:
assertThat(rewritten, equalTo(new WindowExpression(location, "name", ksqlWindowExpression)));
}
Aggregations