Writing an integration test to retrieve all todos is simple. Consider the following method:
@Test
public void retrieveTodos() throws Exception {
String expected = "[" + "{id:1,user:Jack,desc:"Learn Spring MVC",done:false}" + "," +
"{id:2,user:Jack,desc:"Learn Struts",done:false}" + "]";
ResponseEntity < String > response = template.exchange(
"/users/Jack/todos",
HttpMethod.GET,
new HttpEntity < String > (null, headers), String.class);
JSONAssert.assertEquals(expected,
response.getBody(), false);
}
This test is very similar to the integration test for BasicController, except for the fact that we are using JSONAssert to assert the response content.