use of org.apache.kafka.connect.data.SchemaBuilder in project ksql by confluentinc.
the class GenericRowValueTypeEnforcerTest method testEnforceLongThrowsNumberFormatExceptionOnInvalidString.
@Test
public void testEnforceLongThrowsNumberFormatExceptionOnInvalidString() {
SchemaBuilder schemaBuilder = SchemaBuilder.struct().field("long", SchemaBuilder.int64());
GenericRowValueTypeEnforcer genericRowValueTypeEnforcer = new GenericRowValueTypeEnforcer(schemaBuilder);
try {
genericRowValueTypeEnforcer.enforceFieldType(0, "-drbetk");
fail("Expecting exception: NumberFormatException");
} catch (NumberFormatException e) {
assertEquals(NumberFormatException.class.getName(), e.getStackTrace()[0].getClassName());
}
}
use of org.apache.kafka.connect.data.SchemaBuilder in project ksql by confluentinc.
the class GenericRowValueTypeEnforcerTest method testEnforceLongReturningLongWhereShortValueIsNegative.
@Test
public void testEnforceLongReturningLongWhereShortValueIsNegative() {
SchemaBuilder schemaBuilder = SchemaBuilder.struct().field("long", SchemaBuilder.int64());
GenericRowValueTypeEnforcer genericRowValueTypeEnforcer = new GenericRowValueTypeEnforcer(schemaBuilder);
assertEquals(-446L, genericRowValueTypeEnforcer.enforceFieldType(0, -446.28F));
}
use of org.apache.kafka.connect.data.SchemaBuilder in project ksql by confluentinc.
the class GenericRowValueTypeEnforcerTest method testEnforceDoubleAndEnforceDoubleTwo.
@Test
public void testEnforceDoubleAndEnforceDoubleTwo() {
SchemaBuilder schemaBuilder = SchemaBuilder.struct().field("double", SchemaBuilder.float64());
GenericRowValueTypeEnforcer genericRowValueTypeEnforcer = new GenericRowValueTypeEnforcer(schemaBuilder);
assertEquals(0.0, genericRowValueTypeEnforcer.enforceFieldType(0, 0.0F));
}
use of org.apache.kafka.connect.data.SchemaBuilder in project ksql by confluentinc.
the class GenericRowValueTypeEnforcerTest method testEnforceIntegerReturningNull.
@Test
public void testEnforceIntegerReturningNull() {
SchemaBuilder schemaBuilder = SchemaBuilder.struct().field("int", SchemaBuilder.int32());
GenericRowValueTypeEnforcer genericRowValueTypeEnforcer = new GenericRowValueTypeEnforcer(schemaBuilder);
assertNull(genericRowValueTypeEnforcer.enforceFieldType(0, null));
}
use of org.apache.kafka.connect.data.SchemaBuilder in project ksql by confluentinc.
the class GenericRowValueTypeEnforcerTest method testEnforceIntegerOnValidCharSequence.
@Test
public void testEnforceIntegerOnValidCharSequence() {
SchemaBuilder schemaBuilder = SchemaBuilder.struct().field("int", SchemaBuilder.int32());
GenericRowValueTypeEnforcer genericRowValueTypeEnforcer = new GenericRowValueTypeEnforcer(schemaBuilder);
assertEquals(55, genericRowValueTypeEnforcer.enforceFieldType(0, new StringBuilder("55")));
}
Aggregations