BAEL-2495 minor changes
This commit is contained in:
@@ -8,7 +8,6 @@ import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
|
|||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
|
||||||
public class EventWithLocalDate {
|
public class EventWithLocalDate {
|
||||||
public String name;
|
public String name;
|
||||||
|
|
||||||
@@ -17,9 +16,7 @@ public class EventWithLocalDate {
|
|||||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy")
|
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy")
|
||||||
public LocalDate eventDate;
|
public LocalDate eventDate;
|
||||||
|
|
||||||
public EventWithLocalDate() {
|
public EventWithLocalDate() {}
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
public EventWithLocalDate(final String name, final LocalDate eventDate) {
|
public EventWithLocalDate(final String name, final LocalDate eventDate) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|||||||
@@ -159,24 +159,23 @@ public class JacksonDateUnitTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenSerializingJava8DateAndReadingValue_thenCorrect() throws IOException {
|
public void whenSerializingJava8DateAndReadingValue_thenCorrect() throws IOException {
|
||||||
final String stringDate = "\"2014-12-20\"";
|
String stringDate = "\"2014-12-20\"";
|
||||||
|
|
||||||
final ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
mapper.registerModule(new JavaTimeModule());
|
mapper.registerModule(new JavaTimeModule());
|
||||||
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||||
|
|
||||||
final String result2 = mapper.readValue(stringDate, LocalDate.class)
|
LocalDate result = mapper.readValue(stringDate, LocalDate.class);
|
||||||
.toString();
|
assertThat(result.toString(), containsString("2014-12-20"));
|
||||||
assertThat(result2, containsString("2014-12-20"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenSerializingJava8DateAndReadingFromEntity_thenCorrect() throws IOException {
|
public void whenSerializingJava8DateAndReadingFromEntity_thenCorrect() throws IOException {
|
||||||
final String json = "{\"name\":\"party\",\"eventDate\":\"20-12-2014\"}";
|
String json = "{\"name\":\"party\",\"eventDate\":\"20-12-2014\"}";
|
||||||
|
|
||||||
final ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
|
||||||
final EventWithLocalDate result = mapper.readValue(json, EventWithLocalDate.class);
|
EventWithLocalDate result = mapper.readValue(json, EventWithLocalDate.class);
|
||||||
assertThat(result.getEventDate().toString(), containsString("2014-12-20"));
|
assertThat(result.getEventDate().toString(), containsString("2014-12-20"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user