use of io.confluent.ksql.execution.expression.tree.Literal 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.Literal in project ksql by confluentinc.
the class CreateSourcePropertiesTest method shouldThrowIfKeyFormatAndFormatProvided.
@Test
public void shouldThrowIfKeyFormatAndFormatProvided() {
// When:
final Exception e = assertThrows(KsqlException.class, () -> CreateSourceProperties.from(ImmutableMap.<String, Literal>builder().putAll(MINIMUM_VALID_PROPS).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.Literal in project ksql by confluentinc.
the class CreateSourcePropertiesTest method shouldSetNumericPropertyFromStringLiteral.
@Test
public void shouldSetNumericPropertyFromStringLiteral() {
// When:
final CreateSourceProperties properties = CreateSourceProperties.from(ImmutableMap.<String, Literal>builder().putAll(MINIMUM_VALID_PROPS).put(CommonCreateConfigs.SOURCE_NUMBER_OF_REPLICAS, new StringLiteral("3")).build());
// Then:
assertThat(properties.getReplicas(), is(Optional.of((short) 3)));
}
use of io.confluent.ksql.execution.expression.tree.Literal in project ksql by confluentinc.
the class CreateSourcePropertiesTest method shouldThrowIfValueSchemaNameAndAvroSchemaNameProvided.
@Test
public void shouldThrowIfValueSchemaNameAndAvroSchemaNameProvided() {
// When:
final Exception e = assertThrows(KsqlException.class, () -> CreateSourceProperties.from(ImmutableMap.<String, Literal>builder().putAll(MINIMUM_VALID_PROPS).put(VALUE_SCHEMA_FULL_NAME, new StringLiteral("value_schema")).put(VALUE_AVRO_SCHEMA_FULL_NAME, new StringLiteral("value_schema")).build()));
// Then:
assertThat(e.getMessage(), is("Cannot supply both 'VALUE_AVRO_SCHEMA_FULL_NAME' " + "and 'VALUE_SCHEMA_FULL_NAME' properties. Please only set 'VALUE_SCHEMA_FULL_NAME'."));
}
use of io.confluent.ksql.execution.expression.tree.Literal in project ksql by confluentinc.
the class DefaultFormatInjectorTest method givenSourceProps.
private void givenSourceProps(final Map<String, Literal> additionalProps) {
final HashMap<String, Literal> props = new HashMap<>();
props.put("KAFKA_TOPIC", new StringLiteral("some_topic"));
props.putAll(additionalProps);
when(createSource.getProperties()).thenReturn(CreateSourceProperties.from(props));
}
Aggregations