Search in sources :

Example 1 with LoggingDeserializer

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);
}
Also used : ProcessingLogger(io.confluent.ksql.logging.processing.ProcessingLogger) WrapperSerde(org.apache.kafka.common.serialization.Serdes.WrapperSerde) LoggingDeserializer(io.confluent.ksql.logging.processing.LoggingDeserializer) DeserializationError(io.confluent.ksql.logging.processing.DeserializationError) Test(org.junit.Test)

Example 2 with LoggingDeserializer

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);
}
Also used : ProcessingLogger(io.confluent.ksql.logging.processing.ProcessingLogger) WrapperSerde(org.apache.kafka.common.serialization.Serdes.WrapperSerde) LoggingDeserializer(io.confluent.ksql.logging.processing.LoggingDeserializer) Test(org.junit.Test)

Example 3 with LoggingDeserializer

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));
}
Also used : ProcessingLogger(io.confluent.ksql.logging.processing.ProcessingLogger) WrapperSerde(org.apache.kafka.common.serialization.Serdes.WrapperSerde) LoggingDeserializer(io.confluent.ksql.logging.processing.LoggingDeserializer) Test(org.junit.Test)

Aggregations

LoggingDeserializer (io.confluent.ksql.logging.processing.LoggingDeserializer)3 ProcessingLogger (io.confluent.ksql.logging.processing.ProcessingLogger)3 WrapperSerde (org.apache.kafka.common.serialization.Serdes.WrapperSerde)3 Test (org.junit.Test)3 DeserializationError (io.confluent.ksql.logging.processing.DeserializationError)1