dimanche 25 février 2018

spring rest testing @JsonFormat annotation

I need to test if my endpoint /people return correct json values. I use in my Person model `@JsonFormat annotation, when I use Postman or browser it produces correct date in format "dd-MM-yyyy".

Example:

@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyy")
private LocalDate birthDate;

And output is correct in json-> birthDate: "01-01-2000"

But if I want to test my controller, it produces me following error:

Expected: is "01-01-2000"
 but: was <{year=2000, month=JANUARY, monthValue=1, dayOfMonth=1, 
 chronology={id=ISO, calendarType=iso8601}, leapYear=true, 
 dayOfWeek=SATURDAY, dayOfYear=1, era=CE}>

I don't know where is the problem.

Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire