DBZ-804 Better schema comparison in tests; preparing byte conversion
This commit is contained in:
parent
9814a5c82c
commit
0362b333bf
@ -14,6 +14,9 @@
|
||||
*/
|
||||
public class NumberConversions {
|
||||
|
||||
public static final Byte BYTE_TRUE = Byte.valueOf((byte) 1);
|
||||
public static final Byte BYTE_FALSE = Byte.valueOf((byte) 0);
|
||||
|
||||
public static final Short SHORT_TRUE = Short.valueOf((short) 1);
|
||||
public static final Short SHORT_FALSE = Short.valueOf((short) 0);
|
||||
|
||||
@ -42,6 +45,16 @@ public static BigDecimal getBigDecimal(Boolean data) {
|
||||
return data.booleanValue() ? BigDecimal.ONE : BigDecimal.ZERO;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert boolean object to short object.
|
||||
*
|
||||
* @param data A boolean object
|
||||
* @return Byte 0 or 1
|
||||
*/
|
||||
public static Byte getByte(boolean data) {
|
||||
return data ? BYTE_TRUE : BYTE_FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert boolean object to short object.
|
||||
*
|
||||
|
@ -14,12 +14,12 @@
|
||||
import org.fest.assertions.Assertions;
|
||||
|
||||
public class SchemaAndValueField {
|
||||
private final Object schema;
|
||||
private final Schema schema;
|
||||
private final Object value;
|
||||
private final String fieldName;
|
||||
private Supplier<Boolean> assertValueOnlyIf = null;
|
||||
|
||||
public SchemaAndValueField(String fieldName, Object schema, Object value) {
|
||||
public SchemaAndValueField(String fieldName, Schema schema, Object value) {
|
||||
this.schema = schema;
|
||||
this.value = value;
|
||||
this.fieldName = fieldName;
|
||||
@ -105,6 +105,7 @@ private void assertSchema(Struct content) {
|
||||
Schema schema = content.schema();
|
||||
Field field = schema.field(fieldName);
|
||||
Assertions.assertThat(field).as(fieldName + " not found in schema " + schema).isNotNull();
|
||||
Assertions.assertThat(field.schema()).as("Schema for " + field.name() + " does not match the actual value").isEqualTo(this.schema);
|
||||
|
||||
VerifyRecord.assertConnectSchemasAreEqual(field.name(), field.schema(), this.schema);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user