Writing an integration test for deleting a todo – the DELETE method

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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset