JsonObjectMapper implements ObjectMapper { @Override public String writeValue(Object value) { return getGson().toJson(value); }  @Override T readValue(String value, Class<T> valueType); @Override T readValue(String value, GenericType<T> genericType); @Override String writeValue(Object value); static final String ISO_8601; }
@Test void serializeEverythingNull() { TestDates test = new TestDates(); String actual = om.writeValue(test); assertEquals("{}", actual); }
@Test void serializeDate_iso_with_time() { TestDates date = getDate("1985-07-03T18:00:00.042Z"); String actual = om.writeValue(date); assertEquals("{\"date\":\"1985-07-03T18:00:00.042Z\"}", actual); }
@Test void serializeDate_iso_no_time() { TestDates date = getDate(new Date(489196800000L)); String actual = om.writeValue(date); assertEquals("{\"date\":\"1985-07-03T00:00:00Z\"}", actual); }
@Test void canSerializeCalendar() { TestDates test = getCalendar("1985-07-03T18:00:00.042Z"); String actual = om.writeValue(test); assertEquals("{\"calendar\":\"1985-07-03T18:00:00.042Z\"}", actual); }
@Test void canSerializeCalendar_no_time() { Calendar cal = GregorianCalendar.getInstance(); cal.set(1985, 6, 3, 0, 0, 0); cal.set(Calendar.MILLISECOND, 0); TestDates test = getCalendar(cal); String actual = om.writeValue(test); assertEquals("{\"calendar\":\"1985-07-03T00:00:00Z\"}", actual); }
@Test void canSerializeZonedDateTimes() { ZonedDateTime zonedDt = ZonedDateTime.parse("1985-07-03T18:00:00.042Z").withFixedOffsetZone(); TestDates test = new TestDates(); test.setZonedDateTime(zonedDt); String actual = om.writeValue(test); assertEquals("{\"zonedDateTime\":\"1985-07-03T18:00:00.042Z\"}", actual); }
@Test void canSerializeLocalDateTimes() { LocalDateTime zonedDt = LocalDateTime.parse("1985-07-03T18:00:00.042"); TestDates test = new TestDates(); test.setLocalDateTime(zonedDt); String actual = om.writeValue(test); assertEquals("{\"localDateTime\":\"1985-07-03T18:00:00.042\"}", actual); }
@Test void canSerializeLocalDate() { LocalDate zonedDt = LocalDate.parse("1985-07-03"); TestDates test = new TestDates(); test.setLocalDate(zonedDt); String actual = om.writeValue(test); assertEquals("{\"localDate\":\"1985-07-03\"}", actual); }