use of io.confluent.ksql.test.model.PostConditionsNode in project ksql by confluentinc.
the class TestCaseBuilder method createTest.
private static TestCase createTest(final TestCaseNode test, final Path originalFileName, final TestLocation location, final Optional<String> explicitFormat) {
final String testName = TestCaseBuilderUtil.buildTestName(originalFileName, test.name(), explicitFormat);
try {
final VersionBounds versionBounds = test.versionBounds().build();
final List<String> statements = TestCaseBuilderUtil.buildStatements(test.statements(), explicitFormat);
final Optional<Matcher<Throwable>> ee = test.expectedException().map(ExpectedExceptionNode::build);
final Map<String, Topic> topics = TestCaseBuilderUtil.getAllTopics(statements, test.topics().stream().map(TopicNode::build).collect(Collectors.toList()), test.outputs().stream().map(RecordNode::build).collect(Collectors.toList()), test.inputs().stream().map(RecordNode::build).collect(Collectors.toList()), new InternalFunctionRegistry(), new KsqlConfig(test.properties())).stream().collect(Collectors.toMap(t -> t.getName().toLowerCase(), t -> t));
final List<Record> inputRecords = test.inputs().stream().map(r -> {
final String topicName = r.topicName().toLowerCase();
// parse columns which value type cannot be detected without a schema
if (topics.containsKey(topicName)) {
return r.build(topics.get(topicName).getKeySchema(), topics.get(topicName).getValueSchema(), topics.get(topicName).getKeyFeatures(), topics.get(topicName).getValueFeatures());
}
return r.build();
}).collect(Collectors.toList());
final List<Record> outputRecords = test.outputs().stream().map(RecordNode::build).collect(Collectors.toList());
final PostConditions post = test.postConditions().map(PostConditionsNode::build).orElse(PostConditions.NONE);
return new TestCase(location, originalFileName, testName, versionBounds, test.properties(), topics.values(), inputRecords, outputRecords, statements, ee, post);
} catch (final Exception e) {
throw new AssertionError(testName + ": Invalid test. " + e.getMessage(), e);
}
}
Aggregations