Search in sources :

Example 11 with RunningQuery

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

the class ConsoleTest method testPrintSourceDescriptionWithHeaders.

@Test
public void testPrintSourceDescriptionWithHeaders() {
    // Given:
    final List<FieldInfo> fields = buildTestSchema(Optional.empty(), SqlTypes.BOOLEAN, SqlTypes.INTEGER, SqlTypes.BIGINT, SqlTypes.DOUBLE, SqlTypes.STRING, SqlTypes.array(SqlTypes.STRING), SqlTypes.map(SqlTypes.STRING, SqlTypes.BIGINT), SqlTypes.struct().field("a", SqlTypes.DOUBLE).build());
    final List<RunningQuery> readQueries = ImmutableList.of(new RunningQuery("read query", ImmutableSet.of("sink1"), ImmutableSet.of("sink1 topic"), new QueryId("readId"), queryStatusCount, KsqlConstants.KsqlQueryType.PERSISTENT));
    final List<RunningQuery> writeQueries = ImmutableList.of(new RunningQuery("write query", ImmutableSet.of("sink2"), ImmutableSet.of("sink2 topic"), new QueryId("writeId"), queryStatusCount, KsqlConstants.KsqlQueryType.PERSISTENT));
    final KsqlEntityList entityList = new KsqlEntityList(ImmutableList.of(new SourceDescriptionEntity("some sql", buildSourceDescription(readQueries, writeQueries, fields, false), Collections.emptyList())));
    // When:
    console.printKsqlEntityList(entityList);
    // Then:
    final String output = terminal.getOutputString();
    Approvals.verify(output, approvalOptions);
}
Also used : KsqlEntityList(io.confluent.ksql.rest.entity.KsqlEntityList) RunningQuery(io.confluent.ksql.rest.entity.RunningQuery) QueryId(io.confluent.ksql.query.QueryId) SourceDescriptionEntity(io.confluent.ksql.rest.entity.SourceDescriptionEntity) Matchers.containsString(org.hamcrest.Matchers.containsString) FieldInfo(io.confluent.ksql.rest.entity.FieldInfo) Test(org.junit.Test)

Example 12 with RunningQuery

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

the class ConsoleTest method testPrintSourceDescription.

@Test
public void testPrintSourceDescription() {
    // Given:
    final List<FieldInfo> fields = buildTestSchema(SqlTypes.BOOLEAN, SqlTypes.INTEGER, SqlTypes.BIGINT, SqlTypes.DOUBLE, SqlTypes.STRING, SqlTypes.array(SqlTypes.STRING), SqlTypes.map(SqlTypes.STRING, SqlTypes.BIGINT), SqlTypes.struct().field("a", SqlTypes.DOUBLE).build());
    final List<RunningQuery> readQueries = ImmutableList.of(new RunningQuery("read query", ImmutableSet.of("sink1"), ImmutableSet.of("sink1 topic"), new QueryId("readId"), queryStatusCount, KsqlConstants.KsqlQueryType.PERSISTENT));
    final List<RunningQuery> writeQueries = ImmutableList.of(new RunningQuery("write query", ImmutableSet.of("sink2"), ImmutableSet.of("sink2 topic"), new QueryId("writeId"), queryStatusCount, KsqlConstants.KsqlQueryType.PERSISTENT));
    final KsqlEntityList entityList = new KsqlEntityList(ImmutableList.of(new SourceDescriptionEntity("some sql", buildSourceDescription(readQueries, writeQueries, fields, false), Collections.emptyList())));
    // When:
    console.printKsqlEntityList(entityList);
    // Then:
    final String output = terminal.getOutputString();
    Approvals.verify(output, approvalOptions);
}
Also used : KsqlEntityList(io.confluent.ksql.rest.entity.KsqlEntityList) RunningQuery(io.confluent.ksql.rest.entity.RunningQuery) QueryId(io.confluent.ksql.query.QueryId) SourceDescriptionEntity(io.confluent.ksql.rest.entity.SourceDescriptionEntity) Matchers.containsString(org.hamcrest.Matchers.containsString) FieldInfo(io.confluent.ksql.rest.entity.FieldInfo) Test(org.junit.Test)

Example 13 with RunningQuery

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

the class QueriesTableBuilderTest method shouldBuildQueriesTableWithNewlines.

@Test
public void shouldBuildQueriesTableWithNewlines() {
    // Given:
    final RunningQuery query = new RunningQuery("CREATE STREAM S2 AS SELECT *\nFROM S1\nEMIT CHANGES;", ImmutableSet.of("S2"), ImmutableSet.of("S2"), new QueryId("CSAS_S2_0"), queryStatusCount, KsqlConstants.KsqlQueryType.PERSISTENT);
    // When:
    final Table table = buildTableWithSingleQuery(query);
    // Then:
    assertThat(table.headers(), contains("Query ID", "Query Type", "Status", "Sink Name", "Sink Kafka Topic", "Query String"));
    assertThat(table.rows(), hasSize(1));
    assertThat(table.rows().get(0), contains("CSAS_S2_0", KsqlConstants.KsqlQueryType.PERSISTENT.toString(), STATUS, "S2", "S2", "CREATE STREAM S2 AS SELECT * FROM S1 EMIT CHANGES;"));
}
Also used : RunningQuery(io.confluent.ksql.rest.entity.RunningQuery) Table(io.confluent.ksql.cli.console.table.Table) QueryId(io.confluent.ksql.query.QueryId) Test(org.junit.Test)

Example 14 with RunningQuery

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

the class QueriesTableBuilderTest method buildTableWithSingleQuery.

private Table buildTableWithSingleQuery(RunningQuery query) {
    List<RunningQuery> queries = new ArrayList<>();
    queries.add(query);
    final Queries entity = new Queries(null, queries);
    QueriesTableBuilder builder = new QueriesTableBuilder();
    return builder.buildTable(entity);
}
Also used : RunningQuery(io.confluent.ksql.rest.entity.RunningQuery) Queries(io.confluent.ksql.rest.entity.Queries) ArrayList(java.util.ArrayList)

Example 15 with RunningQuery

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

the class QueriesTableBuilderTest method shouldBuildQueriesTable.

@Test
public void shouldBuildQueriesTable() {
    // Given:
    final String exampleQuery = "select * from test_stream emit changes";
    final RunningQuery query = new RunningQuery(exampleQuery, ImmutableSet.of("SINK"), ImmutableSet.of("SINK"), new QueryId("0"), queryStatusCount, KsqlConstants.KsqlQueryType.PUSH);
    // When:
    final Table table = buildTableWithSingleQuery(query);
    // Then:
    assertThat(table.headers(), contains("Query ID", "Query Type", "Status", "Sink Name", "Sink Kafka Topic", "Query String"));
    assertThat(table.rows(), hasSize(1));
    assertThat(table.rows().get(0), contains("0", KsqlConstants.KsqlQueryType.PUSH.toString(), STATUS, "SINK", "SINK", exampleQuery));
}
Also used : RunningQuery(io.confluent.ksql.rest.entity.RunningQuery) Table(io.confluent.ksql.cli.console.table.Table) QueryId(io.confluent.ksql.query.QueryId) Test(org.junit.Test)

Aggregations

RunningQuery (io.confluent.ksql.rest.entity.RunningQuery)25 QueryId (io.confluent.ksql.query.QueryId)16 Test (org.junit.Test)16 Queries (io.confluent.ksql.rest.entity.Queries)11 SourceDescriptionEntity (io.confluent.ksql.rest.entity.SourceDescriptionEntity)11 KsqlEntityList (io.confluent.ksql.rest.entity.KsqlEntityList)9 FieldInfo (io.confluent.ksql.rest.entity.FieldInfo)7 ArrayList (java.util.ArrayList)7 Matchers.containsString (org.hamcrest.Matchers.containsString)6 QueryOffsetSummary (io.confluent.ksql.rest.entity.QueryOffsetSummary)4 QueryStatusCount (io.confluent.ksql.rest.entity.QueryStatusCount)4 Map (java.util.Map)4 ImmutableMap (com.google.common.collect.ImmutableMap)3 BaseApiTest (io.confluent.ksql.api.BaseApiTest)3 MetricCollectors (io.confluent.ksql.metrics.MetricCollectors)3 CommandStatusEntity (io.confluent.ksql.rest.entity.CommandStatusEntity)3 KsqlEntity (io.confluent.ksql.rest.entity.KsqlEntity)3 PushQueryId (io.confluent.ksql.rest.entity.PushQueryId)3 QueryTopicOffsetSummary (io.confluent.ksql.rest.entity.QueryTopicOffsetSummary)3 SourceDescription (io.confluent.ksql.rest.entity.SourceDescription)3