use of io.confluent.ksql.util.PersistentQueryMetadata in project ksql by confluentinc.
the class JsonFormatTest method executePersistentQuery.
private void executePersistentQuery(String queryString) throws Exception {
final QueryMetadata queryMetadata = ksqlEngine.buildMultipleQueries(queryString, Collections.emptyMap()).get(0);
queryMetadata.getKafkaStreams().start();
queryId = ((PersistentQueryMetadata) queryMetadata).getId();
}
use of io.confluent.ksql.util.PersistentQueryMetadata in project ksql by confluentinc.
the class SecureIntegrationTest method executePersistentQuery.
private void executePersistentQuery(final String queryString, final Object... params) throws Exception {
final String query = String.format(queryString, params);
final QueryMetadata queryMetadata = ksqlEngine.buildMultipleQueries(query, Collections.emptyMap()).get(0);
queryMetadata.getKafkaStreams().start();
queryId = ((PersistentQueryMetadata) queryMetadata).getId();
}
use of io.confluent.ksql.util.PersistentQueryMetadata in project ksql by confluentinc.
the class KsqlContextTest method getQueryMetadata.
private List<QueryMetadata> getQueryMetadata(QueryId queryid, DataSource.DataSourceType type) {
KafkaStreams queryStreams = mock(KafkaStreams.class);
queryStreams.start();
expectLastCall();
PersistentQueryMetadata persistentQueryMetadata = new PersistentQueryMetadata(queryid.toString(), queryStreams, null, "", queryid, type, "KSQL_query_" + queryid, null, null, null, null);
return Arrays.asList(persistentQueryMetadata);
}
use of io.confluent.ksql.util.PersistentQueryMetadata in project ksql by confluentinc.
the class KsqlContextTest method shouldRunSimpleStatements.
@Test
public void shouldRunSimpleStatements() throws Exception {
AdminClient adminClient = mock(AdminClient.class);
KafkaTopicClient kafkaTopicClient = mock(KafkaTopicClientImpl.class);
KsqlEngine ksqlEngine = mock(KsqlEngine.class);
Map<QueryId, PersistentQueryMetadata> liveQueryMap = new HashMap<>();
KsqlContext ksqlContext = new KsqlContext(adminClient, kafkaTopicClient, ksqlEngine);
expect(ksqlEngine.buildMultipleQueries(statement1, Collections.emptyMap())).andReturn(Collections.emptyList());
expect(ksqlEngine.buildMultipleQueries(statement2, Collections.emptyMap())).andReturn(getQueryMetadata(new QueryId("CSAS_BIGORDERS"), DataSource.DataSourceType.KSTREAM));
expect(ksqlEngine.getPersistentQueries()).andReturn(liveQueryMap);
replay(ksqlEngine);
ksqlContext.sql(statement1);
ksqlContext.sql(statement2);
verify(ksqlEngine);
}
use of io.confluent.ksql.util.PersistentQueryMetadata in project ksql by confluentinc.
the class KsqlEngineTest method shouldCreatePersistentQueries.
@Test
public void shouldCreatePersistentQueries() throws Exception {
final List<QueryMetadata> queries = ksqlEngine.createQueries("create table bar as select * from test2;" + "create table foo as select * from test2;");
assertThat(queries.size(), equalTo(2));
final PersistentQueryMetadata queryOne = (PersistentQueryMetadata) queries.get(0);
final PersistentQueryMetadata queryTwo = (PersistentQueryMetadata) queries.get(1);
assertThat(queryOne.getEntity(), equalTo("BAR"));
assertThat(queryTwo.getEntity(), equalTo("FOO"));
}
Aggregations