use of io.confluent.ksql.GenericKey in project ksql by confluentinc.
the class SourceBuilderV1Test method shouldApplyCorrectTransformationsToSourceTable.
@Test
@SuppressWarnings("unchecked")
public void shouldApplyCorrectTransformationsToSourceTable() {
// Given:
givenUnwindowedSourceTableV1(true, LEGACY_PSEUDOCOLUMN_VERSION_NUMBER);
// When:
final KTableHolder<GenericKey> builtKTable = tableSourceV1.build(planBuilder, planInfo);
// Then:
assertThat(builtKTable.getTable(), is(kTable));
final InOrder validator = inOrder(streamsBuilder, kTable);
validator.verify(streamsBuilder).table(eq(TOPIC_NAME), eq(consumed));
validator.verify(kTable).mapValues(any(ValueMapper.class), any(Materialized.class));
validator.verify(kTable).transformValues(any(ValueTransformerWithKeySupplier.class));
verify(consumedFactory).create(keySerde, valueSerde);
verify(consumed).withTimestampExtractor(any());
verify(consumed).withOffsetResetPolicy(AutoOffsetReset.EARLIEST);
}
use of io.confluent.ksql.GenericKey in project ksql by confluentinc.
the class SourceBuilderV1Test method shouldHandleNullKey.
@Test
public void shouldHandleNullKey() {
// Given:
givenUnwindowedSourceStream();
final ValueTransformerWithKey<GenericKey, GenericRow, GenericRow> transformer = getTransformerFromStreamSource(streamSource);
final GenericKey nullKey = null;
// When:
final GenericRow withTimestamp = transformer.transform(nullKey, row);
// Then:
assertThat(withTimestamp, equalTo(GenericRow.genericRow("baz", 123, HEADER_DATA, A_ROWTIME, A_ROWPARTITION, A_ROWOFFSET, null)));
}
use of io.confluent.ksql.GenericKey in project ksql by confluentinc.
the class SourceBuilderV1Test method shouldAddRowTimeAndTimeWindowedRowKeyColumnsToLegacyTable.
@Test
public void shouldAddRowTimeAndTimeWindowedRowKeyColumnsToLegacyTable() {
// Given:
givenWindowedSourceTable(LEGACY_PSEUDOCOLUMN_VERSION_NUMBER);
final ValueTransformerWithKey<Windowed<GenericKey>, GenericRow, GenericRow> transformer = getTransformerFromTableSource(windowedTableSource);
final Windowed<GenericKey> key = new Windowed<>(KEY, new TimeWindow(A_WINDOW_START, A_WINDOW_END));
// When:
final GenericRow withTimestamp = transformer.transform(key, row);
// Then:
assertThat(withTimestamp, is(GenericRow.genericRow("baz", 123, HEADER_DATA, A_ROWTIME, A_KEY, A_WINDOW_START, A_WINDOW_END)));
}
use of io.confluent.ksql.GenericKey in project ksql by confluentinc.
the class SourceBuilderV1Test method shouldAddPseudoColumnsAndSessionWindowedRowKeyColumnsToStream.
@Test
public void shouldAddPseudoColumnsAndSessionWindowedRowKeyColumnsToStream() {
// Given:
givenWindowedSourceStream();
final ValueTransformerWithKey<Windowed<GenericKey>, GenericRow, GenericRow> transformer = getTransformerFromStreamSource(windowedStreamSource);
final Windowed<GenericKey> key = new Windowed<>(KEY, new SessionWindow(A_WINDOW_START, A_WINDOW_END));
// When:
final GenericRow withTimestamp = transformer.transform(key, row);
// Then:
assertThat(withTimestamp, equalTo(GenericRow.genericRow("baz", 123, HEADER_DATA, A_ROWTIME, A_ROWPARTITION, A_ROWOFFSET, A_KEY, A_WINDOW_START, A_WINDOW_END)));
}
use of io.confluent.ksql.GenericKey in project ksql by confluentinc.
the class SourceBuilderV1Test method shouldHandleEmptyKey.
@Test
public void shouldHandleEmptyKey() {
// Given:
givenUnwindowedSourceStream();
final ValueTransformerWithKey<GenericKey, GenericRow, GenericRow> transformer = getTransformerFromStreamSource(streamSource);
final GenericKey nullKey = GenericKey.genericKey((Object) null);
// When:
final GenericRow withTimestamp = transformer.transform(nullKey, row);
// Then:
assertThat(withTimestamp, equalTo(GenericRow.genericRow("baz", 123, HEADER_DATA, A_ROWTIME, A_ROWPARTITION, A_ROWOFFSET, null)));
}
Aggregations