Search in sources :

Example 1 with OffsetAndMetadataDeserializer

use of io.mantisrx.connector.kafka.source.serde.OffsetAndMetadataDeserializer in project mantis by Netflix.

the class FileBasedOffsetCheckpointStrategyTest method testOffsetAndMetadataSerialization.

@Test
public void testOffsetAndMetadataSerialization() {
    OffsetAndMetadata expected = new OffsetAndMetadata(100, "tempmeta");
    final SimpleModule module = new SimpleModule().addSerializer(OffsetAndMetadata.class, new OffsetAndMetadataSerializer()).addDeserializer(OffsetAndMetadata.class, new OffsetAndMetadataDeserializer());
    final ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    mapper.registerModule(module);
    try {
        final String s = mapper.writeValueAsString(expected);
        final OffsetAndMetadata actual = mapper.readValue(s, OffsetAndMetadata.class);
        assertEquals(expected, actual);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : OffsetAndMetadataDeserializer(io.mantisrx.connector.kafka.source.serde.OffsetAndMetadataDeserializer) OffsetAndMetadataSerializer(io.mantisrx.connector.kafka.source.serde.OffsetAndMetadataSerializer) OffsetAndMetadata(org.apache.kafka.clients.consumer.OffsetAndMetadata) IOException(java.io.IOException) SimpleModule(io.mantisrx.shaded.com.fasterxml.jackson.databind.module.SimpleModule) ObjectMapper(io.mantisrx.shaded.com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Aggregations

OffsetAndMetadataDeserializer (io.mantisrx.connector.kafka.source.serde.OffsetAndMetadataDeserializer)1 OffsetAndMetadataSerializer (io.mantisrx.connector.kafka.source.serde.OffsetAndMetadataSerializer)1 ObjectMapper (io.mantisrx.shaded.com.fasterxml.jackson.databind.ObjectMapper)1 SimpleModule (io.mantisrx.shaded.com.fasterxml.jackson.databind.module.SimpleModule)1 IOException (java.io.IOException)1 OffsetAndMetadata (org.apache.kafka.clients.consumer.OffsetAndMetadata)1 Test (org.junit.Test)1