### Question:
PrimitiveFloatConverter implements Converter<Float> { public Float convert(String value, Class<? extends Float> type, ResourceBundle bundle) { if (isNullOrEmpty(value)) { return 0f; } try { return Float.parseFloat(value); } catch (NumberFormatException e) { throw new ConversionError(MessageFormat.format(bundle.getString("is_not_a_valid_number"), value)); } }  Float convert(String value, Class<? extends Float> type, ResourceBundle bundle);  }### Answer:
@Test public void shouldBeAbleToConvertNumbers() { assertThat((Float) converter.convert("2.2", float.class, bundle), is(equalTo(2.2f))); }
@Test public void shouldComplainAboutInvalidNumber() { try { converter.convert("---", float.class, bundle); } catch (ConversionError e) { assertThat(e.getMessage(), is(equalTo("--- is not a valid number."))); } }
@Test public void shouldConvertToZeroWhenNull() { assertThat((Float) converter.convert(null, float.class, bundle), is(equalTo(0F))); }
@Test public void shouldConvertToZeroWhenEmpty() { assertThat((Float) converter.convert("", float.class, bundle), is(equalTo(0F))); }