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);
}
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);
}
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;"));
}
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);
}
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));
}
Aggregations