Search in sources :

Example 1 with Timestamp

use of org.apache.kafka.connect.data.Timestamp in project ksql by confluentinc.

the class KsqlJsonDeserializerTest method shouldThrowIfCanNotCoerceToTimestamp.

@Test
public void shouldThrowIfCanNotCoerceToTimestamp() {
    // Given:
    final KsqlJsonDeserializer<java.sql.Timestamp> deserializer = givenDeserializerForSchema(Timestamp.SCHEMA, java.sql.Timestamp.class);
    final byte[] bytes = serializeJson(BooleanNode.valueOf(true));
    // When:
    final Exception e = assertThrows(SerializationException.class, () -> deserializer.deserialize(SOME_TOPIC, bytes));
    // Then:
    assertThat(e.getCause(), (hasMessage(startsWith("Can't convert type. sourceType: BooleanNode, requiredType: TIMESTAMP"))));
}
Also used : Timestamp(org.apache.kafka.connect.data.Timestamp) SerializationException(org.apache.kafka.common.errors.SerializationException) KsqlException(io.confluent.ksql.util.KsqlException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) IOException(java.io.IOException) Test(org.junit.Test)

Aggregations

JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 KsqlException (io.confluent.ksql.util.KsqlException)1 IOException (java.io.IOException)1 SerializationException (org.apache.kafka.common.errors.SerializationException)1 Timestamp (org.apache.kafka.connect.data.Timestamp)1 Test (org.junit.Test)1