Search in sources :

Example 11 with SqlCommand

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

the class CommandParserTest method shouldParseCreateConnectorStatement.

@Test
public void shouldParseCreateConnectorStatement() {
    // Given:
    final String createConnector = "CREATE SOURCE CONNECTOR `jdbc-connector` WITH(\n" + "    \"connector.class\"='io.confluent.connect.jdbc.JdbcSourceConnector',\n" + "    \"connection.url\"='jdbc:postgresql://localhost:5432/my.db',\n" + "    \"mode\"='bulk',\n" + "    \"topic.prefix\"='jdbc-',\n" + "    \"table.whitelist\"='users',\n" + "    \"key\"='username');";
    // When:
    List<SqlCommand> commands = parse(createConnector);
    // 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"));
}
Also used : Matchers.containsString(org.hamcrest.Matchers.containsString) SqlCreateConnectorStatement(io.confluent.ksql.tools.migrations.util.CommandParser.SqlCreateConnectorStatement) SqlCommand(io.confluent.ksql.tools.migrations.util.CommandParser.SqlCommand) Test(org.junit.Test)

Aggregations

SqlCommand (io.confluent.ksql.tools.migrations.util.CommandParser.SqlCommand)11 Test (org.junit.Test)11 Matchers.containsString (org.hamcrest.Matchers.containsString)6 SqlInsertValues (io.confluent.ksql.tools.migrations.util.CommandParser.SqlInsertValues)5 SqlCreateConnectorStatement (io.confluent.ksql.tools.migrations.util.CommandParser.SqlCreateConnectorStatement)2 SqlDefineVariableCommand (io.confluent.ksql.tools.migrations.util.CommandParser.SqlDefineVariableCommand)2 SqlDropConnectorStatement (io.confluent.ksql.tools.migrations.util.CommandParser.SqlDropConnectorStatement)1 SqlUndefineVariableCommand (io.confluent.ksql.tools.migrations.util.CommandParser.SqlUndefineVariableCommand)1