@Test public void shouldComplainAboutInvalidNumber() { try { converter.convert("---", int.class, bundle); } catch (ConversionError e) { assertThat(e.getMessage(), is(equalTo("--- is not a valid integer."))); } }
public Integer convert(String value, Class<? extends Integer> type, ResourceBundle bundle) { if (isNullOrEmpty(value)) { return 0; } try { return Integer.parseInt(value); } catch (NumberFormatException e) { throw new ConversionError(MessageFormat.format(bundle.getString("is_not_a_valid_integer"), value)); } }
PrimitiveIntConverter implements Converter<Integer> { public Integer convert(String value, Class<? extends Integer> type, ResourceBundle bundle) { if (isNullOrEmpty(value)) { return 0; } try { return Integer.parseInt(value); } catch (NumberFormatException e) { throw new ConversionError(MessageFormat.format(bundle.getString("is_not_a_valid_integer"), value)); } } }
PrimitiveIntConverter implements Converter<Integer> { public Integer convert(String value, Class<? extends Integer> type, ResourceBundle bundle) { if (isNullOrEmpty(value)) { return 0; } try { return Integer.parseInt(value); } catch (NumberFormatException e) { throw new ConversionError(MessageFormat.format(bundle.getString("is_not_a_valid_integer"), value)); } }  }
PrimitiveIntConverter implements Converter<Integer> { public Integer convert(String value, Class<? extends Integer> type, ResourceBundle bundle) { if (isNullOrEmpty(value)) { return 0; } try { return Integer.parseInt(value); } catch (NumberFormatException e) { throw new ConversionError(MessageFormat.format(bundle.getString("is_not_a_valid_integer"), value)); } }  Integer convert(String value, Class<? extends Integer> type, ResourceBundle bundle); }
PrimitiveIntConverter implements Converter<Integer> { public Integer convert(String value, Class<? extends Integer> type, ResourceBundle bundle) { if (isNullOrEmpty(value)) { return 0; } try { return Integer.parseInt(value); } catch (NumberFormatException e) { throw new ConversionError(MessageFormat.format(bundle.getString("is_not_a_valid_integer"), value)); } }  Integer convert(String value, Class<? extends Integer> type, ResourceBundle bundle);  }