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"));
}
Aggregations