use of org.apache.kafka.connect.data.SchemaBuilder in project ksql by confluentinc.
the class GenericRowValueTypeEnforcerTest method testEnforceString.
@Test
public void testEnforceString() {
SchemaBuilder schemaBuilder = SchemaBuilder.struct().field("string", SchemaBuilder.string());
GenericRowValueTypeEnforcer genericRowValueTypeEnforcer = new GenericRowValueTypeEnforcer(schemaBuilder);
try {
genericRowValueTypeEnforcer.enforceFieldType(0, 0.0);
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 testEnforceBooleanReturningBooleanWhereBooleanValueIsTrue.
@Test
public void testEnforceBooleanReturningBooleanWhereBooleanValueIsTrue() {
SchemaBuilder schemaBuilder = SchemaBuilder.struct().field("boolean", SchemaBuilder.bool());
GenericRowValueTypeEnforcer genericRowValueTypeEnforcer = new GenericRowValueTypeEnforcer(schemaBuilder);
assertEquals(Boolean.TRUE, genericRowValueTypeEnforcer.enforceFieldType(0, true));
}
use of org.apache.kafka.connect.data.SchemaBuilder in project ksql by confluentinc.
the class GenericRowValueTypeEnforcerTest method testEnforceIntegerAndEnforceIntegerFour.
@Test
public void testEnforceIntegerAndEnforceIntegerFour() {
SchemaBuilder schemaBuilder = SchemaBuilder.struct().field("int", SchemaBuilder.int32());
GenericRowValueTypeEnforcer genericRowValueTypeEnforcer = new GenericRowValueTypeEnforcer(schemaBuilder);
assertEquals(1, genericRowValueTypeEnforcer.enforceFieldType(0, 1));
}
use of org.apache.kafka.connect.data.SchemaBuilder in project ksql by confluentinc.
the class GenericRowValueTypeEnforcerTest method testEnforceDoubleReturningDoubleWhereShortValueIsPositive.
@Test
public void testEnforceDoubleReturningDoubleWhereShortValueIsPositive() {
SchemaBuilder schemaBuilder = SchemaBuilder.struct().field("double", SchemaBuilder.float64());
GenericRowValueTypeEnforcer genericRowValueTypeEnforcer = new GenericRowValueTypeEnforcer(schemaBuilder);
assertEquals(366.0, genericRowValueTypeEnforcer.enforceFieldType(0, 366L));
}
use of org.apache.kafka.connect.data.SchemaBuilder in project ksql by confluentinc.
the class GenericRowValueTypeEnforcerTest method testEnforceStringReturningNull.
@Test
public void testEnforceStringReturningNull() {
SchemaBuilder schemaBuilder = SchemaBuilder.struct().field("string", SchemaBuilder.string());
GenericRowValueTypeEnforcer genericRowValueTypeEnforcer = new GenericRowValueTypeEnforcer(schemaBuilder);
assertNull(genericRowValueTypeEnforcer.enforceFieldType(0, null));
}
Aggregations