use of org.apache.kafka.connect.data.SchemaBuilder in project ksql by confluentinc.
the class GenericRowValueTypeEnforcerTest method testEnforceDoubleReturningNull.
@Test
public void testEnforceDoubleReturningNull() {
SchemaBuilder schemaBuilder = SchemaBuilder.struct().field("double", SchemaBuilder.float64());
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 testEnforceBooleanReturningNull.
@Test
public void testEnforceBooleanReturningNull() {
SchemaBuilder schemaBuilder = SchemaBuilder.struct().field("boolean", SchemaBuilder.bool());
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 testEnforceDoubleAndEnforceDoubleOne.
@Test
public void testEnforceDoubleAndEnforceDoubleOne() {
SchemaBuilder schemaBuilder = SchemaBuilder.struct().field("double", SchemaBuilder.float64());
GenericRowValueTypeEnforcer genericRowValueTypeEnforcer = new GenericRowValueTypeEnforcer(schemaBuilder);
assertEquals(0.0, genericRowValueTypeEnforcer.enforceFieldType(0, 0));
}
use of org.apache.kafka.connect.data.SchemaBuilder in project ksql by confluentinc.
the class GenericRowValueTypeEnforcerTest method testEnforceLong.
@Test
public void testEnforceLong() {
SchemaBuilder schemaBuilder = SchemaBuilder.struct().field("long", SchemaBuilder.int64());
GenericRowValueTypeEnforcer genericRowValueTypeEnforcer = new GenericRowValueTypeEnforcer(schemaBuilder);
try {
genericRowValueTypeEnforcer.enforceFieldType(0, Boolean.FALSE);
fail("Expecting exception: KsqlException");
} catch (KsqlException e) {
assertEquals(GenericRowValueTypeEnforcer.class.getName(), e.getStackTrace()[0].getClassName());
}
}
use of org.apache.kafka.connect.data.SchemaBuilder in project ksql by confluentinc.
the class GenericRowValueTypeEnforcerTest method testEnforceDoubleReturningDoubleWhereShortValueIsNegative.
@Test
public void testEnforceDoubleReturningDoubleWhereShortValueIsNegative() {
SchemaBuilder schemaBuilder = SchemaBuilder.struct().field("double", SchemaBuilder.float64());
GenericRowValueTypeEnforcer genericRowValueTypeEnforcer = new GenericRowValueTypeEnforcer(schemaBuilder);
assertEquals(-433.0, genericRowValueTypeEnforcer.enforceFieldType(0, -433));
}
Aggregations