Search in sources :

Example 6 with ConnectorDescription

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));
}
Also used : ConnectorDescription(io.confluent.ksql.rest.entity.ConnectorDescription) KsqlEntity(io.confluent.ksql.rest.entity.KsqlEntity) Test(org.junit.Test)

Example 7 with ConnectorDescription

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());
}
Also used : ConnectorDescription(io.confluent.ksql.rest.entity.ConnectorDescription) KsqlEntity(io.confluent.ksql.rest.entity.KsqlEntity) Test(org.junit.Test)

Example 8 with ConnectorDescription

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));
}
Also used : ConnectorDescription(io.confluent.ksql.rest.entity.ConnectorDescription) KsqlEntity(io.confluent.ksql.rest.entity.KsqlEntity) Test(org.junit.Test)

Example 9 with ConnectorDescription

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"));
}
Also used : ConnectorTypeImpl(io.confluent.ksql.api.client.impl.ConnectorTypeImpl) ConnectorState(org.apache.kafka.connect.runtime.rest.entities.ConnectorStateInfo.ConnectorState) ConnectorDescription(io.confluent.ksql.rest.entity.ConnectorDescription) ConnectorStateInfo(org.apache.kafka.connect.runtime.rest.entities.ConnectorStateInfo) BaseApiTest(io.confluent.ksql.api.BaseApiTest) Test(org.junit.Test)

Aggregations

ConnectorDescription (io.confluent.ksql.rest.entity.ConnectorDescription)9 Test (org.junit.Test)8 ConnectorStateInfo (org.apache.kafka.connect.runtime.rest.entities.ConnectorStateInfo)5 KsqlEntity (io.confluent.ksql.rest.entity.KsqlEntity)4 ConnectorState (org.apache.kafka.connect.runtime.rest.entities.ConnectorStateInfo.ConnectorState)4 BaseApiTest (io.confluent.ksql.api.BaseApiTest)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ImmutableList (com.google.common.collect.ImmutableList)1 KsqlExecutionContext (io.confluent.ksql.KsqlExecutionContext)1 KsqlClientException (io.confluent.ksql.api.client.exception.KsqlClientException)1 KsqlException (io.confluent.ksql.api.client.exception.KsqlException)1 ConnectorTypeImpl (io.confluent.ksql.api.client.impl.ConnectorTypeImpl)1 KsqlApiException (io.confluent.ksql.api.server.KsqlApiException)1 Connector (io.confluent.ksql.connect.Connector)1 Connectors (io.confluent.ksql.connect.supported.Connectors)1 KafkaResponseGetFailedException (io.confluent.ksql.exception.KafkaResponseGetFailedException)1 ParseFailedException (io.confluent.ksql.parser.exception.ParseFailedException)1 DescribeConnector (io.confluent.ksql.parser.tree.DescribeConnector)1 SessionProperties (io.confluent.ksql.rest.SessionProperties)1 KsqlEntityList (io.confluent.ksql.rest.entity.KsqlEntityList)1