Search in sources :

Example 6 with ConnectorList

use of io.confluent.ksql.rest.entity.ConnectorList in project ksql by confluentinc.

the class CliTest method shouldIssueNonCCloudConnectorRequest.

@Test
public void shouldIssueNonCCloudConnectorRequest() throws Exception {
    // Given:
    final KsqlRestClient mockRestClient = givenMockRestClient();
    when(mockRestClient.getIsCCloudServer()).thenReturn(false);
    when(mockRestClient.makeConnectorRequest(anyString(), anyLong())).thenReturn(RestResponse.successful(OK.code(), new KsqlEntityList(Collections.singletonList(new ConnectorList("list connectors;", Collections.emptyList(), Collections.emptyList())))));
    // When:
    localCli.handleLine("list connectors;");
    // Then:
    verify(mockRestClient).makeConnectorRequest(anyString(), anyLong());
}
Also used : KsqlEntityList(io.confluent.ksql.rest.entity.KsqlEntityList) KsqlRestClient(io.confluent.ksql.rest.client.KsqlRestClient) ConnectorList(io.confluent.ksql.rest.entity.ConnectorList) Test(org.junit.Test) IntegrationTest(io.confluent.common.utils.IntegrationTest)

Example 7 with ConnectorList

use of io.confluent.ksql.rest.entity.ConnectorList in project ksql by confluentinc.

the class ListConnectorsExecutorTest method shouldLabelConnectorsWithNoRunningTasksAsWarning.

@Test
public void shouldLabelConnectorsWithNoRunningTasksAsWarning() {
    // Given:
    when(connectClient.status("connector")).thenReturn(ConnectResponse.success(STATUS_WARNING, HttpStatus.SC_OK));
    when(connectClient.connectors()).thenReturn(ConnectResponse.success(ImmutableList.of("connector"), HttpStatus.SC_OK));
    final KsqlConfig ksqlConfig = new KsqlConfig(ImmutableMap.of());
    final ConfiguredStatement<ListConnectors> statement = ConfiguredStatement.of(PreparedStatement.of("", new ListConnectors(Optional.empty(), Scope.ALL)), 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 ConnectorList connectorList = (ConnectorList) entity.get();
    assertThat(connectorList, is(new ConnectorList("", ImmutableList.of(), ImmutableList.of(new SimpleConnectorInfo("connector", ConnectorType.SOURCE, CONNECTOR_CLASS, "WARNING (0/2 tasks RUNNING)")))));
}
Also used : SimpleConnectorInfo(io.confluent.ksql.rest.entity.SimpleConnectorInfo) KsqlConfig(io.confluent.ksql.util.KsqlConfig) ConnectorList(io.confluent.ksql.rest.entity.ConnectorList) KsqlEntity(io.confluent.ksql.rest.entity.KsqlEntity) ListConnectors(io.confluent.ksql.parser.tree.ListConnectors) Test(org.junit.Test)

Example 8 with ConnectorList

use of io.confluent.ksql.rest.entity.ConnectorList in project ksql by confluentinc.

the class ListConnectorsExecutorTest method shouldFilterNonMatchingConnectors.

@Test
public void shouldFilterNonMatchingConnectors() {
    // Given:
    when(connectClient.connectors()).thenReturn(ConnectResponse.success(ImmutableList.of("connector", "connector2"), HttpStatus.SC_OK));
    final ConfiguredStatement<ListConnectors> statement = ConfiguredStatement.of(PreparedStatement.of("", new ListConnectors(Optional.empty(), Scope.SINK)), SessionConfig.of(new KsqlConfig(ImmutableMap.of()), ImmutableMap.of()));
    // When:
    final Optional<KsqlEntity> entity = EXECUTOR.execute(statement, mock(SessionProperties.class), engine, serviceContext).getEntity();
    // Then:
    assertThat("expected response!", entity.isPresent());
    final ConnectorList connectorList = (ConnectorList) entity.get();
    assertThat(connectorList, is(new ConnectorList("", ImmutableList.of(), ImmutableList.of())));
}
Also used : KsqlConfig(io.confluent.ksql.util.KsqlConfig) ConnectorList(io.confluent.ksql.rest.entity.ConnectorList) KsqlEntity(io.confluent.ksql.rest.entity.KsqlEntity) ListConnectors(io.confluent.ksql.parser.tree.ListConnectors) Test(org.junit.Test)

Example 9 with ConnectorList

use of io.confluent.ksql.rest.entity.ConnectorList in project ksql by confluentinc.

the class ListConnectorsExecutorTest method shouldListValidConnector.

@Test
public void shouldListValidConnector() {
    // Given:
    when(connectClient.connectors()).thenReturn(ConnectResponse.success(ImmutableList.of("connector"), HttpStatus.SC_OK));
    final KsqlConfig ksqlConfig = new KsqlConfig(ImmutableMap.of());
    final ConfiguredStatement<ListConnectors> statement = ConfiguredStatement.of(PreparedStatement.of("", new ListConnectors(Optional.empty(), Scope.ALL)), 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 ConnectorList connectorList = (ConnectorList) entity.get();
    assertThat(connectorList, is(new ConnectorList("", ImmutableList.of(), ImmutableList.of(new SimpleConnectorInfo("connector", ConnectorType.SOURCE, CONNECTOR_CLASS, "RUNNING (1/2 tasks RUNNING)")))));
}
Also used : SimpleConnectorInfo(io.confluent.ksql.rest.entity.SimpleConnectorInfo) KsqlConfig(io.confluent.ksql.util.KsqlConfig) ConnectorList(io.confluent.ksql.rest.entity.ConnectorList) KsqlEntity(io.confluent.ksql.rest.entity.KsqlEntity) ListConnectors(io.confluent.ksql.parser.tree.ListConnectors) Test(org.junit.Test)

Example 10 with ConnectorList

use of io.confluent.ksql.rest.entity.ConnectorList in project ksql by confluentinc.

the class ListConnectorsExecutorTest method shouldListInvalidConnectorWithNoInfo.

@Test
public void shouldListInvalidConnectorWithNoInfo() {
    // Given:
    when(connectClient.connectors()).thenReturn(ConnectResponse.success(ImmutableList.of("connector2"), HttpStatus.SC_OK));
    final ConfiguredStatement<ListConnectors> statement = ConfiguredStatement.of(PreparedStatement.of("", new ListConnectors(Optional.empty(), Scope.ALL)), SessionConfig.of(new KsqlConfig(ImmutableMap.of()), ImmutableMap.of()));
    // When:
    final Optional<KsqlEntity> entity = EXECUTOR.execute(statement, mock(SessionProperties.class), engine, serviceContext).getEntity();
    // Then:
    assertThat("expected response!", entity.isPresent());
    final ConnectorList connectorList = (ConnectorList) entity.get();
    assertThat(connectorList, is(new ConnectorList("", ImmutableList.of(new KsqlWarning("Could not describe connector connector2: DANGER WILL ROBINSON.")), ImmutableList.of(new SimpleConnectorInfo("connector2", ConnectorType.UNKNOWN, null, null)))));
}
Also used : SimpleConnectorInfo(io.confluent.ksql.rest.entity.SimpleConnectorInfo) KsqlConfig(io.confluent.ksql.util.KsqlConfig) KsqlWarning(io.confluent.ksql.rest.entity.KsqlWarning) ConnectorList(io.confluent.ksql.rest.entity.ConnectorList) KsqlEntity(io.confluent.ksql.rest.entity.KsqlEntity) ListConnectors(io.confluent.ksql.parser.tree.ListConnectors) Test(org.junit.Test)

Aggregations

ConnectorList (io.confluent.ksql.rest.entity.ConnectorList)11 Test (org.junit.Test)9 SimpleConnectorInfo (io.confluent.ksql.rest.entity.SimpleConnectorInfo)6 ListConnectors (io.confluent.ksql.parser.tree.ListConnectors)5 KsqlEntity (io.confluent.ksql.rest.entity.KsqlEntity)5 KsqlConfig (io.confluent.ksql.util.KsqlConfig)4 KsqlEntityList (io.confluent.ksql.rest.entity.KsqlEntityList)3 IntegrationTest (io.confluent.common.utils.IntegrationTest)2 BaseApiTest (io.confluent.ksql.api.BaseApiTest)2 KsqlRestClient (io.confluent.ksql.rest.client.KsqlRestClient)2 KsqlWarning (io.confluent.ksql.rest.entity.KsqlWarning)2 ConnectorInfo (org.apache.kafka.connect.runtime.rest.entities.ConnectorInfo)2 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 KafkaResponseGetFailedException (io.confluent.ksql.exception.KafkaResponseGetFailedException)1 ParseFailedException (io.confluent.ksql.parser.exception.ParseFailedException)1 Scope (io.confluent.ksql.parser.tree.ListConnectors.Scope)1