Search in sources :

Example 21 with StringLiteral

use of io.confluent.ksql.parser.tree.StringLiteral 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);
}
Also used : HashMap(java.util.HashMap) RegisterTopic(io.confluent.ksql.parser.tree.RegisterTopic) KsqlEntity(io.confluent.ksql.rest.entity.KsqlEntity) CommandStatusEntity(io.confluent.ksql.rest.entity.CommandStatusEntity) StringLiteral(io.confluent.ksql.parser.tree.StringLiteral) Expression(io.confluent.ksql.parser.tree.Expression) CommandStatus(io.confluent.ksql.rest.entity.CommandStatus) CommandId(io.confluent.ksql.rest.server.computation.CommandId) Test(org.junit.Test)

Aggregations

StringLiteral (io.confluent.ksql.parser.tree.StringLiteral)21 Test (org.junit.Test)16 Expression (io.confluent.ksql.parser.tree.Expression)8 HashMap (java.util.HashMap)7 LongLiteral (io.confluent.ksql.parser.tree.LongLiteral)5 TableElement (io.confluent.ksql.parser.tree.TableElement)5 CreateTable (io.confluent.ksql.parser.tree.CreateTable)4 FunctionCall (io.confluent.ksql.parser.tree.FunctionCall)4 WhenClause (io.confluent.ksql.parser.tree.WhenClause)4 KsqlException (io.confluent.ksql.util.KsqlException)4 SearchedCaseExpression (io.confluent.ksql.parser.tree.SearchedCaseExpression)3 SimpleCaseExpression (io.confluent.ksql.parser.tree.SimpleCaseExpression)3 CreateStream (io.confluent.ksql.parser.tree.CreateStream)2 HoppingWindowExpression (io.confluent.ksql.parser.tree.HoppingWindowExpression)2 LambdaExpression (io.confluent.ksql.parser.tree.LambdaExpression)2 LogicalBinaryExpression (io.confluent.ksql.parser.tree.LogicalBinaryExpression)2 NodeLocation (io.confluent.ksql.parser.tree.NodeLocation)2 RegisterTopic (io.confluent.ksql.parser.tree.RegisterTopic)2 TumblingWindowExpression (io.confluent.ksql.parser.tree.TumblingWindowExpression)2 WindowExpression (io.confluent.ksql.parser.tree.WindowExpression)2