use of io.confluent.ksql.execution.expression.tree.Literal in project ksql by confluentinc.
the class CreateSourcePropertiesTest method shouldThrowOnConstructionOnUnknownWindowType.
@Test
public void shouldThrowOnConstructionOnUnknownWindowType() {
// Given:
final Map<String, Literal> props = ImmutableMap.<String, Literal>builder().putAll(MINIMUM_VALID_PROPS).put(CreateConfigs.WINDOW_TYPE_PROPERTY, new StringLiteral("Unknown")).build();
// When:
final Exception e = assertThrows(KsqlException.class, () -> CreateSourceProperties.from(props));
// Then:
assertThat(e.getMessage(), containsString("Invalid value Unknown for property WINDOW_TYPE: " + "String must be one of: SESSION, HOPPING, TUMBLING, null"));
}
use of io.confluent.ksql.execution.expression.tree.Literal in project ksql by confluentinc.
the class CreateSourcePropertiesTest method shouldThrowOnSessionWindowWithSize.
@Test
public void shouldThrowOnSessionWindowWithSize() {
// When:
final Exception e = assertThrows(KsqlException.class, () -> CreateSourceProperties.from(ImmutableMap.<String, Literal>builder().putAll(MINIMUM_VALID_PROPS).put(WINDOW_TYPE_PROPERTY, new StringLiteral("SESSION")).put(WINDOW_SIZE_PROPERTY, new StringLiteral("2 MILLISECONDS")).build()));
// Then:
assertThat(e.getMessage(), containsString("'WINDOW_SIZE' should not be set for SESSION windows."));
}
use of io.confluent.ksql.execution.expression.tree.Literal in project ksql by confluentinc.
the class CreateSourcePropertiesTest method shouldSetSessionWindow.
@Test
public void shouldSetSessionWindow() {
// When:
final CreateSourceProperties properties = CreateSourceProperties.from(ImmutableMap.<String, Literal>builder().putAll(MINIMUM_VALID_PROPS).put(CreateConfigs.WINDOW_TYPE_PROPERTY, new StringLiteral("SESSION")).build());
// Then:
assertThat(properties.getWindowType(), is(Optional.of(WindowType.SESSION)));
}
use of io.confluent.ksql.execution.expression.tree.Literal 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.Literal 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'"));
}
Aggregations