diff --git a/src/main/java/de/szut/lf8_starter/project/action/RemoveProjectAction.java b/src/main/java/de/szut/lf8_starter/project/action/RemoveProjectAction.java index 4d93a28..767c22d 100644 --- a/src/main/java/de/szut/lf8_starter/project/action/RemoveProjectAction.java +++ b/src/main/java/de/szut/lf8_starter/project/action/RemoveProjectAction.java @@ -33,12 +33,11 @@ public class RemoveProjectAction { @DeleteMapping("/{id}") public ResponseEntity findArticleById(@PathVariable Long id) { Optional project = this.projectService.findById(id); - if (project.isEmpty()) { return new ResponseEntity<>(HttpStatus.NOT_FOUND); } - this.projectService.delete(project.get().getId()); + this.projectService.delete(id); return new ResponseEntity<>(HttpStatus.NO_CONTENT); } } diff --git a/src/test/java/de/szut/lf8_starter/integration/project/DeleteProjectActionTest.java b/src/test/java/de/szut/lf8_starter/integration/project/DeleteProjectActionTest.java index 070fbe9..6d9ee5b 100644 --- a/src/test/java/de/szut/lf8_starter/integration/project/DeleteProjectActionTest.java +++ b/src/test/java/de/szut/lf8_starter/integration/project/DeleteProjectActionTest.java @@ -26,7 +26,6 @@ public class DeleteProjectActionTest { @Test void deleteProjectTest() throws Exception { var project = new ProjectEntity(); - project.setId(20); project.setComment("comment"); project.setContractor(1); project.setContractorName("contractorName"); @@ -37,7 +36,7 @@ public class DeleteProjectActionTest { project.setEmployees(List.of(1L, 2L, 3L)); this.projectRepository.save(project); - this.mockMvc.perform(delete("/projects/20")) + this.mockMvc.perform(delete("/projects/" + project.getId())) .andExpect(status().isNoContent()); }