Search in sources :

Example 1 with ConnectorState

use of org.apache.kafka.connect.runtime.rest.entities.ConnectorStateInfo.ConnectorState in project ksql by confluentinc.

the class ClientTest method shouldSendSessionVariablesWithDescribeConnector.

@Test
public void shouldSendSessionVariablesWithDescribeConnector() throws Exception {
    // Given:
    javaClient.define("a", "a");
    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:
    javaClient.describeConnector("name").get();
    // Then:
    assertThat(testEndpoints.getLastSessionVariables(), is(new JsonObject().put("a", "a")));
}
Also used : ConnectorState(org.apache.kafka.connect.runtime.rest.entities.ConnectorStateInfo.ConnectorState) ConnectorDescription(io.confluent.ksql.rest.entity.ConnectorDescription) JsonObject(io.vertx.core.json.JsonObject) ConnectorStateInfo(org.apache.kafka.connect.runtime.rest.entities.ConnectorStateInfo) BaseApiTest(io.confluent.ksql.api.BaseApiTest) Test(org.junit.Test)

Example 2 with ConnectorState

use of org.apache.kafka.connect.runtime.rest.entities.ConnectorStateInfo.ConnectorState in project ksql by confluentinc.

the class ClientTest method shouldFailToDescribeConnectorViaExecuteStatement.

@Test
public void shouldFailToDescribeConnectorViaExecuteStatement() {
    // 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 Exception e = assertThrows(// thrown from .get() when the future completes exceptionally
    ExecutionException.class, () -> javaClient.executeStatement("describe connector;").get());
    // Then
    assertThat(e.getCause(), instanceOf(KsqlClientException.class));
    assertThat(e.getCause().getMessage(), containsString(EXECUTE_STATEMENT_USAGE_DOC));
    assertThat(e.getCause().getMessage(), containsString("Use the describeConnector() method instead"));
}
Also used : ConnectorState(org.apache.kafka.connect.runtime.rest.entities.ConnectorStateInfo.ConnectorState) KsqlClientException(io.confluent.ksql.api.client.exception.KsqlClientException) ConnectorDescription(io.confluent.ksql.rest.entity.ConnectorDescription) ConnectorStateInfo(org.apache.kafka.connect.runtime.rest.entities.ConnectorStateInfo) KafkaResponseGetFailedException(io.confluent.ksql.exception.KafkaResponseGetFailedException) KsqlClientException(io.confluent.ksql.api.client.exception.KsqlClientException) KsqlApiException(io.confluent.ksql.api.server.KsqlApiException) ExecutionException(java.util.concurrent.ExecutionException) ParseFailedException(io.confluent.ksql.parser.exception.ParseFailedException) KsqlException(io.confluent.ksql.api.client.exception.KsqlException) BaseApiTest(io.confluent.ksql.api.BaseApiTest) Test(org.junit.Test)

Example 3 with ConnectorState

use of org.apache.kafka.connect.runtime.rest.entities.ConnectorStateInfo.ConnectorState in project ksql by confluentinc.

the class ConsoleTest method testPrintConnectorDescription.

@Test
public void testPrintConnectorDescription() {
    // Given:
    final KsqlEntityList entityList = new KsqlEntityList(ImmutableList.of(new ConnectorDescription("STATEMENT", "io.confluent.Connector", new ConnectorStateInfo("name", new ConnectorState("state", "worker", "msg"), ImmutableList.of(new TaskState(0, "task", "worker", "task_msg")), ConnectorType.SOURCE), ImmutableList.of(sourceDescription), ImmutableList.of("a-jdbc-topic"), ImmutableList.of())));
    // When:
    console.printKsqlEntityList(entityList);
    // Then:
    final String output = terminal.getOutputString();
    Approvals.verify(output, approvalOptions);
}
Also used : KsqlEntityList(io.confluent.ksql.rest.entity.KsqlEntityList) ConnectorState(org.apache.kafka.connect.runtime.rest.entities.ConnectorStateInfo.ConnectorState) ConnectorDescription(io.confluent.ksql.rest.entity.ConnectorDescription) Matchers.containsString(org.hamcrest.Matchers.containsString) TaskState(org.apache.kafka.connect.runtime.rest.entities.ConnectorStateInfo.TaskState) ConnectorStateInfo(org.apache.kafka.connect.runtime.rest.entities.ConnectorStateInfo) Test(org.junit.Test)

Example 4 with ConnectorState

use of org.apache.kafka.connect.runtime.rest.entities.ConnectorStateInfo.ConnectorState 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)4 ConnectorStateInfo (org.apache.kafka.connect.runtime.rest.entities.ConnectorStateInfo)4 ConnectorState (org.apache.kafka.connect.runtime.rest.entities.ConnectorStateInfo.ConnectorState)4 Test (org.junit.Test)4 BaseApiTest (io.confluent.ksql.api.BaseApiTest)3 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 KafkaResponseGetFailedException (io.confluent.ksql.exception.KafkaResponseGetFailedException)1 ParseFailedException (io.confluent.ksql.parser.exception.ParseFailedException)1 KsqlEntityList (io.confluent.ksql.rest.entity.KsqlEntityList)1 JsonObject (io.vertx.core.json.JsonObject)1 ExecutionException (java.util.concurrent.ExecutionException)1 TaskState (org.apache.kafka.connect.runtime.rest.entities.ConnectorStateInfo.TaskState)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1