use of io.confluent.ksql.rest.entity.ConnectorDescription in project ksql by confluentinc.
the class DescribeConnectorExecutorTest method shouldDescribeKnownConnector.
@SuppressWarnings("OptionalGetWithoutIsPresent")
@Test
public void shouldDescribeKnownConnector() {
// Given:
when(connectClient.topics("connector")).thenReturn(ConnectResponse.success(ACTIVE_TOPICS, HttpStatus.SC_OK));
// When:
final Optional<KsqlEntity> entity = executor.execute(describeStatement, mock(SessionProperties.class), engine, serviceContext).getEntity();
// Then:
verify(engine).getMetaStore();
verify(engine).metricCollectors();
verify(metaStore).getAllDataSources();
verify(connectClient).status("connector");
verify(connectClient).describe("connector");
verify(connectClient).topics("connector");
assertThat("Expected a response", entity.isPresent());
assertThat(entity.get(), instanceOf(ConnectorDescription.class));
final ConnectorDescription description = (ConnectorDescription) entity.get();
assertThat(description.getConnectorClass(), is(CONNECTOR_CLASS));
assertThat(description.getStatus(), is(STATUS));
assertThat(description.getSources().size(), is(1));
assertThat(description.getSources().get(0).getName(), is("source"));
assertThat(description.getSources().get(0).getTopic(), is(TOPIC));
assertThat(description.getTopics().size(), is(1));
assertThat(description.getTopics().get(0), is(TOPIC));
}
use of io.confluent.ksql.rest.entity.ConnectorDescription in project ksql by confluentinc.
the class DescribeConnectorExecutorTest method shouldNotWarnClientOnMissingTopicsEndpoint.
@Test
public void shouldNotWarnClientOnMissingTopicsEndpoint() {
// Given:
when(connectClient.topics(any())).thenReturn(ConnectResponse.failure("not found", HttpStatus.SC_NOT_FOUND));
// When:
final Optional<KsqlEntity> entity = executor.execute(describeStatement, mock(SessionProperties.class), engine, serviceContext).getEntity();
// Then:
verify(engine).getMetaStore();
verify(metaStore).getAllDataSources();
verify(connectClient).status("connector");
verify(connectClient).describe("connector");
verify(connectClient).topics("connector");
assertThat("Expected a response", entity.isPresent());
assertThat(entity.get(), instanceOf(ConnectorDescription.class));
final ConnectorDescription description = (ConnectorDescription) entity.get();
assertThat(description.getTopics(), empty());
assertThat(description.getWarnings(), empty());
}
use of io.confluent.ksql.rest.entity.ConnectorDescription in project ksql by confluentinc.
the class DescribeConnectorExecutorTest method shouldDescribeKnownConnectorIfTopicListFails.
@Test
public void shouldDescribeKnownConnectorIfTopicListFails() {
// Given:
when(connectClient.topics("connector")).thenReturn(ConnectResponse.failure("Topic tracking is disabled.", HttpStatus.SC_FORBIDDEN));
// When:
final Optional<KsqlEntity> entity = executor.execute(describeStatement, mock(SessionProperties.class), engine, serviceContext).getEntity();
// Then:
verify(engine).getMetaStore();
verify(metaStore).getAllDataSources();
verify(connectClient).status("connector");
verify(connectClient).describe("connector");
verify(connectClient).topics("connector");
assertThat("Expected a response", entity.isPresent());
assertThat(entity.get(), instanceOf(ConnectorDescription.class));
final ConnectorDescription description = (ConnectorDescription) entity.get();
assertThat(description.getConnectorClass(), is(CONNECTOR_CLASS));
assertThat(description.getTopics().size(), is(0));
assertThat(description.getWarnings().size(), is(1));
}
use of io.confluent.ksql.rest.entity.ConnectorDescription in project ksql by confluentinc.
the class ClientTest method shouldDescribeConnector.
@Test
public void shouldDescribeConnector() throws Exception {
// Given:
final ConnectorDescription entity = new ConnectorDescription("describe connector;", "connectorClass", new ConnectorStateInfo("name", new ConnectorState("state", "worker", "msg"), Collections.emptyList(), SOURCE_TYPE), Collections.emptyList(), Collections.singletonList("topic"), Collections.emptyList());
testEndpoints.setKsqlEndpointResponse(Collections.singletonList(entity));
// When:
final io.confluent.ksql.api.client.ConnectorDescription connector = javaClient.describeConnector("name").get();
// Then:
assertThat(connector.state(), is("state"));
assertThat(connector.className(), is("connectorClass"));
assertThat(connector.type(), is(new ConnectorTypeImpl("SOURCE")));
assertThat(connector.sources().size(), is(0));
assertThat(connector.topics().size(), is(1));
assertThat(connector.topics().get(0), is("topic"));
}
Aggregations