Search in sources :

Example 1 with TestFileContext

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

the class JsonTestLoader method buildTests.

private static <TFT extends TestFile<T>, T extends Test> Stream<T> buildTests(final Path testPath, final Class<TFT> testFileType) {
    try (InputStream stream = JsonTestLoader.class.getClassLoader().getResourceAsStream(testPath.toString());
        BufferedReader reader = new BufferedReader(new InputStreamReader(throwNotFoundIfNull(stream, testPath), UTF_8))) {
        final List<String> lines = reader.lines().collect(Collectors.toList());
        final String content = lines.stream().collect(Collectors.joining(System.lineSeparator()));
        final TFT testFile = OBJECT_MAPPER.readValue(content, testFileType);
        return testFile.buildTests(new TestFileContext(testPath, lines));
    } catch (final Exception e) {
        throw new RuntimeException("Unable to load test at path " + testPath, e);
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) TestFileContext(io.confluent.ksql.test.model.TestFileContext) BufferedReader(java.io.BufferedReader) TestFrameworkException(io.confluent.ksql.test.TestFrameworkException) IOException(java.io.IOException)

Aggregations

TestFrameworkException (io.confluent.ksql.test.TestFrameworkException)1 TestFileContext (io.confluent.ksql.test.model.TestFileContext)1 BufferedReader (java.io.BufferedReader)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1