### Question:
JavaTimeTypesParamConverterProvider implements ParamConverterProvider { @SuppressWarnings("unchecked") @Override public <T> ParamConverter<T> getConverter(Class<T> rawType, Type genericType, Annotation[] annotations) { if (rawType.equals(LocalDateTime.class)) { return (ParamConverter<T>) new LocalDateTimeConverter(); } else if (rawType.equals(LocalDate.class)) { return (ParamConverter<T>) new LocalDateConverter(); } else if (rawType.equals(LocalTime.class)) { return (ParamConverter<T>) new LocalTimeConverter(); } else if (rawType.equals(OffsetDateTime.class)) { return (ParamConverter<T>) new OffsetDateTimeConverter(); } else if (rawType.equals(OffsetTime.class)) { return (ParamConverter<T>) new OffsetTimeConverter(); } else if (rawType.equals(ZonedDateTime.class)) { return (ParamConverter<T>) new ZonedDateTimeConverter(); } else { return null; } }  @SuppressWarnings("unchecked") @Override ParamConverter<T> getConverter(Class<T> rawType, Type genericType, Annotation[] annotations);  }### Answer:
@Test public void localDate() { LocalDate localDate = LocalDate.of(2016, 2, 24); ParamConverter<LocalDate> converter = (ParamConverter<LocalDate>) provider.getConverter(localDate.getClass(), localDate.getClass(), localDate.getClass().getAnnotations()); Assert.assertEquals(localDate, converter.fromString(converter.toString(localDate))); }
@Test(expected = IllegalArgumentException.class) public void invalidLocalDate() { ParamConverter<LocalDate> converter = provider.getConverter(LocalDate.class, LocalDate.class, null); converter.fromString("invalid"); }
@Test public void localDateTime() { LocalDateTime localDateTime = LocalDateTime.of(2016, 2, 24, 5, 55); ParamConverter<LocalDateTime> converter = (ParamConverter<LocalDateTime>) provider.getConverter(localDateTime.getClass(), localDateTime.getClass(), localDateTime.getClass().getAnnotations()); Assert.assertEquals(localDateTime, converter.fromString(converter.toString(localDateTime))); }
@Test public void localTime() { LocalTime localTime = LocalTime.of(10, 33); ParamConverter<LocalTime> converter = (ParamConverter<LocalTime>) provider.getConverter(localTime.getClass(), localTime.getClass(), localTime.getClass().getAnnotations()); Assert.assertEquals(localTime, converter.fromString(converter.toString(localTime))); }
@Test public void offsetDateTime() { OffsetDateTime offsetDateTime = OffsetDateTime.of(2016, 2, 24, 5, 55, 0, 0, ZoneOffset.UTC); ParamConverter<OffsetDateTime> converter = (ParamConverter<OffsetDateTime>) provider.getConverter(offsetDateTime.getClass(), offsetDateTime.getClass(), offsetDateTime.getClass().getAnnotations()); Assert.assertEquals(offsetDateTime, converter.fromString(converter.toString(offsetDateTime))); }
@Test public void offsetTime() { OffsetTime offsetTime = OffsetTime.of(10, 33, 24, 5, ZoneOffset.ofHours(2)); ParamConverter<OffsetTime> converter = (ParamConverter<OffsetTime>) provider.getConverter(offsetTime.getClass(), offsetTime.getClass(), offsetTime.getClass().getAnnotations()); Assert.assertEquals(offsetTime, converter.fromString(converter.toString(offsetTime))); }
@Test public void zonedDateTime() { ZonedDateTime zonedDateTime = ZonedDateTime.of(2016, 2, 24, 6, 10, 9, 5, ZoneOffset.ofHours(6)); ParamConverter<ZonedDateTime> converter = (ParamConverter<ZonedDateTime>) provider.getConverter(zonedDateTime.getClass(), zonedDateTime.getClass(), zonedDateTime.getClass().getAnnotations()); Assert.assertEquals(zonedDateTime, converter.fromString(converter.toString(zonedDateTime))); }