From 587bf152d498406f060e7ae5f8327683ac9b6235 Mon Sep 17 00:00:00 2001 From: Yanick Minder Date: Thu, 23 Jan 2025 15:35:54 +0100 Subject: [PATCH] finish IT for unit controller --- .../main/java/ch/puzzle/okr/controller/UnitController.java | 4 ++-- .../okr/service/authorization/UnitAuthorizationService.java | 3 +-- .../java/ch/puzzle/okr/controller/UnitControllerITIT.java | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/backend/src/main/java/ch/puzzle/okr/controller/UnitController.java b/backend/src/main/java/ch/puzzle/okr/controller/UnitController.java index 15293410a3..634d1b72b3 100644 --- a/backend/src/main/java/ch/puzzle/okr/controller/UnitController.java +++ b/backend/src/main/java/ch/puzzle/okr/controller/UnitController.java @@ -73,7 +73,7 @@ public UnitDto updateUnit(@Parameter(description = "The ID for updating a Team." @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Deleted Action by Id"), @ApiResponse(responseCode = "404", description = "Did not find the Action with requested id") }) @DeleteMapping("/{unitId}") - public Unit deleteUnitById(@PathVariable long unitId) { - return unitAuthorizationService.deleteUnitById(unitId); + public void deleteUnitById(@PathVariable long unitId) { + unitAuthorizationService.deleteUnitById(unitId); } } diff --git a/backend/src/main/java/ch/puzzle/okr/service/authorization/UnitAuthorizationService.java b/backend/src/main/java/ch/puzzle/okr/service/authorization/UnitAuthorizationService.java index e30fe6ee7d..d8613fa54f 100644 --- a/backend/src/main/java/ch/puzzle/okr/service/authorization/UnitAuthorizationService.java +++ b/backend/src/main/java/ch/puzzle/okr/service/authorization/UnitAuthorizationService.java @@ -40,12 +40,11 @@ public Unit updateUnit(Long unitId, Unit unit) { return unitBusinessService.updateEntity(unitId, unit); } - public Unit deleteUnitById(Long unitId) { + public void deleteUnitById(Long unitId) { AuthorizationUser authorizationUser = authorizationService.updateOrAddAuthorizationUser(); Unit unit = unitBusinessService.getEntityById(unitId); validateOwner(unit, authorizationUser); unitBusinessService.deleteEntityById(unitId); - return unit; } private void validateOwner(Unit unit, AuthorizationUser authorizationUser) { diff --git a/backend/src/test/java/ch/puzzle/okr/controller/UnitControllerITIT.java b/backend/src/test/java/ch/puzzle/okr/controller/UnitControllerITIT.java index c27a8060ad..d12976e9ab 100644 --- a/backend/src/test/java/ch/puzzle/okr/controller/UnitControllerITIT.java +++ b/backend/src/test/java/ch/puzzle/okr/controller/UnitControllerITIT.java @@ -145,7 +145,7 @@ void shouldReturn403ForWrongUserWhenUpdatingUnit() throws Exception { @Test void shouldReturn403ForWrongUserWhenDeletingUnit() throws Exception { - when(unitAuthorizationService.deleteUnitById(any())).thenThrow(new ResponseStatusException(HttpStatus.FORBIDDEN)); + doThrow(new ResponseStatusException(HttpStatus.FORBIDDEN)).when(unitAuthorizationService).deleteUnitById(101L); mvc .perform(delete(URL_BASE + "/101") .with(SecurityMockMvcRequestPostProcessors.csrf())