Search in sources :

Example 1 with DecimalConversion

use of org.apache.avro.Conversions.DecimalConversion in project ksql by confluentinc.

the class KsqlAvroSerializerTest method shouldSerializeDecimalField.

@Test
public void shouldSerializeDecimalField() {
    final BigDecimal value = new BigDecimal("12.34");
    final ByteBuffer bytes = new DecimalConversion().toBytes(value, DECIMAL_SCHEMA, LogicalTypes.decimal(4, 2));
    shouldSerializeFieldTypeCorrectly(DecimalUtil.builder(4, 2).build(), value, DECIMAL_SCHEMA, bytes);
}
Also used : DecimalConversion(org.apache.avro.Conversions.DecimalConversion) ByteBuffer(java.nio.ByteBuffer) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Aggregations

BigDecimal (java.math.BigDecimal)1 ByteBuffer (java.nio.ByteBuffer)1 DecimalConversion (org.apache.avro.Conversions.DecimalConversion)1 Test (org.junit.Test)1