use of io.confluent.ksql.execution.expression.tree.Literal in project ksql by confluentinc.
the class CreateSourcePropertiesTest method shouldSetValueFullSchemaName.
@Test
public void shouldSetValueFullSchemaName() {
// When:
final CreateSourceProperties properties = CreateSourceProperties.from(ImmutableMap.<String, Literal>builder().putAll(MINIMUM_VALID_PROPS).put(CommonCreateConfigs.VALUE_FORMAT_PROPERTY, new StringLiteral("Protobuf")).put(CommonCreateConfigs.VALUE_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.Literal in project ksql by confluentinc.
the class CreateSourcePropertiesTest method shouldSetReplicasFromNumber.
@Test
public void shouldSetReplicasFromNumber() {
// When:
final CreateSourceProperties properties = CreateSourceProperties.from(ImmutableMap.<String, Literal>builder().putAll(MINIMUM_VALID_PROPS).put(CommonCreateConfigs.SOURCE_NUMBER_OF_REPLICAS, new IntegerLiteral(2)).build());
// Then:
assertThat(properties.getReplicas(), is(Optional.of((short) 2)));
}
use of io.confluent.ksql.execution.expression.tree.Literal in project ksql by confluentinc.
the class CreateSourcePropertiesTest method shouldThrowIfValueFormatAndFormatProvided.
@Test
public void shouldThrowIfValueFormatAndFormatProvided() {
// When:
final Exception e = assertThrows(KsqlException.class, () -> CreateSourceProperties.from(ImmutableMap.<String, Literal>builder().putAll(MINIMUM_VALID_PROPS).put(VALUE_FORMAT_PROPERTY, new StringLiteral("JSON")).put(FORMAT_PROPERTY, new StringLiteral("KAFKA")).build()));
// Then:
assertThat(e.getMessage(), containsString("Cannot supply both 'VALUE_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.Literal in project ksql by confluentinc.
the class CreateSourcePropertiesTest method shouldSetAvroNameOnAvroKeyFormat.
@Test
public void shouldSetAvroNameOnAvroKeyFormat() {
// Given:
final CreateSourceProperties props = CreateSourceProperties.from(ImmutableMap.<String, Literal>builder().putAll(MINIMUM_VALID_PROPS).put(FORMAT_PROPERTY, new StringLiteral("AVRO")).build());
// When / Then:
assertThat(props.getKeyFormat(SourceName.of("foo")).get().getFormat(), is("AVRO"));
assertThat(props.getKeyFormat(SourceName.of("foo")).get().getProperties(), hasEntry(ConnectProperties.FULL_SCHEMA_NAME, "io.confluent.ksql.avro_schemas.FooKey"));
}
use of io.confluent.ksql.execution.expression.tree.Literal in project ksql by confluentinc.
the class CreateSourcePropertiesTest method shouldIncludeOnlyProvidedPropsInToString.
@Test
public void shouldIncludeOnlyProvidedPropsInToString() {
// Given:
final CreateSourceProperties props = CreateSourceProperties.from(ImmutableMap.<String, Literal>builder().putAll(MINIMUM_VALID_PROPS).put("Wrap_Single_value", new StringLiteral("True")).build());
// When:
final String sql = props.toString();
// Then:
assertThat(sql, is("KAFKA_TOPIC='foo', WRAP_SINGLE_VALUE='True'"));
}
Aggregations