CustomLocalDateSerializer extends StdSerializer<LocalDate> { @Override public void serialize(LocalDate value, JsonGenerator gen, SerializerProvider serializerProvider) { if(value == null) return; this.serializer.serialize(LocalDateTime.of(value, LocalTime.MIN), gen, serializerProvider); } CustomLocalDateSerializer();  CustomLocalDateSerializer(Class<LocalDate> t); @Override void serialize(LocalDate value, JsonGenerator gen, SerializerProvider serializerProvider);  }
@Test public void t1_serialize() throws IOException { final LocalDate date = LocalDate.of(1988, 10, 13); Mockito.doNothing().when(this.gen).writeString(Mockito.anyString()); this.testee.serialize(date, gen, null); ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class); Mockito.verify(this.gen).writeString(captor.capture()); Assert.assertEquals("1988-10-13T00:00:00.000Z", captor.getValue()); }
@Test public void t1_serializeBadValue() throws IOException { final LocalDate date = LocalDate.of(1988, 10, 13); Mockito.doThrow(new IOException()).when(this.gen).writeString(Mockito.anyString()); this.thrown.expect(JsonParsingException.class); this.testee.serialize(date, gen, null); }