use of io.debezium.document.DocumentReader in project debezium by debezium.
the class HistoryRecordTest method canSerializeAndDeserializeHistoryRecord.
@Test
public void canSerializeAndDeserializeHistoryRecord() throws Exception {
Map<String, Object> source = Collect.linkMapOf("server", "abc");
Map<String, Object> position = Collect.linkMapOf("file", "x.log", "positionInt", 100, "positionLong", Long.MAX_VALUE, "entry", 1);
String databaseName = "db";
String ddl = "CREATE TABLE foo ( first VARCHAR(22) NOT NULL );";
HistoryRecord record = new HistoryRecord(source, position, databaseName, ddl);
String serialized = record.toString();
DocumentReader reader = DocumentReader.defaultReader();
HistoryRecord deserialized = new HistoryRecord(reader.read(serialized));
assertThat(deserialized.source()).isNotNull();
assertThat(deserialized.source().get("server")).isEqualTo("abc");
assertThat(deserialized.position()).isNotNull();
assertThat(deserialized.position().get("file")).isEqualTo("x.log");
assertThat(deserialized.position().get("positionInt")).isEqualTo(100);
assertThat(deserialized.position().get("positionLong")).isEqualTo(Long.MAX_VALUE);
assertThat(deserialized.position().get("entry")).isEqualTo(1);
assertThat(deserialized.databaseName()).isEqualTo(databaseName);
assertThat(deserialized.ddl()).isEqualTo(ddl);
System.out.println(record);
}
Aggregations