use of io.confluent.ksql.schema.ksql.types.SqlTypes.BOOLEAN in project ksql by confluentinc.
the class OperatorTest method shouldWorkUsingSameRulesAsBaseTypeUpCastRules.
@Test
public void shouldWorkUsingSameRulesAsBaseTypeUpCastRules() {
allOperations().forEach(op -> {
for (final SqlBaseType leftBaseType : SqlBaseType.values()) {
// Given:
final Map<Boolean, List<SqlBaseType>> partitioned = Arrays.stream(SqlBaseType.values()).collect(Collectors.partitioningBy(rightBaseType -> shouldBeSupported(op, leftBaseType, rightBaseType)));
final List<SqlBaseType> shouldUpCast = partitioned.getOrDefault(true, ImmutableList.of());
final List<SqlBaseType> shouldNotUpCast = partitioned.getOrDefault(false, ImmutableList.of());
// Then:
shouldUpCast.forEach(rightBaseType -> assertThat("should support " + op + " on (" + leftBaseType + ", " + rightBaseType + ")", op.resultType(getType(leftBaseType), getType(rightBaseType)), is(notNullValue())));
shouldNotUpCast.forEach(rightBaseType -> {
try {
op.resultType(getType(leftBaseType), getType(rightBaseType));
fail("should not support " + op + " on (" + leftBaseType + ", " + rightBaseType + ")");
} catch (final KsqlException e) {
// Expected
}
});
}
});
}
Aggregations