use of io.confluent.ksql.execution.expression.tree.StringLiteral in project ksql by confluentinc.
the class CreateSourceAsPropertiesTest method shouldGetKeyAndValueSchemaIdFromFormat.
@Test
public void shouldGetKeyAndValueSchemaIdFromFormat() {
// Given:
final CreateSourceAsProperties props = CreateSourceAsProperties.from(ImmutableMap.<String, Literal>builder().put(FORMAT_PROPERTY, new StringLiteral("AVRO")).put(KEY_SCHEMA_ID, new IntegerLiteral(123)).put(VALUE_SCHEMA_ID, new IntegerLiteral(456)).build());
// When / Then:
assertThat(props.getKeyFormatProperties("foo", "Avro"), hasEntry(ConnectProperties.SCHEMA_ID, "123"));
assertThat(props.getValueFormatProperties(), hasEntry(ConnectProperties.SCHEMA_ID, "456"));
}
use of io.confluent.ksql.execution.expression.tree.StringLiteral in project ksql by confluentinc.
the class InsertIntoPropertiesTest method shoulSetQueryId.
@Test
public void shoulSetQueryId() {
// When:
final InsertIntoProperties properties = InsertIntoProperties.from(ImmutableMap.<String, Literal>builder().put(InsertIntoConfigs.QUERY_ID_PROPERTY, new StringLiteral("my_insert_query_id")).build());
// Then:
assertThat(properties.getQueryId(), is(Optional.of("MY_INSERT_QUERY_ID")));
}
use of io.confluent.ksql.execution.expression.tree.StringLiteral 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.StringLiteral in project ksql by confluentinc.
the class CreateSourcePropertiesTest method shouldSetHoppingWindow.
@Test
public void shouldSetHoppingWindow() {
// When:
final CreateSourceProperties properties = CreateSourceProperties.from(ImmutableMap.<String, Literal>builder().putAll(MINIMUM_VALID_PROPS).put(CreateConfigs.WINDOW_TYPE_PROPERTY, new StringLiteral("HoppIng")).put(CreateConfigs.WINDOW_SIZE_PROPERTY, new StringLiteral("10 Minutes")).build());
// Then:
assertThat(properties.getWindowType(), is(Optional.of(WindowType.HOPPING)));
assertThat(properties.getWindowSize(), is(Optional.of(Duration.ofMinutes(10))));
}
use of io.confluent.ksql.execution.expression.tree.StringLiteral 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)));
}
Aggregations