From d702a867c74996e534441c5bdd6bdc08800f51cf Mon Sep 17 00:00:00 2001 From: Jan Klattenhoff Date: Wed, 23 Oct 2024 11:47:58 +0200 Subject: [PATCH] test: add 404 response test for non-existent project --- .../RemoveEmployeeFromProjectIntegrationTest.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/test/java/de/szut/lf8_starter/integration/project/RemoveEmployeeFromProjectIntegrationTest.java b/src/test/java/de/szut/lf8_starter/integration/project/RemoveEmployeeFromProjectIntegrationTest.java index 978fd7c..7e55dd8 100644 --- a/src/test/java/de/szut/lf8_starter/integration/project/RemoveEmployeeFromProjectIntegrationTest.java +++ b/src/test/java/de/szut/lf8_starter/integration/project/RemoveEmployeeFromProjectIntegrationTest.java @@ -17,8 +17,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @SpringBootTest @@ -75,4 +74,12 @@ class RemoveEmployeeFromProjectIntegrationTest { return Objects.requireNonNull(response.getBody()).get("access_token").toString(); } + + @Test + void removeEmployeeShouldReturn404IfProjectNotFound() throws Exception { + mockMvc.perform(delete("/projects/{projectId}/employees/{employeeId}", 1987234987, 312) + .header(HttpHeaders.AUTHORIZATION, getBearerToken()) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isNotFound()); + } }