@Test public void should_throw_error_if_conversion_throws_NumberFormatException() { try { converter.toValue("0xZ", node); fail("Expecting a " + ValueConverterException.class.getName()); } catch (ValueConverterException e) { assertThat(e.getMessage(), equalTo("Couldn't convert '0xZ' to long.")); assertThat(e.getCause(), instanceOf(NumberFormatException.class)); } }
@Test public void should_throw_error_if_input_has_less_than_three_characters() { thrown.expect(ValueConverterException.class); thrown.expectMessage("Couldn't convert '0x' to long."); converter.toValue("0x", node); }
@Test public void should_throw_error_if_input_is_empty() { thrown.expect(ValueConverterException.class); thrown.expectMessage("Couldn't convert empty string to long."); converter.toValue("", node); }