Search in sources :

Example 31 with Literal

use of io.confluent.ksql.execution.expression.tree.Literal in project ksql by confluentinc.

the class CreateSourcePropertiesTest method shouldSetValidTimestampFormat.

@Test
public void shouldSetValidTimestampFormat() {
    // When:
    final CreateSourceProperties properties = CreateSourceProperties.from(ImmutableMap.<String, Literal>builder().putAll(MINIMUM_VALID_PROPS).put(CommonCreateConfigs.TIMESTAMP_FORMAT_PROPERTY, new StringLiteral("yyyy-MM-dd'T'HH:mm:ss.SSS")).build());
    // Then:
    assertThat(properties.getTimestampFormat(), is(Optional.of("yyyy-MM-dd'T'HH:mm:ss.SSS")));
}
Also used : StringLiteral(io.confluent.ksql.execution.expression.tree.StringLiteral) StringLiteral(io.confluent.ksql.execution.expression.tree.StringLiteral) IntegerLiteral(io.confluent.ksql.execution.expression.tree.IntegerLiteral) Literal(io.confluent.ksql.execution.expression.tree.Literal) BooleanLiteral(io.confluent.ksql.execution.expression.tree.BooleanLiteral) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 32 with Literal

use of io.confluent.ksql.execution.expression.tree.Literal in project ksql by confluentinc.

the class CreateSourcePropertiesTest method shouldSetWrapSingleValues.

@Test
public void shouldSetWrapSingleValues() {
    // When:
    final CreateSourceProperties properties = CreateSourceProperties.from(ImmutableMap.<String, Literal>builder().putAll(MINIMUM_VALID_PROPS).put(CommonCreateConfigs.WRAP_SINGLE_VALUE, new BooleanLiteral("true")).build());
    // Then:
    assertThat(properties.getValueSerdeFeatures(), is(SerdeFeatures.of(SerdeFeature.WRAP_SINGLES)));
}
Also used : BooleanLiteral(io.confluent.ksql.execution.expression.tree.BooleanLiteral) StringLiteral(io.confluent.ksql.execution.expression.tree.StringLiteral) IntegerLiteral(io.confluent.ksql.execution.expression.tree.IntegerLiteral) Literal(io.confluent.ksql.execution.expression.tree.Literal) BooleanLiteral(io.confluent.ksql.execution.expression.tree.BooleanLiteral) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 33 with Literal

use of io.confluent.ksql.execution.expression.tree.Literal in project ksql by confluentinc.

the class CreateSourcePropertiesTest method shouldSetValidTimestampName.

@Test
public void shouldSetValidTimestampName() {
    // When:
    final CreateSourceProperties properties = CreateSourceProperties.from(ImmutableMap.<String, Literal>builder().putAll(MINIMUM_VALID_PROPS).put(CommonCreateConfigs.TIMESTAMP_NAME_PROPERTY, new StringLiteral("ts")).build());
    // Then:
    assertThat(properties.getTimestampColumnName(), is(Optional.of(ColumnName.of("TS"))));
}
Also used : StringLiteral(io.confluent.ksql.execution.expression.tree.StringLiteral) StringLiteral(io.confluent.ksql.execution.expression.tree.StringLiteral) IntegerLiteral(io.confluent.ksql.execution.expression.tree.IntegerLiteral) Literal(io.confluent.ksql.execution.expression.tree.Literal) BooleanLiteral(io.confluent.ksql.execution.expression.tree.BooleanLiteral) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 34 with Literal

use of io.confluent.ksql.execution.expression.tree.Literal in project ksql by confluentinc.

the class CreateSourcePropertiesTest method shouldFailIfNoKafkaTopicName.

@Test
public void shouldFailIfNoKafkaTopicName() {
    // Given:
    final HashMap<String, Literal> props = new HashMap<>(MINIMUM_VALID_PROPS);
    props.remove(KAFKA_TOPIC_NAME_PROPERTY);
    // When:
    final Exception e = assertThrows(KsqlException.class, () -> CreateSourceProperties.from(props));
    // Then:
    assertThat(e.getMessage(), containsString("Missing required property \"KAFKA_TOPIC\" which has no default value."));
}
Also used : HashMap(java.util.HashMap) StringLiteral(io.confluent.ksql.execution.expression.tree.StringLiteral) IntegerLiteral(io.confluent.ksql.execution.expression.tree.IntegerLiteral) Literal(io.confluent.ksql.execution.expression.tree.Literal) BooleanLiteral(io.confluent.ksql.execution.expression.tree.BooleanLiteral) Matchers.containsString(org.hamcrest.Matchers.containsString) KsqlException(io.confluent.ksql.util.KsqlException) Test(org.junit.Test)

Example 35 with Literal

use of io.confluent.ksql.execution.expression.tree.Literal in project ksql by confluentinc.

the class CreateSourcePropertiesTest method shouldSetBooleanPropertyFromStringLiteral.

@Test
public void shouldSetBooleanPropertyFromStringLiteral() {
    // When:
    final CreateSourceProperties properties = CreateSourceProperties.from(ImmutableMap.<String, Literal>builder().putAll(MINIMUM_VALID_PROPS).put(CommonCreateConfigs.WRAP_SINGLE_VALUE, new StringLiteral("true")).build());
    // Then:
    assertThat(properties.getValueSerdeFeatures(), is(SerdeFeatures.of(SerdeFeature.WRAP_SINGLES)));
}
Also used : StringLiteral(io.confluent.ksql.execution.expression.tree.StringLiteral) StringLiteral(io.confluent.ksql.execution.expression.tree.StringLiteral) IntegerLiteral(io.confluent.ksql.execution.expression.tree.IntegerLiteral) Literal(io.confluent.ksql.execution.expression.tree.Literal) BooleanLiteral(io.confluent.ksql.execution.expression.tree.BooleanLiteral) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Aggregations

Literal (io.confluent.ksql.execution.expression.tree.Literal)39 StringLiteral (io.confluent.ksql.execution.expression.tree.StringLiteral)38 IntegerLiteral (io.confluent.ksql.execution.expression.tree.IntegerLiteral)32 Test (org.junit.Test)32 BooleanLiteral (io.confluent.ksql.execution.expression.tree.BooleanLiteral)28 Matchers.containsString (org.hamcrest.Matchers.containsString)27 KsqlException (io.confluent.ksql.util.KsqlException)10 ImmutableMap (com.google.common.collect.ImmutableMap)8 CreateSourceProperties (io.confluent.ksql.parser.properties.with.CreateSourceProperties)6 StringContains.containsString (org.hamcrest.core.StringContains.containsString)5 HashMap (java.util.HashMap)4 EqualsTester (com.google.common.testing.EqualsTester)3 DecimalLiteral (io.confluent.ksql.execution.expression.tree.DecimalLiteral)3 DoubleLiteral (io.confluent.ksql.execution.expression.tree.DoubleLiteral)3 Expression (io.confluent.ksql.execution.expression.tree.Expression)3 LongLiteral (io.confluent.ksql.execution.expression.tree.LongLiteral)3 CreateTable (io.confluent.ksql.parser.tree.CreateTable)3 ImmutableMap.of (com.google.common.collect.ImmutableMap.of)2 WindowType (io.confluent.ksql.model.WindowType)2 ColumnName (io.confluent.ksql.name.ColumnName)2