use of io.confluent.ksql.execution.ddl.commands.CreateStreamCommand in project ksql by confluentinc.
the class CreateSourceFactoryTest method shouldHandleTumblingWindowedKeyForStream.
@Test
public void shouldHandleTumblingWindowedKeyForStream() {
// Given:
givenProperties(ImmutableMap.of("window_type", new StringLiteral("tumbling"), "window_size", new StringLiteral("1 MINUTE")));
final CreateStream statement = new CreateStream(SOME_NAME, STREAM_ELEMENTS, false, true, withProperties, false);
// When:
final CreateStreamCommand cmd = createSourceFactory.createStreamCommand(statement, ksqlConfig);
// Then:
assertThat(cmd.getFormats().getKeyFormat(), is(FormatInfo.of(KAFKA.name())));
assertThat(cmd.getWindowInfo(), is(Optional.of(WindowInfo.of(TUMBLING, Optional.of(Duration.ofMinutes(1))))));
}
use of io.confluent.ksql.execution.ddl.commands.CreateStreamCommand in project ksql by confluentinc.
the class CreateSourceFactoryTest method shouldBuildSchemaWithImplicitKeyFieldForStream.
@Test
public void shouldBuildSchemaWithImplicitKeyFieldForStream() {
// Given:
final CreateStream statement = new CreateStream(SOME_NAME, STREAM_ELEMENTS, false, true, withProperties, false);
// When:
final CreateStreamCommand result = createSourceFactory.createStreamCommand(statement, ksqlConfig);
// Then:
assertThat(result.getSchema(), is(EXPECTED_SCHEMA));
}
use of io.confluent.ksql.execution.ddl.commands.CreateStreamCommand in project ksql by confluentinc.
the class CreateSourceFactoryTest method shouldHandleHoppingWindowedKeyForStream.
@Test
public void shouldHandleHoppingWindowedKeyForStream() {
// Given:
givenProperties(ImmutableMap.of("window_type", new StringLiteral("Hopping"), "window_size", new StringLiteral("2 SECONDS")));
final CreateStream statement = new CreateStream(SOME_NAME, STREAM_ELEMENTS, false, true, withProperties, false);
// When:
final CreateStreamCommand cmd = createSourceFactory.createStreamCommand(statement, ksqlConfig);
// Then:
assertThat(cmd.getFormats().getKeyFormat(), is(FormatInfo.of(KAFKA.name())));
assertThat(cmd.getWindowInfo(), is(Optional.of(WindowInfo.of(HOPPING, Optional.of(Duration.ofSeconds(2))))));
}
use of io.confluent.ksql.execution.ddl.commands.CreateStreamCommand in project ksql by confluentinc.
the class CreateSourceFactoryTest method shouldCreateStreamCommandWithSingleValueWrappingFromDefaultConfig.
@Test
public void shouldCreateStreamCommandWithSingleValueWrappingFromDefaultConfig() {
// Given:
final CreateStream statement = new CreateStream(SOME_NAME, ONE_KEY_ONE_VALUE, false, true, withProperties, false);
// When:
final CreateStreamCommand cmd = createSourceFactory.createStreamCommand(statement, ksqlConfig);
// Then:
assertThat(cmd.getFormats().getValueFeatures(), is(SerdeFeatures.of()));
}
use of io.confluent.ksql.execution.ddl.commands.CreateStreamCommand in project ksql by confluentinc.
the class CreateSourceFactoryTest method shouldBuildSerdeFeaturesForStream.
@Test
public void shouldBuildSerdeFeaturesForStream() {
// Given:
givenCommandFactoriesWithMocks();
final CreateStream statement = new CreateStream(SOME_NAME, ONE_KEY_ONE_VALUE, false, true, withProperties, false);
final LogicalSchema schema = LogicalSchema.builder().keyColumn(ColumnName.of("k"), SqlTypes.INTEGER).valueColumn(ColumnName.of("bob"), SqlTypes.STRING).build();
when(keyOptionsSupplier.build(any(), any(), any(), any())).thenReturn(SerdeFeatures.of(SerdeFeature.WRAP_SINGLES));
when(valOptionsSupplier.build(any(), any(), any(), any())).thenReturn(SerdeFeatures.of(SerdeFeature.UNWRAP_SINGLES));
// When:
final CreateStreamCommand cmd = createSourceFactory.createStreamCommand(statement, ksqlConfig);
// Then:
verify(keyOptionsSupplier).build(schema, FormatFactory.of(SourcePropertiesUtil.getKeyFormat(statement.getProperties(), SOME_NAME)), SerdeFeatures.of(), ksqlConfig);
verify(valOptionsSupplier).build(schema, FormatFactory.of(SourcePropertiesUtil.getValueFormat(statement.getProperties())), statement.getProperties().getValueSerdeFeatures(), ksqlConfig);
assertThat(cmd.getFormats().getKeyFeatures(), is(SerdeFeatures.of(SerdeFeature.WRAP_SINGLES)));
assertThat(cmd.getFormats().getValueFeatures(), is(SerdeFeatures.of(SerdeFeature.UNWRAP_SINGLES)));
}
Aggregations