BAEL-2495 minor changes

This commit is contained in:
patkorek
2020-05-29 16:10:10 +02:00
parent 20e1b768e6
commit 174d8664e2
2 changed files with 8 additions and 12 deletions

View File

@@ -8,7 +8,6 @@ import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
import java.time.LocalDate;
public class EventWithLocalDate {
public String name;
@@ -17,9 +16,7 @@ public class EventWithLocalDate {
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy")
public LocalDate eventDate;
public EventWithLocalDate() {
super();
}
public EventWithLocalDate() {}
public EventWithLocalDate(final String name, final LocalDate eventDate) {
this.name = name;

View File

@@ -159,24 +159,23 @@ public class JacksonDateUnitTest {
@Test
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.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
final String result2 = mapper.readValue(stringDate, LocalDate.class)
.toString();
assertThat(result2, containsString("2014-12-20"));
LocalDate result = mapper.readValue(stringDate, LocalDate.class);
assertThat(result.toString(), containsString("2014-12-20"));
}
@Test
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"));
}