use of org.apache.kafka.connect.data.SchemaBuilder in project ksql by confluentinc.
the class GenericRowValueTypeEnforcerTest method testEnforceIntegerOnValidString.
@Test
public void testEnforceIntegerOnValidString() {
SchemaBuilder schemaBuilder = SchemaBuilder.struct().field("int", SchemaBuilder.int32());
GenericRowValueTypeEnforcer genericRowValueTypeEnforcer = new GenericRowValueTypeEnforcer(schemaBuilder);
assertEquals(-55, genericRowValueTypeEnforcer.enforceFieldType(0, "-55"));
}
use of org.apache.kafka.connect.data.SchemaBuilder in project ksql by confluentinc.
the class GenericRowValueTypeEnforcerTest method testEnforceLongReturningLongWhereByteValueIsNegative.
@Test
public void testEnforceLongReturningLongWhereByteValueIsNegative() {
SchemaBuilder schemaBuilder = SchemaBuilder.struct().field("long", SchemaBuilder.int64());
GenericRowValueTypeEnforcer genericRowValueTypeEnforcer = new GenericRowValueTypeEnforcer(schemaBuilder);
assertEquals(-2315L, genericRowValueTypeEnforcer.enforceFieldType(0, -2315));
}
use of org.apache.kafka.connect.data.SchemaBuilder in project ksql by confluentinc.
the class GenericRowValueTypeEnforcerTest method testEnforceLongOnValidString.
@Test
public void testEnforceLongOnValidString() {
SchemaBuilder schemaBuilder = SchemaBuilder.struct().field("long", SchemaBuilder.int64());
GenericRowValueTypeEnforcer genericRowValueTypeEnforcer = new GenericRowValueTypeEnforcer(schemaBuilder);
assertEquals(-123L, genericRowValueTypeEnforcer.enforceFieldType(0, "-123"));
}
use of org.apache.kafka.connect.data.SchemaBuilder in project ksql by confluentinc.
the class GenericRowValueTypeEnforcerTest method testEnforceDoubleThrowsNumberFormatExceptionOnInvalidCharSequence.
@Test(expected = NumberFormatException.class)
public void testEnforceDoubleThrowsNumberFormatExceptionOnInvalidCharSequence() {
SchemaBuilder schemaBuilder = SchemaBuilder.struct().field("double", SchemaBuilder.float64());
GenericRowValueTypeEnforcer genericRowValueTypeEnforcer = new GenericRowValueTypeEnforcer(schemaBuilder);
genericRowValueTypeEnforcer.enforceFieldType(0, new StringBuilder("not a double"));
}
use of org.apache.kafka.connect.data.SchemaBuilder in project ksql by confluentinc.
the class GenericRowValueTypeEnforcerTest method testEnforceBooleanReturningBooleanWhereBooleanValueIsFalse.
@Test
public void testEnforceBooleanReturningBooleanWhereBooleanValueIsFalse() {
SchemaBuilder schemaBuilder = SchemaBuilder.struct().field("boolean", SchemaBuilder.bool());
GenericRowValueTypeEnforcer genericRowValueTypeEnforcer = new GenericRowValueTypeEnforcer(schemaBuilder);
assertEquals(Boolean.FALSE, genericRowValueTypeEnforcer.enforceFieldType(0, "0x"));
}
Aggregations