BookingMessageTO { public static BookingMessageTO fromJson(String json) { try (ByteArrayInputStream bos = new ByteArrayInputStream(json.getBytes(StandardCharsets.UTF_8))) { return new BookingMessageTOReader().readFrom(null, null, null, null, null, bos); } catch (IOException e) { throw new RuntimeException("Cannot convert " + json, e); } } BookingMessageTO(Long guest, String room, LocalDate checkin, LocalDate checkout); Long getGuest(); String getRoom(); LocalDate getCheckin(); LocalDate getCheckout(); @Override String toString(); static BookingMessageTO fromJson(String json); String toJson();  }
@Test public void fromJson() { BookingMessageTO fromJson = BookingMessageTO.fromJson(JSON); assertThat(fromJson.getGuest(), is(equalTo(12L))); assertThat(fromJson.getRoom(), is(equalTo("abc"))); assertThat(fromJson.getCheckin(), is(equalTo(LocalDate.of(2014, Month.NOVEMBER, 25)))); assertThat(fromJson.getCheckout(), is(equalTo(LocalDate.of(2014, Month.NOVEMBER, 25)))); }