public class VerifyRecord extends Object
SourceRecord.| Modifier and Type | Class and Description |
|---|---|
static interface |
VerifyRecord.RecordValueComparator |
| Modifier and Type | Field and Description |
|---|---|
private static io.confluent.connect.avro.AvroConverter |
avroKeyConverter |
private static io.confluent.connect.avro.AvroConverter |
avroValueConverter |
private static org.apache.kafka.connect.json.JsonConverter |
keyJsonConverter |
private static org.apache.kafka.connect.json.JsonDeserializer |
keyJsonDeserializer |
private static io.confluent.kafka.schemaregistry.client.MockSchemaRegistryClient |
schemaRegistry |
private static org.apache.kafka.connect.json.JsonConverter |
valueJsonConverter |
private static org.apache.kafka.connect.json.JsonDeserializer |
valueJsonDeserializer |
| Constructor and Description |
|---|
VerifyRecord() |
| Modifier and Type | Method and Description |
|---|---|
private static boolean |
areConnectSchemasEqual(org.apache.kafka.connect.data.Schema schema1,
org.apache.kafka.connect.data.Schema schema2) |
private static boolean |
areFieldListsEqual(List<org.apache.kafka.connect.data.Field> fields1,
List<org.apache.kafka.connect.data.Field> fields2) |
static void |
assertConnectSchemasAreEqual(String fieldName,
org.apache.kafka.connect.data.Schema actual,
org.apache.kafka.connect.data.Schema expected)
Asserts that the two given schemas are equal.
|
protected static void |
assertEquals(Object o1,
Object o2) |
protected static void |
assertEquals(org.apache.kafka.connect.data.Schema schema,
Object o1,
Object o2,
String keyOrValue,
String field,
Predicate<String> ignoreFields,
Map<String,VerifyRecord.RecordValueComparator> comparatorsByName,
Map<String,VerifyRecord.RecordValueComparator> comparatorsBySchemaName) |
static void |
assertEquals(org.apache.kafka.connect.source.SourceRecord actual,
org.apache.kafka.connect.source.SourceRecord expected,
Predicate<String> ignoreFields,
Map<String,VerifyRecord.RecordValueComparator> comparatorsByName,
Map<String,VerifyRecord.RecordValueComparator> comparatorsBySchemaName) |
static void |
assertSameValue(Object actual,
Object expected)
Utility method to validate that two given
SourceRecord values are identical. |
static void |
assertValueField(org.apache.kafka.connect.source.SourceRecord record,
String fieldPath,
Object expectedValue)
Verify the given
SourceRecord has the expected value in the given fieldPath. |
static void |
debug(org.apache.kafka.connect.source.SourceRecord record)
Print a debug message with the JSON representation of the SourceRecord.
|
private static boolean |
deepEquals(Object[] a1,
Object[] a2) |
private static boolean |
deepEquals0(Object e1,
Object e2) |
protected static boolean |
equals(Object o1,
Object o2) |
private static String |
fieldName(String field,
String suffix) |
static void |
fieldsInSchema(org.apache.kafka.connect.data.Struct struct,
org.apache.kafka.connect.data.Schema schema)
Verify that the fields in the given
Struct reference the Field definitions in the given Schema. |
static void |
hasNoSourceQuery(org.apache.kafka.connect.source.SourceRecord record)
Verify that the given
SourceRecord has no source query value. |
static void |
hasValidKey(org.apache.kafka.connect.source.SourceRecord record,
String pkField,
int pk)
Verify that the given
SourceRecord has a valid non-null integer key that matches the expected integer value. |
static void |
hasValidSourceQuery(org.apache.kafka.connect.source.SourceRecord record,
String query)
Verify that the given
SourceRecord has the appropriate source query value. |
static void |
isValid(org.apache.kafka.connect.source.SourceRecord record)
Validate that a
SourceRecord's key and value can each be converted to a byte[] and then back to an equivalent
SourceRecord. |
static void |
isValidDelete(org.apache.kafka.connect.source.SourceRecord record)
Verify that the given
SourceRecord is a DELETE record without PK. |
static void |
isValidDelete(org.apache.kafka.connect.source.SourceRecord record,
boolean keyExpected)
Verify that the given
SourceRecord is a DELETE record. |
static void |
isValidDelete(org.apache.kafka.connect.source.SourceRecord record,
String pkField,
int pk)
Verify that the given
SourceRecord is a DELETE record, and that the integer key
matches the expected value. |
static void |
isValidInsert(org.apache.kafka.connect.source.SourceRecord record)
Verify that the given
SourceRecord is a INSERT/CREATE record without primary key. |
static void |
isValidInsert(org.apache.kafka.connect.source.SourceRecord record,
boolean keyExpected)
Verify that the given
SourceRecord is a INSERT/CREATE record. |
static void |
isValidInsert(org.apache.kafka.connect.source.SourceRecord record,
String pkField,
int pk)
Verify that the given
SourceRecord is a INSERT/CREATE record, and that the integer key
matches the expected value. |
static void |
isValidRead(org.apache.kafka.connect.source.SourceRecord record)
Verify that the given
SourceRecord is a READ record. |
static void |
isValidRead(org.apache.kafka.connect.source.SourceRecord record,
String pkField,
int pk)
Verify that the given
SourceRecord is a READ record, and that the integer key
matches the expected value. |
static void |
isValidTombstone(org.apache.kafka.connect.source.SourceRecord record)
Verify that the given
SourceRecord is a valid tombstone, meaning it has a non-null key and key schema but null
value and value schema. |
static void |
isValidTombstone(org.apache.kafka.connect.source.SourceRecord record,
String pkField,
int pk)
Verify that the given
SourceRecord is a valid tombstone, meaning it has a valid non-null key with key schema
but null value and value schema. |
static void |
isValidUpdate(org.apache.kafka.connect.source.SourceRecord record)
Verify that the given
SourceRecord is a UPDATE record without PK. |
static void |
isValidUpdate(org.apache.kafka.connect.source.SourceRecord record,
boolean keyExpected)
Verify that the given
SourceRecord is a UPDATE record. |
static void |
isValidUpdate(org.apache.kafka.connect.source.SourceRecord record,
String pkField,
int pk)
Verify that the given
SourceRecord is a UPDATE record, and that the integer key
matches the expected value. |
protected static String |
nameOf(String keyOrValue,
String field) |
protected static String |
prettyJson(com.fasterxml.jackson.databind.JsonNode json) |
static void |
print(org.apache.kafka.connect.source.SourceRecord record)
Print a message with the JSON representation of the SourceRecord.
|
protected static void |
printJson(org.apache.kafka.connect.source.SourceRecord record) |
static void |
schemaMatchesStruct(org.apache.kafka.connect.data.SchemaAndValue schemaAndValue)
Assert that the supplied
Struct is valid and its schema
matches that of the supplied schema. |
static void |
schemaMatchesStruct(org.apache.kafka.connect.data.Struct struct,
org.apache.kafka.connect.data.Schema schema)
Assert that the supplied
Struct is valid and its schema
matches that of the supplied schema. |
private static String |
schemaName(org.apache.kafka.connect.data.Schema schema) |
protected static void |
validateSchemaNames(org.apache.kafka.connect.data.Schema schema) |
protected static void |
validateSubSchemaNames(org.apache.kafka.connect.data.Schema parentSchema,
org.apache.kafka.connect.data.Field field) |
private static Object[] |
valuesFor(org.apache.kafka.connect.data.Struct struct) |
private static final org.apache.kafka.connect.json.JsonConverter keyJsonConverter
private static final org.apache.kafka.connect.json.JsonConverter valueJsonConverter
private static final org.apache.kafka.connect.json.JsonDeserializer keyJsonDeserializer
private static final org.apache.kafka.connect.json.JsonDeserializer valueJsonDeserializer
private static final io.confluent.kafka.schemaregistry.client.MockSchemaRegistryClient schemaRegistry
private static final io.confluent.connect.avro.AvroConverter avroKeyConverter
private static final io.confluent.connect.avro.AvroConverter avroValueConverter
public static void isValidInsert(org.apache.kafka.connect.source.SourceRecord record,
boolean keyExpected)
SourceRecord is a INSERT/CREATE record.record - the source record; may not be nullpublic static void isValidRead(org.apache.kafka.connect.source.SourceRecord record)
SourceRecord is a READ record.record - the source record; may not be nullpublic static void isValidUpdate(org.apache.kafka.connect.source.SourceRecord record,
boolean keyExpected)
SourceRecord is a UPDATE record.record - the source record; may not be nullpublic static void isValidDelete(org.apache.kafka.connect.source.SourceRecord record,
boolean keyExpected)
SourceRecord is a DELETE record.record - the source record; may not be nullpublic static void isValidTombstone(org.apache.kafka.connect.source.SourceRecord record)
SourceRecord is a valid tombstone, meaning it has a non-null key and key schema but null
value and value schema.record - the source record; may not be nullpublic static void hasValidKey(org.apache.kafka.connect.source.SourceRecord record,
String pkField,
int pk)
SourceRecord has a valid non-null integer key that matches the expected integer value.record - the source record; may not be nullpkField - the single field defining the primary key of the struct; may not be nullpk - the expected integer value of the primary key in the structpublic static void isValidInsert(org.apache.kafka.connect.source.SourceRecord record)
SourceRecord is a INSERT/CREATE record without primary key.record - the source record; may not be nullpublic static void isValidInsert(org.apache.kafka.connect.source.SourceRecord record,
String pkField,
int pk)
SourceRecord is a INSERT/CREATE record, and that the integer key
matches the expected value.record - the source record; may not be nullpkField - the single field defining the primary key of the struct; may not be nullpk - the expected integer value of the primary key in the structpublic static void isValidRead(org.apache.kafka.connect.source.SourceRecord record,
String pkField,
int pk)
SourceRecord is a READ record, and that the integer key
matches the expected value.record - the source record; may not be nullpkField - the single field defining the primary key of the struct; may not be nullpk - the expected integer value of the primary key in the structpublic static void isValidUpdate(org.apache.kafka.connect.source.SourceRecord record)
SourceRecord is a UPDATE record without PK.record - the source record; may not be nullpkField - the single field defining the primary key of the struct; may not be nullpk - the expected integer value of the primary key in the structpublic static void isValidUpdate(org.apache.kafka.connect.source.SourceRecord record,
String pkField,
int pk)
SourceRecord is a UPDATE record, and that the integer key
matches the expected value.record - the source record; may not be nullpkField - the single field defining the primary key of the struct; may not be nullpk - the expected integer value of the primary key in the structpublic static void isValidDelete(org.apache.kafka.connect.source.SourceRecord record)
SourceRecord is a DELETE record without PK.
matches the expected value.record - the source record; may not be nullpkField - the single field defining the primary key of the struct; may not be nullpk - the expected integer value of the primary key in the structpublic static void isValidDelete(org.apache.kafka.connect.source.SourceRecord record,
String pkField,
int pk)
SourceRecord is a DELETE record, and that the integer key
matches the expected value.record - the source record; may not be nullpkField - the single field defining the primary key of the struct; may not be nullpk - the expected integer value of the primary key in the structpublic static void isValidTombstone(org.apache.kafka.connect.source.SourceRecord record,
String pkField,
int pk)
SourceRecord is a valid tombstone, meaning it has a valid non-null key with key schema
but null value and value schema.record - the source record; may not be nullpkField - the single field defining the primary key of the struct; may not be nullpk - the expected integer value of the primary key in the structpublic static void hasValidSourceQuery(org.apache.kafka.connect.source.SourceRecord record,
String query)
SourceRecord has the appropriate source query value.record - the source record; may not be nullquery - the expected sql query value.public static void hasNoSourceQuery(org.apache.kafka.connect.source.SourceRecord record)
SourceRecord has no source query value.record - the source record; may not be nullpublic static void assertValueField(org.apache.kafka.connect.source.SourceRecord record,
String fieldPath,
Object expectedValue)
SourceRecord has the expected value in the given fieldPath.record - the source record; may not be nullfieldPath - the field path to validate, separated by '/'expectedValue - the expected value in the source records field path.public static void assertSameValue(Object actual, Object expected)
SourceRecord values are identical.actual - actual value stored on the source recordexpected - expected value stored on the source recordpublic static void schemaMatchesStruct(org.apache.kafka.connect.data.SchemaAndValue schemaAndValue)
Struct is valid and its schema
matches that of the supplied schema.schemaAndValue - the value with a schema; may not be nullpublic static void schemaMatchesStruct(org.apache.kafka.connect.data.Struct struct,
org.apache.kafka.connect.data.Schema schema)
Struct is valid and its schema
matches that of the supplied schema.struct - the Struct to validate; may not be nullschema - the expected schema of the Struct; may not be nullpublic static void fieldsInSchema(org.apache.kafka.connect.data.Struct struct,
org.apache.kafka.connect.data.Schema schema)
Struct reference the Field definitions in the given Schema.struct - the Struct instance; may not be nullschema - the Schema defining the fields in the Struct; may not be nullpublic static void print(org.apache.kafka.connect.source.SourceRecord record)
record - the source record; may not be nullpublic static void debug(org.apache.kafka.connect.source.SourceRecord record)
record - the source record; may not be nullpublic static void assertEquals(org.apache.kafka.connect.source.SourceRecord actual,
org.apache.kafka.connect.source.SourceRecord expected,
Predicate<String> ignoreFields,
Map<String,VerifyRecord.RecordValueComparator> comparatorsByName,
Map<String,VerifyRecord.RecordValueComparator> comparatorsBySchemaName)
public static void assertConnectSchemasAreEqual(String fieldName, org.apache.kafka.connect.data.Schema actual, org.apache.kafka.connect.data.Schema expected)
fieldName - name of the field owning that schema, if it's not a top-level schemaactual - the actual schemaexpected - the expected schemaprivate static String schemaName(org.apache.kafka.connect.data.Schema schema)
protected static void assertEquals(org.apache.kafka.connect.data.Schema schema,
Object o1,
Object o2,
String keyOrValue,
String field,
Predicate<String> ignoreFields,
Map<String,VerifyRecord.RecordValueComparator> comparatorsByName,
Map<String,VerifyRecord.RecordValueComparator> comparatorsBySchemaName)
public static void isValid(org.apache.kafka.connect.source.SourceRecord record)
SourceRecord's key and value can each be converted to a byte[] and then back to an equivalent
SourceRecord.record - the record to validate; may not be nullprotected static void validateSchemaNames(org.apache.kafka.connect.data.Schema schema)
protected static void validateSubSchemaNames(org.apache.kafka.connect.data.Schema parentSchema,
org.apache.kafka.connect.data.Field field)
protected static void printJson(org.apache.kafka.connect.source.SourceRecord record)
protected static String prettyJson(com.fasterxml.jackson.databind.JsonNode json)
private static Object[] valuesFor(org.apache.kafka.connect.data.Struct struct)
private static boolean areConnectSchemasEqual(org.apache.kafka.connect.data.Schema schema1,
org.apache.kafka.connect.data.Schema schema2)
Copyright © 2019 JBoss by Red Hat. All rights reserved.