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