In the integration test for the DELETE method, let's try to delete the todo with an ID, 3, belonging to Jill.
We would need to send a DELETE request to /users/Jill/todos/3.
The integration test is as follows:
@Test
public void deleteTodo() throws Exception {
ResponseEntity < String > response = template.exchange(
"/users/Jill/todos/3",
HttpMethod.DELETE,
new HttpEntity < > (null, headers), String.class);
assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode());
}
We use template.exchange to execute the DELETE request. We assert the status of HttpStatus.NO_CONTENT.