feat(project): Delete project (SCRUM-35) #29
@ -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());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user