@Test public void testNonInteger() throws Exception { try { Type.INTEGER.convert("foo", null); fail(); } catch (Type.ConversionException e) { // This does not use assertMessageContainsWordsWithQuotes because at least // one test should test exact wording (but they all shouldn't to make // changing/improving the messages easy). assertThat(e).hasMessage("expected value of type 'int', but got \"foo\" (string)"); } }
@Test public void testInteger() throws Exception { Object x = 3; assertEquals(x, Type.INTEGER.convert(x, null)); assertThat(Type.INTEGER.flatten(x)).isEmpty(); }