I'm trying to do a Spring-Test-MVC. Here is my code ...
@Test
public void findAll_UWPersonsFound_ShouldReturnFoundUWPersonEntries() throws Exception {
UWPerson first = this.personBuilder("ID1", "John", "Doe", "111-11-1111");
UWPerson second = this.personBuilder("ID12", "Jane", "Smith", "222-22-11222211");
when(serviceMock.findAll()).thenReturn(Arrays.asList(first, second));
mockMvc.perform(get("/uw/person"))
.andExpect(status().isOk())
// .andExpect(content().contentType(TestUtil.APPLICATION_JSON_UTF8))
.andExpect(jsonPath("$", hasSize(2)))
.andExpect(jsonPath("$[0].id", is("ID1")))
.andExpect(jsonPath("$[0].first_name", is("John")))
.andExpect(jsonPath("$[0].last_name", is("Doe")))
.andExpect(jsonPath("$[0], ssn", is("111-11-1111")))
.andExpect(jsonPath("$[1].id", is("ID2")))
.andExpect(jsonPath("$[1].first_name", is("Jane")))
.andExpect(jsonPath("$[1].last_name", is("Smith")))
.andExpect(jsonPath("$[1], ssn", is("222-222-2222")))
;
verify(serviceMock, times(1)).findAll();
verifyNoMoreInteractions(serviceMock);
}
The error I'm getting is ... java.lang.IllegalArgumentException: json can not be null or empty
Can someone help me understand what's going on here?
Aucun commentaire:
Enregistrer un commentaire