refactor: simplify project deletion logic in action class
Some checks failed
Quality Check / Tests (pull_request) Successful in 1m3s
Quality Check / Checkstyle Main (pull_request) Successful in 46s
gitea-sonarqube-bot ERROR
Build PR / Build and analyze (pull_request) Successful in 1m59s

This commit is contained in:
Jan Gleytenhoover 2024-10-02 11:27:25 +02:00
parent 4abce554e5
commit 4c44b843ae
Signed by: jank
GPG Key ID: B267751B8AE29EFE
2 changed files with 2 additions and 4 deletions

@ -33,12 +33,11 @@ public class RemoveProjectAction {
@DeleteMapping("/{id}")
public ResponseEntity<GetProjectDto> findArticleById(@PathVariable Long id) {
Optional<ProjectEntity> 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);
}
}

@ -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());
}