use of io.confluent.ksql.logging.processing.LoggingDeserializer in project ksql by confluentinc.
the class StaticTopicSerdeTest method shouldLogOriginalFailureIfBothFail.
@Test
public void shouldLogOriginalFailureIfBothFail() {
// Given:
when(delegateD.deserialize(Mockito.any(), Mockito.any())).thenThrow(new RuntimeException());
final ProcessingLogger logger = mock(ProcessingLogger.class);
final LoggingDeserializer<Object> loggingDelegate = new LoggingDeserializer<>(delegateD, logger);
final Serde<Object> delegate = new WrapperSerde<>(delegateS, loggingDelegate);
staticSerde = StaticTopicSerde.wrap(STATIC_TOPIC, delegate, callback);
// When:
final RuntimeException err = assertThrows(RuntimeException.class, () -> staticSerde.deserializer().deserialize(SOURCE_TOPIC, SOME_BYTES));
// Then:
verify(logger).error(new DeserializationError(err, Optional.of(SOME_BYTES), STATIC_TOPIC, false));
verifyNoMoreInteractions(callback);
}
use of io.confluent.ksql.logging.processing.LoggingDeserializer in project ksql by confluentinc.
the class StaticTopicSerdeTest method shouldUseDelegateLoggingDeserializerWithStaticTopic.
@Test
public void shouldUseDelegateLoggingDeserializerWithStaticTopic() {
// Given:
final ProcessingLogger logger = mock(ProcessingLogger.class);
final LoggingDeserializer<Object> loggingDelegate = new LoggingDeserializer<>(delegateD, logger);
final Serde<Object> delegate = new WrapperSerde<>(delegateS, loggingDelegate);
staticSerde = StaticTopicSerde.wrap(STATIC_TOPIC, delegate, callback);
// When:
final Object deserialized = staticSerde.deserializer().deserialize(SOURCE_TOPIC, SOME_BYTES);
// Then:
verify(delegateD).deserialize(STATIC_TOPIC, SOME_BYTES);
assertThat(deserialized, is(SOME_OBJECT));
verifyNoMoreInteractions(callback);
verifyNoMoreInteractions(logger);
}
use of io.confluent.ksql.logging.processing.LoggingDeserializer in project ksql by confluentinc.
the class StaticTopicSerdeTest method shouldTrySourceTopicAndCallCallbackOnDeserializationFailureWithLoggingDeserializer.
@Test
public void shouldTrySourceTopicAndCallCallbackOnDeserializationFailureWithLoggingDeserializer() {
// Given:
when(delegateD.deserialize(Mockito.eq(STATIC_TOPIC), Mockito.any())).thenThrow(new RuntimeException());
final ProcessingLogger logger = mock(ProcessingLogger.class);
final LoggingDeserializer<Object> loggingDelegate = new LoggingDeserializer<>(delegateD, logger);
final Serde<Object> delegate = new WrapperSerde<>(delegateS, loggingDelegate);
staticSerde = StaticTopicSerde.wrap(STATIC_TOPIC, delegate, callback);
// When:
final Object deserialized = staticSerde.deserializer().deserialize(SOURCE_TOPIC, SOME_BYTES);
// Then:
verifyNoMoreInteractions(logger);
verify(callback).onDeserializationFailure(SOURCE_TOPIC, STATIC_TOPIC, SOME_BYTES);
assertThat(deserialized, is(SOME_OBJECT));
}
Aggregations