Search in sources :

Example 71 with ConfiguredStatement

use of io.confluent.ksql.statement.ConfiguredStatement in project ksql by confluentinc.

the class ListPropertiesExecutorTest method shouldNotListSslProperties.

@Test
public void shouldNotListSslProperties() {
    // When:
    final PropertiesList properties = (PropertiesList) CUSTOM_EXECUTORS.listProperties().execute((ConfiguredStatement<ListProperties>) engine.configure("LIST PROPERTIES;"), mock(SessionProperties.class), engine.getEngine(), engine.getServiceContext()).getEntity().orElseThrow(IllegalStateException::new);
    // Then:
    assertThat(toMap(properties), not(hasKey(isIn(KsqlConfig.SSL_CONFIG_NAMES))));
}
Also used : ConfiguredStatement(io.confluent.ksql.statement.ConfiguredStatement) PropertiesList(io.confluent.ksql.rest.entity.PropertiesList) Test(org.junit.Test)

Example 72 with ConfiguredStatement

use of io.confluent.ksql.statement.ConfiguredStatement in project ksql by confluentinc.

the class ListPropertiesExecutorTest method shouldListPropertiesWithOverrides.

@Test
public void shouldListPropertiesWithOverrides() {
    // When:
    final PropertiesList properties = (PropertiesList) CUSTOM_EXECUTORS.listProperties().execute((ConfiguredStatement<ListProperties>) engine.configure("LIST PROPERTIES;").withConfigOverrides(ImmutableMap.of("ksql.streams.auto.offset.reset", "latest")), mock(SessionProperties.class), engine.getEngine(), engine.getServiceContext()).getEntity().orElseThrow(IllegalStateException::new);
    // Then:
    assertThat(properties.getProperties(), hasItem(new Property("ksql.streams.auto.offset.reset", "KSQL", "latest")));
    assertThat(properties.getOverwrittenProperties(), hasItem("ksql.streams.auto.offset.reset"));
}
Also used : ConfiguredStatement(io.confluent.ksql.statement.ConfiguredStatement) PropertiesList(io.confluent.ksql.rest.entity.PropertiesList) Property(io.confluent.ksql.rest.entity.PropertiesList.Property) Test(org.junit.Test)

Example 73 with ConfiguredStatement

use of io.confluent.ksql.statement.ConfiguredStatement in project ksql by confluentinc.

the class ListSourceExecutorTest method shouldShowTables.

@Test
public void shouldShowTables() {
    // Given:
    final KsqlTable<?> table1 = engine.givenSource(DataSourceType.KTABLE, "table1");
    final KsqlTable<?> table2 = engine.givenSource(DataSourceType.KTABLE, "table2");
    engine.givenSource(DataSourceType.KSTREAM, "stream");
    // When:
    final TablesList descriptionList = (TablesList) CUSTOM_EXECUTORS.listTables().execute((ConfiguredStatement<ListTables>) engine.configure("LIST TABLES;"), SESSION_PROPERTIES, engine.getEngine(), engine.getServiceContext()).getEntity().orElseThrow(IllegalStateException::new);
    // Then:
    assertThat(descriptionList.getTables(), containsInAnyOrder(new SourceInfo.Table(table1.getName().toString(FormatOptions.noEscape()), table1.getKsqlTopic().getKafkaTopicName(), table2.getKsqlTopic().getKeyFormat().getFormat(), table1.getKsqlTopic().getValueFormat().getFormat(), table1.getKsqlTopic().getKeyFormat().isWindowed()), new SourceInfo.Table(table2.getName().toString(FormatOptions.noEscape()), table2.getKsqlTopic().getKafkaTopicName(), table2.getKsqlTopic().getKeyFormat().getFormat(), table2.getKsqlTopic().getValueFormat().getFormat(), table2.getKsqlTopic().getKeyFormat().isWindowed())));
}
Also used : ConfiguredStatement(io.confluent.ksql.statement.ConfiguredStatement) KsqlTable(io.confluent.ksql.metastore.model.KsqlTable) TablesList(io.confluent.ksql.rest.entity.TablesList) Test(org.junit.Test)

Example 74 with ConfiguredStatement

use of io.confluent.ksql.statement.ConfiguredStatement in project ksql by confluentinc.

the class ListSourceExecutorTest method shouldDescribeStreams.

@Test
public void shouldDescribeStreams() {
    // Given:
    final KsqlStream<?> stream1 = engine.givenSource(DataSourceType.KSTREAM, "stream1");
    final KsqlStream<?> stream2 = engine.givenSource(DataSourceType.KSTREAM, "stream2", ImmutableSet.of(SourceName.of("stream1")));
    engine.givenSource(DataSourceType.KTABLE, "table");
    // When:
    final SourceDescriptionList descriptionList = (SourceDescriptionList) CUSTOM_EXECUTORS.describeStreams().execute((ConfiguredStatement<DescribeStreams>) engine.configure("DESCRIBE STREAMS;"), SESSION_PROPERTIES, engine.getEngine(), engine.getServiceContext()).getEntity().orElseThrow(IllegalStateException::new);
    // Then:
    assertThat(descriptionList.getSourceDescriptions(), containsInAnyOrder(SourceDescriptionFactory.create(stream1, false, ImmutableList.of(), ImmutableList.of(), Optional.of(topicWith1PartitionAndRfOf1), ImmutableList.of(), ImmutableList.of("stream2"), new MetricCollectors()), SourceDescriptionFactory.create(stream2, false, ImmutableList.of(), ImmutableList.of(), Optional.of(topicWith1PartitionAndRfOf1), ImmutableList.of(), ImmutableList.of(), new MetricCollectors())));
}
Also used : ConfiguredStatement(io.confluent.ksql.statement.ConfiguredStatement) SourceDescriptionList(io.confluent.ksql.rest.entity.SourceDescriptionList) MetricCollectors(io.confluent.ksql.metrics.MetricCollectors) Test(org.junit.Test)

Example 75 with ConfiguredStatement

use of io.confluent.ksql.statement.ConfiguredStatement in project ksql by confluentinc.

the class ListSourceExecutorTest method shouldShowStreamsExtended.

@Test
public void shouldShowStreamsExtended() {
    // Given:
    final KsqlStream<?> stream1 = engine.givenSource(DataSourceType.KSTREAM, "stream1");
    final KsqlStream<?> stream2 = engine.givenSource(DataSourceType.KSTREAM, "stream2", ImmutableSet.of(SourceName.of("stream1")));
    engine.givenSource(DataSourceType.KTABLE, "table");
    // When:
    final SourceDescriptionList descriptionList = (SourceDescriptionList) CUSTOM_EXECUTORS.listStreams().execute((ConfiguredStatement<ListStreams>) engine.configure("SHOW STREAMS EXTENDED;"), SESSION_PROPERTIES, engine.getEngine(), engine.getServiceContext()).getEntity().orElseThrow(IllegalStateException::new);
    // Then:
    assertThat(descriptionList.getSourceDescriptions(), containsInAnyOrder(SourceDescriptionFactory.create(stream1, true, ImmutableList.of(), ImmutableList.of(), Optional.of(topicWith1PartitionAndRfOf1), ImmutableList.of(), ImmutableList.of("stream2"), new MetricCollectors()), SourceDescriptionFactory.create(stream2, true, ImmutableList.of(), ImmutableList.of(), Optional.of(topicWith1PartitionAndRfOf1), ImmutableList.of(), ImmutableList.of(), new MetricCollectors())));
}
Also used : ConfiguredStatement(io.confluent.ksql.statement.ConfiguredStatement) SourceDescriptionList(io.confluent.ksql.rest.entity.SourceDescriptionList) MetricCollectors(io.confluent.ksql.metrics.MetricCollectors) Test(org.junit.Test)

Aggregations

ConfiguredStatement (io.confluent.ksql.statement.ConfiguredStatement)84 Test (org.junit.Test)57 KsqlException (io.confluent.ksql.util.KsqlException)23 Statement (io.confluent.ksql.parser.tree.Statement)22 PreparedStatement (io.confluent.ksql.parser.KsqlParser.PreparedStatement)19 Optional (java.util.Optional)19 ServiceContext (io.confluent.ksql.services.ServiceContext)18 PersistentQueryMetadata (io.confluent.ksql.util.PersistentQueryMetadata)18 KsqlEngine (io.confluent.ksql.engine.KsqlEngine)17 KsqlConfig (io.confluent.ksql.util.KsqlConfig)16 Map (java.util.Map)14 DataSource (io.confluent.ksql.metastore.model.DataSource)12 QueryId (io.confluent.ksql.query.QueryId)12 LogicalSchema (io.confluent.ksql.schema.ksql.LogicalSchema)12 Collectors (java.util.stream.Collectors)12 ImmutableMap (com.google.common.collect.ImmutableMap)11 ListQueries (io.confluent.ksql.parser.tree.ListQueries)11 KsqlStatementException (io.confluent.ksql.util.KsqlStatementException)11 List (java.util.List)11 Query (io.confluent.ksql.parser.tree.Query)10