@Test public void whenValueIsAValidDateShouldGetCorrespondingDate() throws Exception { givenLocaleIs(Locale.ENGLISH); LocalDate date = converter.convert("10/29/2009", LocalDate.class, null); assertThat(date, is(new LocalDate(2009, 10, 29))); mockery.assertIsSatisfied(); }
@Test public void whenValueIsAnInvalidDateShouldThrowConversionError() throws Exception { givenLocaleIs(Locale.ENGLISH); try { converter.convert("an unparseable date", LocalDate.class, null); fail("expected ConversionError"); } catch (ConversionError e) { mockery.assertIsSatisfied(); } }
@Test public void whenValueIsBlankOrNullShouldReturnNull() throws Exception { assertNull(converter.convert(null, LocalDate.class, null)); assertNull(converter.convert("", LocalDate.class, null)); }