use of io.confluent.ksql.tools.migrations.util.CommandParser.SqlCommand in project ksql by confluentinc.
the class CommandParserTest method shouldParseUndefineStatement.
@Test
public void shouldParseUndefineStatement() {
// Given:
final String undefineVar = "UNDEFINE var;";
// When:
List<SqlCommand> commands = parse(undefineVar);
// Then:
assertThat(commands.size(), is(1));
assertThat(commands.get(0).getCommand(), is(undefineVar));
assertThat(commands.get(0), instanceOf(SqlUndefineVariableCommand.class));
assertThat(((SqlUndefineVariableCommand) commands.get(0)).getVariable(), is("var"));
}
use of io.confluent.ksql.tools.migrations.util.CommandParser.SqlCommand 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"));
}
use of io.confluent.ksql.tools.migrations.util.CommandParser.SqlCommand in project ksql by confluentinc.
the class CommandParserTest method shouldParseInsertValuesStatementWithExplicitQuoting.
@Test
public void shouldParseInsertValuesStatementWithExplicitQuoting() {
// When:
List<SqlCommand> commands = parse("INSERT INTO `foo` (`col1`) VALUES (55);");
// Then:
assertThat(commands.size(), is(1));
assertThat(commands.get(0), instanceOf(SqlInsertValues.class));
final SqlInsertValues insertValues = (SqlInsertValues) commands.get(0);
assertThat(insertValues.getSourceName(), is("`foo`"));
assertThat(insertValues.getColumns(), is(ImmutableList.of("col1")));
assertThat(insertValues.getValues().size(), is(1));
assertThat(toFieldType(insertValues.getValues().get(0)), is(55));
}
use of io.confluent.ksql.tools.migrations.util.CommandParser.SqlCommand in project ksql by confluentinc.
the class CommandParserTest method shouldParseInsertValuesStatement.
@Test
public void shouldParseInsertValuesStatement() {
// When:
List<SqlCommand> commands = parse("INSERT INTO FOO VALUES (55);");
// Then:
assertThat(commands.size(), is(1));
assertThat(commands.get(0), instanceOf(SqlInsertValues.class));
final SqlInsertValues insertValues = (SqlInsertValues) commands.get(0);
assertThat(insertValues.getSourceName(), is("`FOO`"));
assertThat(insertValues.getColumns(), is(Collections.emptyList()));
assertThat(insertValues.getValues().size(), is(1));
assertThat(toFieldType(insertValues.getValues().get(0)), is(55));
}
use of io.confluent.ksql.tools.migrations.util.CommandParser.SqlCommand in project ksql by confluentinc.
the class CommandParserTest method shouldParseCreateConnectorStatementWithVariables.
@Test
public void shouldParseCreateConnectorStatementWithVariables() {
// Given:
final String createConnector = "CREATE SOURCE CONNECTOR ${name} WITH(\n" + " \"connector.class\"='io.confluent.connect.jdbc.JdbcSourceConnector',\n" + " \"connection.url\"=${url},\n" + " \"mode\"='bulk',\n" + " \"topic.prefix\"='jdbc-',\n" + " \"table.whitelist\"='users',\n" + " \"key\"='username');";
// When:
List<SqlCommand> commands = parse(createConnector, ImmutableMap.of("url", "'jdbc:postgresql://localhost:5432/my.db'", "name", "`jdbc_connector`"));
// Then:
assertThat(commands.size(), is(1));
assertThat(commands.get(0), instanceOf(SqlCreateConnectorStatement.class));
assertThat(commands.get(0).getCommand(), is(createConnector));
assertThat(((SqlCreateConnectorStatement) commands.get(0)).getName(), is("`jdbc_connector`"));
assertThat(((SqlCreateConnectorStatement) commands.get(0)).isSource(), is(true));
assertThat(((SqlCreateConnectorStatement) commands.get(0)).getProperties().size(), is(6));
assertThat(((SqlCreateConnectorStatement) commands.get(0)).getProperties().get("connector.class"), is("io.confluent.connect.jdbc.JdbcSourceConnector"));
assertThat(((SqlCreateConnectorStatement) commands.get(0)).getProperties().get("connection.url"), is("jdbc:postgresql://localhost:5432/my.db"));
assertThat(((SqlCreateConnectorStatement) commands.get(0)).getProperties().get("mode"), is("bulk"));
assertThat(((SqlCreateConnectorStatement) commands.get(0)).getProperties().get("topic.prefix"), is("jdbc-"));
assertThat(((SqlCreateConnectorStatement) commands.get(0)).getProperties().get("table.whitelist"), is("users"));
assertThat(((SqlCreateConnectorStatement) commands.get(0)).getProperties().get("key"), is("username"));
}
Aggregations