@Test public void testListWorkerShifts() { this.createTwoShiftsAndVerify(); WorkerShiftListRequest workerShiftListRequest = WorkerShiftListRequest.builder() .companyId(company.getId()) .workerId(directoryEntryDto1.getUserId()) .teamId(team.getId()) .shiftStartAfter(Instant.now().minus(1, ChronoUnit.DAYS)) .shiftStartBefore(Instant.now().plus(5, ChronoUnit.DAYS)) .build(); GenericShiftListResponse genericShiftListResponse = companyClient.listWorkerShifts(AuthConstant.AUTHORIZATION_SUPPORT_USER, workerShiftListRequest); log.info(genericShiftListResponse.toString()); assertThat(genericShiftListResponse.isSuccess()).isTrue(); ShiftList shiftList = genericShiftListResponse.getShiftList(); assertThat(shiftList.getShifts()).containsExactly(shiftDto1, shiftDto2); GenericShiftResponse genericShiftResponse = companyClient.getShift(AuthConstant.AUTHORIZATION_SUPPORT_USER, shiftDto1.getId(), team.getId(), company.getId()); assertThat(genericShiftResponse.isSuccess()).isTrue(); assertThat(genericShiftResponse.getShift()).isEqualTo(shiftDto1); genericShiftResponse = companyClient.getShift(AuthConstant.AUTHORIZATION_SUPPORT_USER, shiftDto2.getId(), team.getId(), company.getId()); assertThat(genericShiftResponse.isSuccess()).isTrue(); assertThat(genericShiftResponse.getShift()).isEqualTo(shiftDto2); }
@PostMapping(path = "/list_worker_shifts") @Authorize(value = { AuthConstant.AUTHORIZATION_AUTHENTICATED_USER, AuthConstant.AUTHORIZATION_SUPPORT_USER, AuthConstant.AUTHORIZATION_BOT_SERVICE, AuthConstant.AUTHORIZATION_ICAL_SERVICE }) public GenericShiftListResponse listWorkerShifts(@RequestBody @Validated WorkerShiftListRequest request) { if (AuthConstant.AUTHORIZATION_AUTHENTICATED_USER.equals(AuthContext.getAuthz())) { permissionService.checkPermissionTeamWorker(request.getCompanyId(), request.getTeamId()); } ShiftList shiftList = shiftService.listWorkerShifts(request); return new GenericShiftListResponse(shiftList); }
ShiftController { @PostMapping(path = "/list_worker_shifts") @Authorize(value = { AuthConstant.AUTHORIZATION_AUTHENTICATED_USER, AuthConstant.AUTHORIZATION_SUPPORT_USER, AuthConstant.AUTHORIZATION_BOT_SERVICE, AuthConstant.AUTHORIZATION_ICAL_SERVICE }) public GenericShiftListResponse listWorkerShifts(@RequestBody @Validated WorkerShiftListRequest request) { if (AuthConstant.AUTHORIZATION_AUTHENTICATED_USER.equals(AuthContext.getAuthz())) { permissionService.checkPermissionTeamWorker(request.getCompanyId(), request.getTeamId()); } ShiftList shiftList = shiftService.listWorkerShifts(request); return new GenericShiftListResponse(shiftList); } }
ShiftController { @PostMapping(path = "/list_worker_shifts") @Authorize(value = { AuthConstant.AUTHORIZATION_AUTHENTICATED_USER, AuthConstant.AUTHORIZATION_SUPPORT_USER, AuthConstant.AUTHORIZATION_BOT_SERVICE, AuthConstant.AUTHORIZATION_ICAL_SERVICE }) public GenericShiftListResponse listWorkerShifts(@RequestBody @Validated WorkerShiftListRequest request) { if (AuthConstant.AUTHORIZATION_AUTHENTICATED_USER.equals(AuthContext.getAuthz())) { permissionService.checkPermissionTeamWorker(request.getCompanyId(), request.getTeamId()); } ShiftList shiftList = shiftService.listWorkerShifts(request); return new GenericShiftListResponse(shiftList); }  }
ShiftController { @PostMapping(path = "/list_worker_shifts") @Authorize(value = { AuthConstant.AUTHORIZATION_AUTHENTICATED_USER, AuthConstant.AUTHORIZATION_SUPPORT_USER, AuthConstant.AUTHORIZATION_BOT_SERVICE, AuthConstant.AUTHORIZATION_ICAL_SERVICE }) public GenericShiftListResponse listWorkerShifts(@RequestBody @Validated WorkerShiftListRequest request) { if (AuthConstant.AUTHORIZATION_AUTHENTICATED_USER.equals(AuthContext.getAuthz())) { permissionService.checkPermissionTeamWorker(request.getCompanyId(), request.getTeamId()); } ShiftList shiftList = shiftService.listWorkerShifts(request); return new GenericShiftListResponse(shiftList); }  @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 { @PostMapping(path = "/list_worker_shifts") @Authorize(value = { AuthConstant.AUTHORIZATION_AUTHENTICATED_USER, AuthConstant.AUTHORIZATION_SUPPORT_USER, AuthConstant.AUTHORIZATION_BOT_SERVICE, AuthConstant.AUTHORIZATION_ICAL_SERVICE }) public GenericShiftListResponse listWorkerShifts(@RequestBody @Validated WorkerShiftListRequest request) { if (AuthConstant.AUTHORIZATION_AUTHENTICATED_USER.equals(AuthContext.getAuthz())) { permissionService.checkPermissionTeamWorker(request.getCompanyId(), request.getTeamId()); } ShiftList shiftList = shiftService.listWorkerShifts(request); return new GenericShiftListResponse(shiftList); }  @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);  }