@Test public void testTombstoneDroppedConfigured() { try (final UnwrapFromEnvelope<SourceRecord> transform = new UnwrapFromEnvelope<>()) { final Map<String, String> props = new HashMap<>(); props.put(DROP_TOMBSTONES, "true"); transform.configure(props); final SourceRecord tombstone = new SourceRecord(new HashMap<>(), new HashMap<>(), "dummy", null, null); assertThat(transform.apply(tombstone)).isNull(); } }
@Test public void testTombstoneDroppedByDefault() { try (final UnwrapFromEnvelope<SourceRecord> transform = new UnwrapFromEnvelope<>()) { final Map<String, String> props = new HashMap<>(); transform.configure(props); final SourceRecord tombstone = new SourceRecord(new HashMap<>(), new HashMap<>(), "dummy", null, null); assertThat(transform.apply(tombstone)).isNull(); } }
@Test public void testDeleteDroppedConfigured() { try (final UnwrapFromEnvelope<SourceRecord> transform = new UnwrapFromEnvelope<>()) { final Map<String, String> props = new HashMap<>(); props.put(DROP_DELETES, "true"); props.put(OPERATION_HEADER, "true"); transform.configure(props); final SourceRecord deleteRecord = createDeleteRecord(); assertThat(transform.apply(deleteRecord)).isNull(); } }
@Test public void testHandleDeleteDrop() { try (final UnwrapFromEnvelope<SourceRecord> transform = new UnwrapFromEnvelope<>()) { final Map<String, String> props = new HashMap<>(); props.put(HANDLE_DELETES, "drop"); transform.configure(props); final SourceRecord deleteRecord = createDeleteRecord(); assertThat(transform.apply(deleteRecord)).isNull(); } }
@Test public void testHandleDeleteNone() { try (final UnwrapFromEnvelope<SourceRecord> transform = new UnwrapFromEnvelope<>()) { final Map<String, String> props = new HashMap<>(); props.put(HANDLE_DELETES, "none"); transform.configure(props); final SourceRecord deleteRecord = createDeleteRecord(); final SourceRecord tombstone = transform.apply(deleteRecord); assertThat(tombstone.value()).isNull(); } }
private void assertEmptyFieldValue(SourceRecord record, String fieldName) { final Struct envelope = (Struct)record.value(); final Struct after = (Struct)envelope.get("after"); assertThat(after.getWithoutDefault(fieldName)).isNull(); }
@Test public void testDeleteDroppedByDefault() { try (final UnwrapFromEnvelope<SourceRecord> transform = new UnwrapFromEnvelope<>()) { final Map<String, String> props = new HashMap<>(); transform.configure(props); final SourceRecord deleteRecord = createDeleteRecord(); assertThat(transform.apply(deleteRecord)).isNull(); } }
/** * Verify that the given {@link SourceRecord} is a valid tombstone, meaning it has a non-null key and key schema but null * value and value schema. * * @param record the source record; may not be null */ public static void isValidTombstone(SourceRecord record) { assertThat(record.key()).isNotNull(); assertThat(record.keySchema()).isNotNull(); assertThat(record.value()).isNull(); assertThat(record.valueSchema()).isNull(); }
public EventAssert renamedFrom( String oldName ) { TableId previousTableId = alterTableEvent().previousTableId(); if ( oldName == null ) { assertThat(previousTableId).isNull(); } else { assertThat(previousTableId.table()).isEqualTo(oldName); } return this; } public EventAssert dropTableNamed( String tableName) {
@Test public void shouldTruncateStrings() { converter = new TruncateStrings(5).create(column); assertThat(converter.convert("1234567890").toString()).isEqualTo("12345"); assertThat(converter.convert("123456").toString()).isEqualTo("12345"); assertThat(converter.convert("12345").toString()).isEqualTo("12345"); assertThat(converter.convert("1234").toString()).isEqualTo("1234"); assertThat(converter.convert("123").toString()).isEqualTo("123"); assertThat(converter.convert("12").toString()).isEqualTo("12"); assertThat(converter.convert("1").toString()).isEqualTo("1"); assertThat(converter.convert(null)).isNull(); }
@Test public void shouldNotFindMapperForUnmatchedColumn() { Configuration config = Configuration.create() .with("column.truncate.to.10.chars", fullyQualifiedNames) .build(); mappers = ColumnMappers.create(config); converter = mappers.mappingConverterFor(tableId, column2); assertThat(converter).isNull(); }
@Test public void shouldNotFindMatchingDataTypeIfInvalidOrIncomplete() { pattern = parser.parse(TYPE, "DECIMAL(3)"); assertThat(pattern).isNotNull(); type = pattern.match(text("DECIMAL(3")); assertThat(type).isNull(); }
@Test public void shouldInitAndDestroyResources() { MockReader r1 = new MockReader("r1", records()); MockReader r2 = new MockReader("r2", records()); reader = new ChainedReader.Builder().addReader(r1).addReader(r2).build(); reader.initialize(); assertThat(r1.mockResource).isNotNull(); assertThat(r2.mockResource).isNotNull(); reader.destroy(); assertThat(r1.mockResource).isNull(); assertThat(r2.mockResource).isNull(); }
@Test public void shouldNotHaveColumnsIfEmpty() { assertThat(editor.columnWithName("any")).isNull(); assertThat(editor.columns()).isEmpty(); assertThat(editor.primaryKeyColumnNames()).isEmpty(); }
@Test public void shouldMapValuesUsingFunctionByClassName() { mappers = ColumnMappers.build().map(fullyQualifiedNames, RepeatingColumnMapper.class.getName()).build(); converter = mappers.mappingConverterFor(tableId, column); assertThat(converter).isNotNull(); assertThat(converter.convert("1234")).isEqualTo("12341234"); assertThat(converter.convert("a")).isEqualTo("aa"); assertThat(converter.convert(null)).isNull(); }
@Test public void shouldCreateTableWhenEditorHasIdButNoColumns() { table = editor.tableId(id).create(); assertThat(table.columnWithName("any")).isNull(); assertThat(table.columns()).isEmpty(); assertThat(table.primaryKeyColumnNames()).isEmpty(); }
@Test public void shouldMapValuesUsingColumnMapperInstance() { RepeatingColumnMapper mapper = new RepeatingColumnMapper(); mappers = ColumnMappers.build().map(fullyQualifiedNames, mapper).build(); converter = mappers.mappingConverterFor(tableId, column); assertThat(converter).isNotNull(); assertThat(converter.convert("1234")).isEqualTo("12341234"); assertThat(converter.convert("a")).isEqualTo("aa"); assertThat(converter.convert(null)).isNull(); }