Skip to content

Commit

Permalink
#13 Tests de controlador de preguntas, bug arreglado
Browse files Browse the repository at this point in the history
  • Loading branch information
AlvaroGlezC committed Apr 26, 2024
1 parent 571eca2 commit 29141c5
Show file tree
Hide file tree
Showing 94 changed files with 5 additions and 3,145 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ public class QuestionsController {
private QuestionService questionService;

@GetMapping
public ResponseEntity<Object> findAll() {
public ResponseEntity<Object> findAll(@RequestParam(name = "maxNumberOfQuestions", defaultValue = "15", required = false) int maxNumberOfQuestions) {
List<Question> questions = questionService.findAll();
if(questions.size() <= 0) {
return ResponseEntity.status(HttpStatus.OK).body(questions);
}
Collections.shuffle(questions);
return ResponseEntity.status(HttpStatus.OK).body(questions.subList(0, Math.min(questions.size(), 15)));
return ResponseEntity.status(HttpStatus.OK).body(questions.subList(0, Math.min(questions.size(), maxNumberOfQuestions)));
}

@GetMapping("/id")
Expand All @@ -44,12 +44,13 @@ public ResponseEntity<Object> findById(@RequestParam(name = "id") Long id) {
}
}
@GetMapping("/category")
public ResponseEntity<Object> findByCategory(@RequestParam(name = "categoryId") Long categoryId) {
public ResponseEntity<Object> findByCategory(@RequestParam(name = "categoryId") Long categoryId,
@RequestParam(name = "maxNumberOfQuestions", defaultValue = "15", required = false) int maxNumberOfQuestions) {
List<Question> questions = questionService.findByCategory(categoryId);
if(questions.size() <= 0) {
return ResponseEntity.status(HttpStatus.OK).body(questions);
}
Collections.shuffle(questions);
return ResponseEntity.status(HttpStatus.OK).body(questions.subList(0, Math.min(questions.size(), 15)));
return ResponseEntity.status(HttpStatus.OK).body(questions.subList(0, Math.min(questions.size(), maxNumberOfQuestions)));
}
}
1 change: 0 additions & 1 deletion syg-backend/coverage/SYG-domain/index.html

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 29141c5

Please sign in to comment.