use of com.github.jcustenborder.kafka.connect.utils.AssertConnectRecord.assertSourceRecord in project connect-utils by jcustenborder.
the class SourceRecordSerializationModuleTest method roundtrip.
@Test
public void roundtrip() throws IOException {
final Schema expectedKeySchema = SchemaBuilder.struct().name("key").field("id", Schema.INT64_SCHEMA).build();
final Struct expectedKey = new Struct(expectedKeySchema).put("id", 1234L);
final Schema expectedValueSchema = SchemaBuilder.struct().name("value").field("firstName", Schema.STRING_SCHEMA).field("lastName", Schema.STRING_SCHEMA).build();
final Struct expectedValue = new Struct(expectedValueSchema).put("firstName", "foo").put("lastName", "bar");
final SourceRecord expected = new SourceRecord(ImmutableMap.of(), ImmutableMap.of(), "test", 1, expectedKeySchema, expectedKey, expectedValueSchema, expectedValue, 1485910473123L);
final String temp = ObjectMapperFactory.INSTANCE.writeValueAsString(expected);
log.trace(temp);
final SourceRecord actual = ObjectMapperFactory.INSTANCE.readValue(temp, SourceRecord.class);
AssertConnectRecord.assertSourceRecord(expected, actual);
}
Aggregations