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