feat(project): Delete project (SCRUM-35) #29

Merged
jank merged 8 commits from feature/remove-project into main 2024-10-02 09:43:10 +00:00
2 changed files with 2 additions and 4 deletions
Showing only changes of commit 4c44b843ae - Show all commits

@ -33,12 +33,11 @@ public class RemoveProjectAction {
@DeleteMapping("/{id}") @DeleteMapping("/{id}")
public ResponseEntity<GetProjectDto> findArticleById(@PathVariable Long id) { public ResponseEntity<GetProjectDto> findArticleById(@PathVariable Long id) {
Optional<ProjectEntity> project = this.projectService.findById(id); Optional<ProjectEntity> project = this.projectService.findById(id);
if (project.isEmpty()) { if (project.isEmpty()) {
return new ResponseEntity<>(HttpStatus.NOT_FOUND); return new ResponseEntity<>(HttpStatus.NOT_FOUND);
} }
this.projectService.delete(project.get().getId()); this.projectService.delete(id);
return new ResponseEntity<>(HttpStatus.NO_CONTENT); return new ResponseEntity<>(HttpStatus.NO_CONTENT);
} }
} }

@ -26,7 +26,6 @@ public class DeleteProjectActionTest {
@Test @Test
void deleteProjectTest() throws Exception { void deleteProjectTest() throws Exception {
var project = new ProjectEntity(); var project = new ProjectEntity();
project.setId(20);
project.setComment("comment"); project.setComment("comment");
project.setContractor(1); project.setContractor(1);
project.setContractorName("contractorName"); project.setContractorName("contractorName");
@ -37,7 +36,7 @@ public class DeleteProjectActionTest {
project.setEmployees(List.of(1L, 2L, 3L)); project.setEmployees(List.of(1L, 2L, 3L));
this.projectRepository.save(project); this.projectRepository.save(project);
this.mockMvc.perform(delete("/projects/20")) this.mockMvc.perform(delete("/projects/" + project.getId()))
.andExpect(status().isNoContent()); .andExpect(status().isNoContent());
} }