New endpints tests

This commit is contained in:
Filip Izydorczyk
2020-12-10 16:50:47 +01:00
parent 831358128e
commit a6acab932c
3 changed files with 59 additions and 1 deletions

View File

@ -40,7 +40,7 @@ public class AssignmentsController extends TokenBasedController {
private AssignmentService assignmentService;
@GetMapping("/user")
@ApiOperation(value = "Return user current assignemts (from newest commision). STUDENT Token needs to be provided.")
@ApiOperation(value = "Return user current assignemts (from newest commision). STUDENT Token needs to be provided. This method is depreaceted. Use `/api/v1/commisions/user/schedule` instead.")
@Deprecated
public ResponseEntity<List<AssignmentResponse>> getCurrentAssignments() throws Exception {
User user = this.getCurrentUser().orElseThrow(() -> new NullPointerException("User not found"));

View File

@ -158,6 +158,11 @@ public class CommisionController extends TokenBasedController {
public ResponseEntity<List<AssignmentResponse>> getCurrentAssignmentsDeanery(
@PathVariable(name = "id") Long userId) throws Exception {
User user = this.userService.getById(userId).orElseThrow(() -> new NullPointerException());
if (user.getRole() == UserRoles.DEANERY) {
return new ResponseEntity<>(null, HttpStatus.BAD_REQUEST);
}
Optional<Commision> com = this.commisionService.getNewestCommision(user);
if (com.isPresent()) {