### Question:
RoundingFloatDeserializer extends JsonDeserializer<Float> { @Override public Float deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { if (p.hasToken(JsonToken.VALUE_NUMBER_FLOAT)) { return BigDecimal.valueOf(p.getFloatValue()) .setScale(DECIMAL_POINTS, RoundingMode.HALF_UP) .floatValue(); } return (Float) ctxt.handleUnexpectedToken(Float.class, p); }  @Override Float deserialize(JsonParser p, DeserializationContext ctxt);  }### Answer:
@Test public void testDeserializeFloatRoundDown() throws IOException { when(parser.hasToken(eq(JsonToken.VALUE_NUMBER_FLOAT))).thenReturn(true); when(parser.getFloatValue()).thenReturn(0.444f); assertEquals(0.44f, deserializer.deserialize(parser, context), 0.0f); }
@Test public void testDeserializeFloatRoundUp() throws IOException { when(parser.hasToken(eq(JsonToken.VALUE_NUMBER_FLOAT))).thenReturn(true); when(parser.getFloatValue()).thenReturn(0.555f); assertEquals(0.56f, deserializer.deserialize(parser, context), 0.0f); }
@Test(expected = MismatchedInputException.class) public void testDeserializeInvalidToken() throws IOException { when(context.handleUnexpectedToken(eq(Float.class), eq(parser))).thenThrow(MismatchedInputException.class); deserializer.deserialize(parser, context); }