@Test public void testListShifts() { this.createTwoShiftsAndVerify(); 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(shiftDto1, shiftDto2); ShiftListRequest shiftListRequest2 = ShiftListRequest.builder() .jobId(job.getId()) .companyId(company.getId()) .teamId(team.getId()) .shiftStartAfter(Instant.now().minus(1, ChronoUnit.DAYS)) .shiftStartBefore(Instant.now().plus(5, ChronoUnit.DAYS)) .build(); shiftListResponse = companyClient.listShifts(AuthConstant.AUTHORIZATION_SUPPORT_USER, shiftListRequest2); log.info(shiftListResponse.toString()); assertThat(shiftListResponse.isSuccess()).isTrue(); shiftList = shiftListResponse.getShiftList(); assertThat(shiftList.getShifts()).containsExactly(shiftDto1, shiftDto2); ShiftListRequest shiftListRequest3 = ShiftListRequest.builder() .jobId(job.getId()) .userId(directoryEntryDto1.getUserId()) .companyId(company.getId()) .teamId(team.getId()) .shiftStartAfter(Instant.now().minus(1, ChronoUnit.DAYS)) .shiftStartBefore(Instant.now().plus(5, ChronoUnit.DAYS)) .build(); shiftListResponse = companyClient.listShifts(AuthConstant.AUTHORIZATION_SUPPORT_USER, shiftListRequest3); log.info(shiftListResponse.toString()); assertThat(shiftListResponse.isSuccess()).isTrue(); shiftList = shiftListResponse.getShiftList(); assertThat(shiftList.getShifts()).containsExactly(shiftDto1, shiftDto2); ShiftListRequest shiftListRequest4 = ShiftListRequest.builder() .companyId(company.getId()) .teamId(team.getId()) .shiftStartAfter(Instant.now().minus(1, ChronoUnit.DAYS)) .shiftStartBefore(Instant.now().plus(5, ChronoUnit.DAYS)) .build(); shiftListResponse = companyClient.listShifts(AuthConstant.AUTHORIZATION_SUPPORT_USER, shiftListRequest4); log.info(shiftListResponse.toString()); assertThat(shiftListResponse.isSuccess()).isTrue(); shiftList = shiftListResponse.getShiftList(); assertThat(shiftList.getShifts()).containsExactly(shiftDto1, shiftDto2); }
@PostMapping(path = "/list_shifts") @Authorize(value = { AuthConstant.AUTHORIZATION_AUTHENTICATED_USER, AuthConstant.AUTHORIZATION_SUPPORT_USER }) public GenericShiftListResponse listShifts(@RequestBody @Validated ShiftListRequest request) { if (AuthConstant.AUTHORIZATION_AUTHENTICATED_USER.equals(AuthContext.getAuthz())) { permissionService.checkPermissionTeamWorker(request.getCompanyId(), request.getTeamId()); } ShiftList shiftList = shiftService.listShifts(request); return new GenericShiftListResponse(shiftList); }
ShiftController { @PostMapping(path = "/list_shifts") @Authorize(value = { AuthConstant.AUTHORIZATION_AUTHENTICATED_USER, AuthConstant.AUTHORIZATION_SUPPORT_USER }) public GenericShiftListResponse listShifts(@RequestBody @Validated ShiftListRequest request) { if (AuthConstant.AUTHORIZATION_AUTHENTICATED_USER.equals(AuthContext.getAuthz())) { permissionService.checkPermissionTeamWorker(request.getCompanyId(), request.getTeamId()); } ShiftList shiftList = shiftService.listShifts(request); return new GenericShiftListResponse(shiftList); } }
ShiftController { @PostMapping(path = "/list_shifts") @Authorize(value = { AuthConstant.AUTHORIZATION_AUTHENTICATED_USER, AuthConstant.AUTHORIZATION_SUPPORT_USER }) public GenericShiftListResponse listShifts(@RequestBody @Validated ShiftListRequest request) { if (AuthConstant.AUTHORIZATION_AUTHENTICATED_USER.equals(AuthContext.getAuthz())) { permissionService.checkPermissionTeamWorker(request.getCompanyId(), request.getTeamId()); } ShiftList shiftList = shiftService.listShifts(request); return new GenericShiftListResponse(shiftList); }  }
ShiftController { @PostMapping(path = "/list_shifts") @Authorize(value = { AuthConstant.AUTHORIZATION_AUTHENTICATED_USER, AuthConstant.AUTHORIZATION_SUPPORT_USER }) public GenericShiftListResponse listShifts(@RequestBody @Validated ShiftListRequest request) { if (AuthConstant.AUTHORIZATION_AUTHENTICATED_USER.equals(AuthContext.getAuthz())) { permissionService.checkPermissionTeamWorker(request.getCompanyId(), request.getTeamId()); } ShiftList shiftList = shiftService.listShifts(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_shifts") @Authorize(value = { AuthConstant.AUTHORIZATION_AUTHENTICATED_USER, AuthConstant.AUTHORIZATION_SUPPORT_USER }) public GenericShiftListResponse listShifts(@RequestBody @Validated ShiftListRequest request) { if (AuthConstant.AUTHORIZATION_AUTHENTICATED_USER.equals(AuthContext.getAuthz())) { permissionService.checkPermissionTeamWorker(request.getCompanyId(), request.getTeamId()); } ShiftList shiftList = shiftService.listShifts(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);  }