use of io.confluent.ksql.rest.entity.SimpleConnectorPluginInfo in project ksql by confluentinc.
the class ListConnectorPluginsExecutor method execute.
@SuppressWarnings("OptionalGetWithoutIsPresent")
public StatementExecutorResponse execute(final ConfiguredStatement<ListConnectorPlugins> configuredStatement, final SessionProperties sessionProperties, final KsqlExecutionContext ksqlExecutionContext, final ServiceContext serviceContext) {
final ConnectResponse<List<ConnectorPluginInfo>> plugins = serviceContext.getConnectClient().connectorPlugins();
if (plugins.error().isPresent()) {
return StatementExecutorResponse.handled(connectErrorHandler.handle(configuredStatement, plugins));
}
final List<SimpleConnectorPluginInfo> pluginInfos = new ArrayList<>();
for (final ConnectorPluginInfo info : plugins.datum().get()) {
pluginInfos.add(new SimpleConnectorPluginInfo(info.className(), info.type(), info.version()));
}
return StatementExecutorResponse.handled(Optional.of(new ConnectorPluginsList(configuredStatement.getStatementText(), Collections.emptyList(), pluginInfos)));
}
use of io.confluent.ksql.rest.entity.SimpleConnectorPluginInfo in project ksql by confluentinc.
the class ListConnectorPluginsTest method shouldListValidConnectorPlugins.
@Test
public void shouldListValidConnectorPlugins() {
// Given:
when(connectClient.connectorPlugins()).thenReturn(ConnectClient.ConnectResponse.success(ImmutableList.of(INFO), HttpStatus.SC_OK));
final KsqlConfig ksqlConfig = new KsqlConfig(ImmutableMap.of());
final ConfiguredStatement<ListConnectorPlugins> statement = ConfiguredStatement.of(KsqlParser.PreparedStatement.of("", new ListConnectorPlugins(Optional.empty())), SessionConfig.of(ksqlConfig, ImmutableMap.of()));
// When:
final Optional<KsqlEntity> entity = EXECUTOR.execute(statement, mock(SessionProperties.class), engine, serviceContext).getEntity();
// Then:
assertThat("expected response!", entity.isPresent());
final ConnectorPluginsList connectorPluginsList = (ConnectorPluginsList) entity.get();
assertThat(connectorPluginsList, is(new ConnectorPluginsList("", ImmutableList.of(), ImmutableList.of(new SimpleConnectorPluginInfo("org.apache.kafka.connect.file.FileStreamSinkConnector", ConnectorType.SOURCE, "2.1")))));
}
use of io.confluent.ksql.rest.entity.SimpleConnectorPluginInfo in project ksql by confluentinc.
the class ConsoleTest method shouldPrintConnectorPluginsList.
@Test
public void shouldPrintConnectorPluginsList() {
// Given:
final KsqlEntityList entities = new KsqlEntityList(ImmutableList.of(new ConnectorPluginsList("statement", ImmutableList.of(), ImmutableList.of(new SimpleConnectorPluginInfo("clazz1", ConnectorType.SOURCE, "v1"), new SimpleConnectorPluginInfo("clazz2", ConnectorType.SINK, "v2")))));
// When:
console.printKsqlEntityList(entities);
// Then:
final String output = terminal.getOutputString();
if (console.getOutputFormat() == OutputFormat.JSON) {
assertThat(output, is("" + "[ {" + NEWLINE + " \"@type\" : \"connector_plugins_list\"," + NEWLINE + " \"statementText\" : \"statement\"," + NEWLINE + " \"warnings\" : [ ]," + NEWLINE + " \"connectorsPlugins\" : [ {" + NEWLINE + " \"className\" : \"clazz1\"," + NEWLINE + " \"type\" : \"source\"," + NEWLINE + " \"version\" : \"v1\"" + NEWLINE + " }, {" + NEWLINE + " \"className\" : \"clazz2\"," + NEWLINE + " \"type\" : \"sink\"," + NEWLINE + " \"version\" : \"v2\"" + NEWLINE + " } ]" + NEWLINE + "} ]" + NEWLINE));
} else {
assertThat(output, is("" + NEWLINE + " Class | Type | Version " + NEWLINE + "---------------------------" + NEWLINE + " clazz1 | SOURCE | v1 " + NEWLINE + " clazz2 | SINK | v2 " + NEWLINE + "---------------------------" + NEWLINE));
}
}
Aggregations