Search in sources :

Example 1 with QttTestFile

use of io.confluent.ksql.test.model.QttTestFile in project ksql by confluentinc.

the class TestExecutorUtilTest method loadTestCase.

private static TestCase loadTestCase(final String testName) {
    try {
        final QttTestFile qttTestFile = TestJsonMapper.INSTANCE.get().readValue(TEST_FILE, QttTestFile.class);
        final TestCaseNode testCaseNode = qttTestFile.tests.stream().filter(tcn -> tcn.name().equals(testName)).findFirst().orElseThrow(() -> new AssertionError("Invalid test: no test case named " + testName));
        return TestCaseBuilder.buildTests(testCaseNode, TEST_FILE.toPath(), name -> mock(TestLocation.class)).get(0);
    } catch (final Exception e) {
        throw new AssertionError("Invalid test: failed to load test " + testName, e);
    }
}
Also used : QttTestFile(io.confluent.ksql.test.model.QttTestFile) CoreMatchers.is(org.hamcrest.CoreMatchers.is) TestCaseNode(io.confluent.ksql.test.model.TestCaseNode) CoreMatchers.equalTo(org.hamcrest.CoreMatchers.equalTo) PlannedStatement(io.confluent.ksql.test.tools.TestExecutorUtil.PlannedStatement) Mock(org.mockito.Mock) Assert.assertThrows(org.junit.Assert.assertThrows) ServiceContext(io.confluent.ksql.services.ServiceContext) RunWith(org.junit.runner.RunWith) CoreMatchers.startsWith(org.hamcrest.CoreMatchers.startsWith) CoreMatchers.notNullValue(org.hamcrest.CoreMatchers.notNullValue) ConfiguredKsqlPlan(io.confluent.ksql.planner.plan.ConfiguredKsqlPlan) After(org.junit.After) StubKafkaService(io.confluent.ksql.test.tools.stubs.StubKafkaService) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) LinkedList(java.util.LinkedList) Before(org.junit.Before) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) QttTestFile(io.confluent.ksql.test.model.QttTestFile) Iterator(java.util.Iterator) KsqlEngine(io.confluent.ksql.engine.KsqlEngine) TestLocation(io.confluent.ksql.test.model.TestLocation) Test(org.junit.Test) KsqlConfig(io.confluent.ksql.util.KsqlConfig) File(java.io.File) KsqlStatementException(io.confluent.ksql.util.KsqlStatementException) List(java.util.List) Optional(java.util.Optional) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) Mockito.mock(org.mockito.Mockito.mock) TestCaseNode(io.confluent.ksql.test.model.TestCaseNode) KsqlStatementException(io.confluent.ksql.util.KsqlStatementException)

Aggregations

KsqlEngine (io.confluent.ksql.engine.KsqlEngine)1 ConfiguredKsqlPlan (io.confluent.ksql.planner.plan.ConfiguredKsqlPlan)1 ServiceContext (io.confluent.ksql.services.ServiceContext)1 QttTestFile (io.confluent.ksql.test.model.QttTestFile)1 TestCaseNode (io.confluent.ksql.test.model.TestCaseNode)1 TestLocation (io.confluent.ksql.test.model.TestLocation)1 PlannedStatement (io.confluent.ksql.test.tools.TestExecutorUtil.PlannedStatement)1 StubKafkaService (io.confluent.ksql.test.tools.stubs.StubKafkaService)1 KsqlConfig (io.confluent.ksql.util.KsqlConfig)1 KsqlStatementException (io.confluent.ksql.util.KsqlStatementException)1 File (java.io.File)1 Iterator (java.util.Iterator)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Optional (java.util.Optional)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 CoreMatchers.equalTo (org.hamcrest.CoreMatchers.equalTo)1 CoreMatchers.is (org.hamcrest.CoreMatchers.is)1 CoreMatchers.notNullValue (org.hamcrest.CoreMatchers.notNullValue)1 CoreMatchers.startsWith (org.hamcrest.CoreMatchers.startsWith)1