Search in sources :

Example 1 with PlannedStatement

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"));
}
Also used : PlannedStatement(io.confluent.ksql.test.tools.TestExecutorUtil.PlannedStatement) KsqlStatementException(io.confluent.ksql.util.KsqlStatementException) Test(org.junit.Test)

Example 2 with PlannedStatement

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"));
}
Also used : ConfiguredKsqlPlan(io.confluent.ksql.planner.plan.ConfiguredKsqlPlan) PlannedStatement(io.confluent.ksql.test.tools.TestExecutorUtil.PlannedStatement) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Aggregations

PlannedStatement (io.confluent.ksql.test.tools.TestExecutorUtil.PlannedStatement)2 Test (org.junit.Test)2 ConfiguredKsqlPlan (io.confluent.ksql.planner.plan.ConfiguredKsqlPlan)1 KsqlStatementException (io.confluent.ksql.util.KsqlStatementException)1 LinkedList (java.util.LinkedList)1