### Question:
RoundingFloatSerializer extends JsonSerializer<Float> { @Override public void serialize(Float value, JsonGenerator gen, SerializerProvider serializers) throws IOException { gen.writeNumber(BigDecimal.valueOf(value) .setScale(DECIMAL_POINTS, RoundingMode.HALF_UP) .floatValue() ); }  @Override void serialize(Float value, JsonGenerator gen, SerializerProvider serializers);  }### Answer:
@Test public void testSerializeFloatRoundDown() throws IOException { JsonGenerator generator = mock(JsonGenerator.class); RoundingFloatSerializer serializer = new RoundingFloatSerializer(); serializer.serialize(0.444f, generator, null); verify(generator, times(1)).writeNumber(eq(0.44f)); }
@Test public void testSerializeFloatRoundUp() throws IOException { JsonGenerator generator = mock(JsonGenerator.class); RoundingFloatSerializer serializer = new RoundingFloatSerializer(); serializer.serialize(0.555f, generator, null); verify(generator, times(1)).writeNumber(eq(0.56f)); }