I'm writing mockMvc tests for my controller, and need to validate jsonPath return value.
Have tried differently with .is() and .value(), mapping, in any way i can imagine with no success
Loan loan = new Loan(
"0000-0000",
"OPEN",
LocalDate.now(),
LocalDate.now().plusDays(30),
new BigDecimal("500.0"),
new BigDecimal("50.0"),
new BigDecimal("550.0"),
new ArrayList<>()
);
Mockito.lenient()
.when(loanService.loans())
.thenReturn(Collections.singletonList(loan));
String json = MAPPER.writeValueAsString(loan);
mockMvc.perform(get("/api/loans"))
.andExpect(jsonPath("$.*").value(json));
Expected :{"id":"0000-0000","status":"OPEN","created":"2019-05-09","dueDate":"2019-06-08","principal":500.0,"interest":50.0,"total":550.0,"extensions":[]}
Actual :{id=0000-0000, status=OPEN, created=2019-05-09, dueDate=2019-06-08, principal=500.0, interest=50.0, total=550.0, extensions=[]}
So this is the closes i got, just dont get the types here.