use of io.confluent.ksql.execution.streams.timestamp.KsqlTimestampExtractor in project ksql by confluentinc.
the class SinkBuilderTest method shouldCallProcessingLoggerOnTimestampExtractorError.
@Test
public void shouldCallProcessingLoggerOnTimestampExtractorError() {
// Given
final KsqlTimestampExtractor timestampExtractor = mock(KsqlTimestampExtractor.class);
doThrow(KsqlException.class).when(timestampExtractor).extract(key, row);
// When
final Transformer<Struct, GenericRow, KeyValue<Struct, GenericRow>> transformer = getTransformer(timestampExtractor, processingLogger);
transformer.init(processorContext);
final KeyValue<Struct, GenericRow> kv = transformer.transform(key, row);
// Then
assertNull(kv);
verify(timestampExtractor).extract(key, row);
verify(processingLogger, Mockito.times(1)).error(any());
verifyNoMoreInteractions(processorContext);
}
use of io.confluent.ksql.execution.streams.timestamp.KsqlTimestampExtractor in project ksql by confluentinc.
the class SinkBuilderTest method shouldTransformTimestampRow.
@Test
public void shouldTransformTimestampRow() {
// Given
final long timestampColumnValue = 10001;
final KsqlTimestampExtractor timestampExtractor = mock(KsqlTimestampExtractor.class);
when(timestampExtractor.extract(any(), any())).thenReturn(timestampColumnValue);
// When
final Transformer<Struct, GenericRow, KeyValue<Struct, GenericRow>> transformer = getTransformer(timestampExtractor, processingLogger);
transformer.init(processorContext);
final KeyValue<Struct, GenericRow> kv = transformer.transform(key, row);
// Then
assertNull(kv);
verify(timestampExtractor).extract(key, row);
verify(processorContext, Mockito.times(1)).forward(eq(key), eq(row), toCaptor.capture());
assertEquals(toCaptor.getValue(), To.all().withTimestamp(timestampColumnValue));
verifyNoMoreInteractions(processingLogger);
}
use of io.confluent.ksql.execution.streams.timestamp.KsqlTimestampExtractor in project ksql by confluentinc.
the class SinkBuilderTest method shouldThrowOnNullProcessorContext.
@Test(expected = NullPointerException.class)
public void shouldThrowOnNullProcessorContext() {
// Given
final KsqlTimestampExtractor timestampExtractor = mock(KsqlTimestampExtractor.class);
// When/Then
getTransformer(timestampExtractor, processingLogger).init(null);
}
use of io.confluent.ksql.execution.streams.timestamp.KsqlTimestampExtractor in project ksql by confluentinc.
the class SinkBuilderTest method shouldThrowOnNullProcessingLogger.
@Test(expected = NullPointerException.class)
public void shouldThrowOnNullProcessingLogger() {
// Given
final KsqlTimestampExtractor timestampExtractor = mock(KsqlTimestampExtractor.class);
// When/Then
getTransformer(timestampExtractor, null);
}
use of io.confluent.ksql.execution.streams.timestamp.KsqlTimestampExtractor in project ksql by confluentinc.
the class SinkBuilderTest method shouldCallProcessingLoggerOnForwardError.
@Test
public void shouldCallProcessingLoggerOnForwardError() {
// Given
final long timestampColumnValue = 10001;
final KsqlTimestampExtractor timestampExtractor = mock(KsqlTimestampExtractor.class);
when(timestampExtractor.extract(any(), any())).thenReturn(timestampColumnValue);
doThrow(KsqlException.class).when(processorContext).forward(any(), any(), any(To.class));
// When
final Transformer<Struct, GenericRow, KeyValue<Struct, GenericRow>> transformer = getTransformer(timestampExtractor, processingLogger);
transformer.init(processorContext);
final KeyValue<Struct, GenericRow> kv = transformer.transform(key, row);
// Then
assertNull(kv);
verify(timestampExtractor).extract(key, row);
verify(processorContext, Mockito.times(1)).forward(eq(key), eq(row), toCaptor.capture());
verify(processingLogger, Mockito.times(1)).error(any());
}
Aggregations