Search in sources :

Example 1 with SqlDefineVariableCommand

use of io.confluent.ksql.tools.migrations.util.CommandParser.SqlDefineVariableCommand in project ksql by confluentinc.

the class CommandParserTest method shouldDefineStatementWithVariable.

@Test
public void shouldDefineStatementWithVariable() {
    // Given:
    final String defineVar = "DEFiNe word = 'walk${suffix}';";
    // When:
    List<SqlCommand> commands = parse(defineVar, ImmutableMap.of("suffix", "ing"));
    // Then:
    assertThat(commands.size(), is(1));
    assertThat(commands.get(0), instanceOf(SqlDefineVariableCommand.class));
    assertThat(((SqlDefineVariableCommand) commands.get(0)).getVariable(), is("word"));
    assertThat(((SqlDefineVariableCommand) commands.get(0)).getValue(), is("walking"));
}
Also used : Matchers.containsString(org.hamcrest.Matchers.containsString) SqlDefineVariableCommand(io.confluent.ksql.tools.migrations.util.CommandParser.SqlDefineVariableCommand) SqlCommand(io.confluent.ksql.tools.migrations.util.CommandParser.SqlCommand) Test(org.junit.Test)

Example 2 with SqlDefineVariableCommand

use of io.confluent.ksql.tools.migrations.util.CommandParser.SqlDefineVariableCommand in project ksql by confluentinc.

the class CommandParserTest method shouldParseDefineStatement.

@Test
public void shouldParseDefineStatement() {
    // Given:
    final String defineVar = "DEFINE var = 'foo';";
    // When:
    List<SqlCommand> commands = parse(defineVar);
    // Then:
    assertThat(commands.size(), is(1));
    assertThat(commands.get(0).getCommand(), is(defineVar));
    assertThat(commands.get(0), instanceOf(SqlDefineVariableCommand.class));
    assertThat(((SqlDefineVariableCommand) commands.get(0)).getVariable(), is("var"));
    assertThat(((SqlDefineVariableCommand) commands.get(0)).getValue(), is("foo"));
}
Also used : Matchers.containsString(org.hamcrest.Matchers.containsString) SqlDefineVariableCommand(io.confluent.ksql.tools.migrations.util.CommandParser.SqlDefineVariableCommand) SqlCommand(io.confluent.ksql.tools.migrations.util.CommandParser.SqlCommand) Test(org.junit.Test)

Aggregations

SqlCommand (io.confluent.ksql.tools.migrations.util.CommandParser.SqlCommand)2 SqlDefineVariableCommand (io.confluent.ksql.tools.migrations.util.CommandParser.SqlDefineVariableCommand)2 Matchers.containsString (org.hamcrest.Matchers.containsString)2 Test (org.junit.Test)2