use of io.confluent.ksql.execution.expression.tree.StringLiteral in project ksql by confluentinc.
the class CreateSourcePropertiesTest method shouldSetValidAvroSchemaName.
@Test
public void shouldSetValidAvroSchemaName() {
// When:
final CreateSourceProperties properties = CreateSourceProperties.from(ImmutableMap.<String, Literal>builder().putAll(MINIMUM_VALID_PROPS).put(CommonCreateConfigs.VALUE_FORMAT_PROPERTY, new StringLiteral("AvRo")).put(CommonCreateConfigs.VALUE_AVRO_SCHEMA_FULL_NAME, new StringLiteral("schema")).build());
// Then:
assertThat(properties.getValueFormat().map(FormatInfo::getProperties).map(props -> props.get(ConnectProperties.FULL_SCHEMA_NAME)), is(Optional.of("schema")));
}
use of io.confluent.ksql.execution.expression.tree.StringLiteral in project ksql by confluentinc.
the class CreateSourcePropertiesTest method shouldThrowOnConstructionOnInvalidDuration.
@Test
public void shouldThrowOnConstructionOnInvalidDuration() {
// Given:
final Map<String, Literal> props = ImmutableMap.<String, Literal>builder().putAll(MINIMUM_VALID_PROPS).put(CreateConfigs.WINDOW_TYPE_PROPERTY, new StringLiteral("HOPPING")).put(CreateConfigs.WINDOW_SIZE_PROPERTY, new StringLiteral("2 HOURS")).build();
when(durationParser.apply(any())).thenThrow(new IllegalArgumentException("a failure reason"));
// When:
final Exception e = assertThrows(KsqlException.class, () -> new CreateSourceProperties(props, durationParser));
// Then:
assertThat(e.getMessage(), containsString("Error in WITH clause property 'WINDOW_SIZE': " + "a failure reason" + System.lineSeparator() + "Example valid value: '10 SECONDS'"));
}
use of io.confluent.ksql.execution.expression.tree.StringLiteral in project ksql by confluentinc.
the class CreateSourceAsPropertiesTest method shouldProperlyImplementEqualsAndHashCode.
@Test
public void shouldProperlyImplementEqualsAndHashCode() {
final ImmutableMap<String, Literal> someConfig = ImmutableMap.of(VALUE_AVRO_SCHEMA_FULL_NAME, new StringLiteral("schema"));
new EqualsTester().addEqualityGroup(CreateSourceAsProperties.from(someConfig), CreateSourceAsProperties.from(someConfig)).addEqualityGroup(CreateSourceAsProperties.from(ImmutableMap.of())).testEquals();
}
use of io.confluent.ksql.execution.expression.tree.StringLiteral in project ksql by confluentinc.
the class CreateSourceAsPropertiesTest method shouldThrowIfKeyFormatAndFormatProvided.
@Test
public void shouldThrowIfKeyFormatAndFormatProvided() {
// When:
final Exception e = assertThrows(KsqlException.class, () -> CreateSourceAsProperties.from(ImmutableMap.<String, Literal>builder().put(KEY_FORMAT_PROPERTY, new StringLiteral("KAFKA")).put(FORMAT_PROPERTY, new StringLiteral("JSON")).build()));
// Then:
assertThat(e.getMessage(), containsString("Cannot supply both 'KEY_FORMAT' and 'FORMAT' properties, " + "as 'FORMAT' sets both key and value formats."));
assertThat(e.getMessage(), containsString("Either use just 'FORMAT', or use 'KEY_FORMAT' and 'VALUE_FORMAT'."));
}
use of io.confluent.ksql.execution.expression.tree.StringLiteral in project ksql by confluentinc.
the class CreateSourceAsPropertiesTest method shouldIncludeOnlyProvidedPropsInToString.
@Test
public void shouldIncludeOnlyProvidedPropsInToString() {
// Given:
final CreateSourceAsProperties props = CreateSourceAsProperties.from(ImmutableMap.of("Wrap_Single_value", new StringLiteral("True"), "KAFKA_TOPIC", new StringLiteral("foo")));
// When:
final String sql = props.toString();
// Then:
assertThat(sql, is("KAFKA_TOPIC='foo', WRAP_SINGLE_VALUE='True'"));
}
Aggregations