@Test public void deleteShift() { this.createTwoShiftsAndVerify(); when(botClient.alertRemovedShift(any(AlertRemovedShiftRequest.class))) .thenReturn(BaseResponse.builder().message("Removed Shift Alerted").build()); BaseResponse baseResponse = companyClient.deleteShift(AuthConstant.AUTHORIZATION_SUPPORT_USER, shiftDto1.getId(), shiftDto1.getTeamId(), shiftDto1.getCompanyId()); assertThat(baseResponse.isSuccess()).isTrue(); ArgumentCaptor<AlertRemovedShiftRequest> argument1 = ArgumentCaptor.forClass(AlertRemovedShiftRequest.class); verify(botClient, times(1)).alertRemovedShift(argument1.capture()); AlertRemovedShiftRequest alertRemovedShiftRequest = argument1.getValue(); assertThat(alertRemovedShiftRequest.getUserId()).isEqualTo(directoryEntryDto1.getUserId()); assertThat(alertRemovedShiftRequest.getOldShift()).isEqualTo(shiftDto1); GenericShiftResponse genericShiftResponse = companyClient.getShift(AuthConstant.AUTHORIZATION_SUPPORT_USER, shiftDto1.getId(), team.getId(), company.getId()); assertThat(genericShiftResponse.isSuccess()).isFalse(); assertThat(genericShiftResponse.getCode()).isEqualTo(ResultCode.NOT_FOUND); ShiftListRequest shiftListRequest1 = ShiftListRequest.builder() .userId(directoryEntryDto1.getUserId()) .companyId(company.getId()) .teamId(team.getId()) .shiftStartAfter(Instant.now().minus(1, ChronoUnit.DAYS)) .shiftStartBefore(Instant.now().plus(5, ChronoUnit.DAYS)) .build(); GenericShiftListResponse shiftListResponse = companyClient.listShifts(AuthConstant.AUTHORIZATION_SUPPORT_USER, shiftListRequest1); log.info(shiftListResponse.toString()); assertThat(shiftListResponse.isSuccess()).isTrue(); ShiftList shiftList = shiftListResponse.getShiftList(); assertThat(shiftList.getShifts()).containsExactly(shiftDto2); }
@DeleteMapping(path = "/delete") @Authorize(value = { AuthConstant.AUTHORIZATION_AUTHENTICATED_USER, AuthConstant.AUTHORIZATION_SUPPORT_USER }) public BaseResponse deleteShift(@RequestParam String shiftId, @RequestParam String teamId, @RequestParam String companyId) { if (AuthConstant.AUTHORIZATION_AUTHENTICATED_USER.equals(AuthContext.getAuthz())) { permissionService.checkPermissionTeamWorker(companyId, teamId); } shiftService.deleteShift(shiftId, teamId, companyId); return BaseResponse.builder().message("shift deleted").build(); }
ShiftController { @DeleteMapping(path = "/delete") @Authorize(value = { AuthConstant.AUTHORIZATION_AUTHENTICATED_USER, AuthConstant.AUTHORIZATION_SUPPORT_USER }) public BaseResponse deleteShift(@RequestParam String shiftId, @RequestParam String teamId, @RequestParam String companyId) { if (AuthConstant.AUTHORIZATION_AUTHENTICATED_USER.equals(AuthContext.getAuthz())) { permissionService.checkPermissionTeamWorker(companyId, teamId); } shiftService.deleteShift(shiftId, teamId, companyId); return BaseResponse.builder().message("shift deleted").build(); } }
ShiftController { @DeleteMapping(path = "/delete") @Authorize(value = { AuthConstant.AUTHORIZATION_AUTHENTICATED_USER, AuthConstant.AUTHORIZATION_SUPPORT_USER }) public BaseResponse deleteShift(@RequestParam String shiftId, @RequestParam String teamId, @RequestParam String companyId) { if (AuthConstant.AUTHORIZATION_AUTHENTICATED_USER.equals(AuthContext.getAuthz())) { permissionService.checkPermissionTeamWorker(companyId, teamId); } shiftService.deleteShift(shiftId, teamId, companyId); return BaseResponse.builder().message("shift deleted").build(); }  }
ShiftController { @DeleteMapping(path = "/delete") @Authorize(value = { AuthConstant.AUTHORIZATION_AUTHENTICATED_USER, AuthConstant.AUTHORIZATION_SUPPORT_USER }) public BaseResponse deleteShift(@RequestParam String shiftId, @RequestParam String teamId, @RequestParam String companyId) { if (AuthConstant.AUTHORIZATION_AUTHENTICATED_USER.equals(AuthContext.getAuthz())) { permissionService.checkPermissionTeamWorker(companyId, teamId); } shiftService.deleteShift(shiftId, teamId, companyId); return BaseResponse.builder().message("shift deleted").build(); }  @PostMapping(path = "/create") @Authorize(value = { AuthConstant.AUTHORIZATION_AUTHENTICATED_USER, AuthConstant.AUTHORIZATION_SUPPORT_USER }) GenericShiftResponse createShift(@RequestBody @Validated CreateShiftRequest request); @PostMapping(path = "/list_worker_shifts") @Authorize(value = { AuthConstant.AUTHORIZATION_AUTHENTICATED_USER, AuthConstant.AUTHORIZATION_SUPPORT_USER, AuthConstant.AUTHORIZATION_BOT_SERVICE, AuthConstant.AUTHORIZATION_ICAL_SERVICE }) GenericShiftListResponse listWorkerShifts(@RequestBody @Validated WorkerShiftListRequest request); @PostMapping(path = "/list_shifts") @Authorize(value = { AuthConstant.AUTHORIZATION_AUTHENTICATED_USER, AuthConstant.AUTHORIZATION_SUPPORT_USER }) GenericShiftListResponse listShifts(@RequestBody @Validated ShiftListRequest request); @PostMapping(path = "/bulk_publish") @Authorize(value = { AuthConstant.AUTHORIZATION_AUTHENTICATED_USER, AuthConstant.AUTHORIZATION_SUPPORT_USER }) GenericShiftListResponse bulkPublishShifts(@RequestBody @Validated BulkPublishShiftsRequest request); @GetMapping(path = "/get") @Authorize(value = { AuthConstant.AUTHORIZATION_AUTHENTICATED_USER, AuthConstant.AUTHORIZATION_SUPPORT_USER }) GenericShiftResponse getShift(@RequestParam String shiftId, @RequestParam String teamId, @RequestParam  String companyId); @PutMapping(path = "/update") @Authorize(value = { AuthConstant.AUTHORIZATION_AUTHENTICATED_USER, AuthConstant.AUTHORIZATION_SUPPORT_USER }) GenericShiftResponse updateShift(@RequestBody @Validated ShiftDto shiftDto); @DeleteMapping(path = "/delete") @Authorize(value = { AuthConstant.AUTHORIZATION_AUTHENTICATED_USER, AuthConstant.AUTHORIZATION_SUPPORT_USER }) BaseResponse deleteShift(@RequestParam String shiftId, @RequestParam String teamId, @RequestParam String companyId); }
ShiftController { @DeleteMapping(path = "/delete") @Authorize(value = { AuthConstant.AUTHORIZATION_AUTHENTICATED_USER, AuthConstant.AUTHORIZATION_SUPPORT_USER }) public BaseResponse deleteShift(@RequestParam String shiftId, @RequestParam String teamId, @RequestParam String companyId) { if (AuthConstant.AUTHORIZATION_AUTHENTICATED_USER.equals(AuthContext.getAuthz())) { permissionService.checkPermissionTeamWorker(companyId, teamId); } shiftService.deleteShift(shiftId, teamId, companyId); return BaseResponse.builder().message("shift deleted").build(); }  @PostMapping(path = "/create") @Authorize(value = { AuthConstant.AUTHORIZATION_AUTHENTICATED_USER, AuthConstant.AUTHORIZATION_SUPPORT_USER }) GenericShiftResponse createShift(@RequestBody @Validated CreateShiftRequest request); @PostMapping(path = "/list_worker_shifts") @Authorize(value = { AuthConstant.AUTHORIZATION_AUTHENTICATED_USER, AuthConstant.AUTHORIZATION_SUPPORT_USER, AuthConstant.AUTHORIZATION_BOT_SERVICE, AuthConstant.AUTHORIZATION_ICAL_SERVICE }) GenericShiftListResponse listWorkerShifts(@RequestBody @Validated WorkerShiftListRequest request); @PostMapping(path = "/list_shifts") @Authorize(value = { AuthConstant.AUTHORIZATION_AUTHENTICATED_USER, AuthConstant.AUTHORIZATION_SUPPORT_USER }) GenericShiftListResponse listShifts(@RequestBody @Validated ShiftListRequest request); @PostMapping(path = "/bulk_publish") @Authorize(value = { AuthConstant.AUTHORIZATION_AUTHENTICATED_USER, AuthConstant.AUTHORIZATION_SUPPORT_USER }) GenericShiftListResponse bulkPublishShifts(@RequestBody @Validated BulkPublishShiftsRequest request); @GetMapping(path = "/get") @Authorize(value = { AuthConstant.AUTHORIZATION_AUTHENTICATED_USER, AuthConstant.AUTHORIZATION_SUPPORT_USER }) GenericShiftResponse getShift(@RequestParam String shiftId, @RequestParam String teamId, @RequestParam  String companyId); @PutMapping(path = "/update") @Authorize(value = { AuthConstant.AUTHORIZATION_AUTHENTICATED_USER, AuthConstant.AUTHORIZATION_SUPPORT_USER }) GenericShiftResponse updateShift(@RequestBody @Validated ShiftDto shiftDto); @DeleteMapping(path = "/delete") @Authorize(value = { AuthConstant.AUTHORIZATION_AUTHENTICATED_USER, AuthConstant.AUTHORIZATION_SUPPORT_USER }) BaseResponse deleteShift(@RequestParam String shiftId, @RequestParam String teamId, @RequestParam String companyId);  }