use of io.debezium.jdbc.JdbcValueConverters in project debezium by debezium.
the class TableSchemaBuilderTest method shouldBuildTableSchemaFromTableWithoutPrimaryKey.
@Test
public void shouldBuildTableSchemaFromTableWithoutPrimaryKey() {
table = table.edit().setPrimaryKeyNames().create();
schema = new TableSchemaBuilder(new JdbcValueConverters(), adjuster, SchemaBuilder.struct().build()).create(prefix, "sometopic", table, null, null);
assertThat(schema).isNotNull();
// Check the keys ...
assertThat(schema.keySchema()).isNull();
assertThat(schema.keyFromColumnData(data)).isNull();
// Check the values ...
Schema values = schema.valueSchema();
assertThat(values).isNotNull();
assertThat(values.field("C1").name()).isEqualTo("C1");
assertThat(values.field("C1").index()).isEqualTo(0);
assertThat(values.field("C1").schema()).isEqualTo(SchemaBuilder.string().build());
assertThat(values.field("C2").name()).isEqualTo("C2");
assertThat(values.field("C2").index()).isEqualTo(1);
// scale of 3
assertThat(values.field("C2").schema()).isEqualTo(Decimal.builder(3).optional().build());
assertThat(values.field("C3").name()).isEqualTo("C3");
assertThat(values.field("C3").index()).isEqualTo(2);
// optional date
assertThat(values.field("C3").schema()).isEqualTo(Date.builder().optional().build());
assertThat(values.field("C4").name()).isEqualTo("C4");
assertThat(values.field("C4").index()).isEqualTo(3);
// JDBC INTEGER = 32 bits
assertThat(values.field("C4").schema()).isEqualTo(SchemaBuilder.int32().optional().build());
assertThat(values.field("C5").index()).isEqualTo(4);
// JDBC BINARY = bytes
assertThat(values.field("C5").schema()).isEqualTo(SchemaBuilder.bytes().build());
assertThat(values.field("C6").index()).isEqualTo(5);
assertThat(values.field("C6").schema()).isEqualTo(SchemaBuilder.int16().build());
Struct value = schema.valueFromColumnData(data);
assertThat(value).isNotNull();
assertThat(value.get("C1")).isEqualTo("c1value");
assertThat(value.get("C2")).isEqualTo(BigDecimal.valueOf(3.142d));
assertThat(value.get("C3")).isEqualTo(11626);
assertThat(value.get("C4")).isEqualTo(4);
assertThat(value.get("C5")).isEqualTo(ByteBuffer.wrap(new byte[] { 71, 117, 110, 110, 97, 114 }));
assertThat(value.get("C6")).isEqualTo(Short.valueOf((short) 0));
}
use of io.debezium.jdbc.JdbcValueConverters in project debezium by debezium.
the class TableSchemaBuilderTest method shouldBuildTableSchemaFromTable.
@Test
public void shouldBuildTableSchemaFromTable() {
schema = new TableSchemaBuilder(new JdbcValueConverters(), adjuster, SchemaBuilder.struct().build()).create(prefix, "sometopic", table, null, null);
assertThat(schema).isNotNull();
}
Aggregations