use of io.confluent.ksql.test.tools.TestExecutorUtil.PlannedStatement in project ksql by confluentinc.
the class TestExecutorUtilTest method shouldThrowOnNextIfStatementFails.
@Test
public void shouldThrowOnNextIfStatementFails() {
// Given:
final TestCase testCase = loadTestCase(FIRST_STATEMENT_FAILS);
final Iterator<PlannedStatement> plans = TestExecutorUtil.planTestCase(ksqlEngine, testCase, ksqlConfig, serviceContext, Optional.of(serviceContext.getSchemaRegistryClient()), stubKafkaService);
// When:
final Exception e = assertThrows(KsqlStatementException.class, plans::next);
// Then:
assertThat(e.getMessage(), containsString("UNKNOWN_SOURCE does not exist"));
}
use of io.confluent.ksql.test.tools.TestExecutorUtil.PlannedStatement in project ksql by confluentinc.
the class TestExecutorUtilTest method shouldPlanTestCase.
@Test
public void shouldPlanTestCase() {
// Given:
final TestCase testCase = loadTestCase(PROJECT_AND_FILTER);
// When:
final Iterator<PlannedStatement> plans = TestExecutorUtil.planTestCase(ksqlEngine, testCase, ksqlConfig, serviceContext, Optional.of(serviceContext.getSchemaRegistryClient()), stubKafkaService);
// Then:
final List<ConfiguredKsqlPlan> asList = new LinkedList<>();
while (plans.hasNext()) {
final PlannedStatement planned = plans.next();
final ConfiguredKsqlPlan plan = planned.plan.orElseThrow(() -> new AssertionError("Should be plan"));
ksqlEngine.execute(ksqlEngine.getServiceContext(), plan);
asList.add(plan);
}
assertThat(asList.size(), is(2));
assertThat(asList.get(0).getPlan().getStatementText(), startsWith("CREATE STREAM TEST"));
assertThat(asList.get(1).getPlan().getStatementText(), startsWith("CREATE STREAM S1 AS SELECT"));
}
Aggregations