use of io.confluent.ksql.parser.tree.Expression in project ksql by confluentinc.
the class KsqlResourceTest method testInstantRegisterTopic.
@Test
public void testInstantRegisterTopic() throws Exception {
KsqlResource testResource = TestKsqlResourceUtil.get(ksqlEngine, ksqlRestConfig);
final String ksqlTopic = "FOO";
final String kafkaTopic = "bar";
final String format = "json";
final String ksqlString = String.format("REGISTER TOPIC %s WITH (kafka_topic='%s', value_format='%s');", ksqlTopic, kafkaTopic, format);
final Map<String, Expression> createTopicProperties = new HashMap<>();
createTopicProperties.put(DdlConfig.KAFKA_TOPIC_NAME_PROPERTY, new StringLiteral(kafkaTopic));
createTopicProperties.put(DdlConfig.VALUE_FORMAT_PROPERTY, new StringLiteral(format));
final RegisterTopic ksqlStatement = new RegisterTopic(QualifiedName.of(ksqlTopic), false, createTopicProperties);
final CommandId commandId = new CommandId(CommandId.Type.TOPIC, ksqlTopic, CommandId.Action.CREATE);
final CommandStatus commandStatus = new CommandStatus(CommandStatus.Status.QUEUED, "Statement written to command topic");
final CommandStatusEntity expectedCommandStatusEntity = new CommandStatusEntity(ksqlString, commandId, commandStatus);
final Map<String, Object> streamsProperties = Collections.emptyMap();
KsqlEntity testKsqlEntity = makeSingleRequest(testResource, ksqlString, ksqlStatement, streamsProperties, KsqlEntity.class);
assertEquals(expectedCommandStatusEntity, testKsqlEntity);
}
Aggregations