/** * Verify that the given {@link SourceRecord} is a {@link Operation#UPDATE UPDATE} record without PK. * * @param record the source record; may not be null * @param pkField the single field defining the primary key of the struct; may not be null * @param pk the expected integer value of the primary key in the struct */ public static void isValidUpdate(SourceRecord record) { isValidUpdate(record, false); }
protected void assertUpdate(SourceRecord record, String pkField, int pk) { VerifyRecord.isValidUpdate(record, pkField, pk); }
/** * Verify that the given {@link SourceRecord} is a {@link Operation#UPDATE UPDATE} record, and that the integer key * matches the expected value. * * @param record the source record; may not be null * @param pkField the single field defining the primary key of the struct; may not be null * @param pk the expected integer value of the primary key in the struct */ public static void isValidUpdate(SourceRecord record, String pkField, int pk) { hasValidKey(record, pkField, pk); isValidUpdate(record, true); }
String topicName = topicName("public.test_table"); assertEquals(topicName, updatedRecord.topic()); VerifyRecord.isValidUpdate(updatedRecord, PK_FIELD, 1); VerifyRecord.isValidUpdate(updatedRecord, PK_FIELD, 1); executeAndWait(statements); updatedRecord = consumer.remove(); VerifyRecord.isValidUpdate(updatedRecord, PK_FIELD, 1); executeAndWait(statements); updatedRecord = consumer.remove(); VerifyRecord.isValidUpdate(updatedRecord, PK_FIELD, 2); assertRecordSchemaAndValues( Collections.singletonList(new SchemaAndValueField("modtype", SchemaBuilder.OPTIONAL_INT16_SCHEMA, (short)1)), updatedRecord, Envelope.FieldName.BEFORE);
String topicName = topicName("public.test_table"); assertEquals(topicName, updatedRecord.topic()); VerifyRecord.isValidUpdate(updatedRecord, PK_FIELD, 1); VerifyRecord.isValidUpdate(updatedRecord, PK_FIELD, 1);
String topicName = topicName("public.test_table"); assertEquals(topicName, updatedRecord.topic()); VerifyRecord.isValidUpdate(updatedRecord, PK_FIELD, 1);
executeAndWait("UPDATE test_table set text='b' WHERE id=1"); SourceRecord updatedRecord = consumer.remove(); VerifyRecord.isValidUpdate(updatedRecord);
protected void assertUpdate(SourceRecord record, String pkField, int pk) { VerifyRecord.isValidUpdate(record, pkField, pk); }
String topicName = topicName("public.test_table"); assertEquals(topicName, updatedRecord.topic()); VerifyRecord.isValidUpdate(updatedRecord, PK_FIELD, 1); VerifyRecord.isValidUpdate(updatedRecord, PK_FIELD, 1); executeAndWait(statements); updatedRecord = consumer.remove(); VerifyRecord.isValidUpdate(updatedRecord, PK_FIELD, 1); executeAndWait(statements); updatedRecord = consumer.remove(); VerifyRecord.isValidUpdate(updatedRecord, PK_FIELD, 2); assertRecordSchemaAndValues( Collections.singletonList(new SchemaAndValueField("modtype", SchemaBuilder.OPTIONAL_INT16_SCHEMA, (short)1)), updatedRecord, Envelope.FieldName.BEFORE);
String topicName = topicName("public.test_table"); assertEquals(topicName, updatedRecord.topic()); VerifyRecord.isValidUpdate(updatedRecord, PK_FIELD, 1); VerifyRecord.isValidUpdate(updatedRecord, PK_FIELD, 1);
String topicName = topicName("public.test_table"); assertEquals(topicName, updatedRecord.topic()); VerifyRecord.isValidUpdate(updatedRecord, PK_FIELD, 1);
executeAndWait("UPDATE test_table set text='b' WHERE id=1"); SourceRecord updatedRecord = consumer.remove(); VerifyRecord.isValidUpdate(updatedRecord);
VerifyRecord.isValidUpdate(testTableRecords.get(1), "ID", 1); Struct before = (Struct) ((Struct)testTableRecords.get(1).value()).get("before"); assertThat(before.get("ID")).isEqualTo(1);