Skip to content

Commit

Permalink
Fix some hotspots and code smells
Browse files Browse the repository at this point in the history
  • Loading branch information
Pelayori committed Apr 6, 2024
1 parent f2d5235 commit eedabb3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public MultipleQuestionGenerator(QuestionGenerator... generators) {
this.generators = generators;
}

public List<Question> getQuestions() {
public List<Question> getQuestions() throws InterruptedException {
List<Question> questions = new ArrayList<>();
for (QuestionGenerator generator : generators) {
questions.addAll(generator.getQuestions());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public InsertSampleDataService(PlayerService playerService, QuestionService ques

@Transactional
@EventListener(ApplicationReadyEvent.class) // Uncomment this line to insert sample data on startup
public void insertSampleQuestions() {
public void insertSampleQuestions() throws InterruptedException {
if (!playerService.getUserByEmail("[email protected]").isPresent()) {
PlayerDto player = new PlayerDto();
player.setEmail("[email protected]");
Expand All @@ -68,7 +68,7 @@ public void insertSampleQuestions() {
}

@Transactional
public void generateSampleData() {
public void generateSampleData() throws InterruptedException {

questionRepository.deleteAll();

Expand Down
12 changes: 6 additions & 6 deletions src/test/java/com/uniovi/Wiq_UnitTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void testPlayerService() {
}
@Test
@Order(2)
public void testQuestions(){
public void testQuestions() throws InterruptedException {
sampleDataService.insertSampleQuestions();
sampleDataService.generateSampleData();
List<Question> questions = questionService.getAllQuestions();
Expand All @@ -69,7 +69,7 @@ public void testQuestions(){
}
@Test
@Order(2)
public void testRandomQuestions(){
public void testRandomQuestions() throws InterruptedException {
sampleDataService.insertSampleQuestions();
sampleDataService.generateSampleData();
List<Question> questions = questionService.getRandomQuestions(5);
Expand All @@ -78,7 +78,7 @@ public void testRandomQuestions(){

@Test
@Order(3)
public void testBorderQuestionsGenerator(){
public void testBorderQuestionsGenerator() throws InterruptedException {
BorderQuestionGenerator borderQuestionGenerator=new BorderQuestionGenerator(categoryService,Question.SPANISH);
List<Question> questions = borderQuestionGenerator.getQuestions();
Assertions.assertFalse(questions.isEmpty());
Expand All @@ -92,7 +92,7 @@ public void testBorderQuestionsGenerator(){

@Test
@Order(4)
public void testCapitalQuestionsGenerator(){
public void testCapitalQuestionsGenerator() throws InterruptedException {
CapitalQuestionGenerator capitalQuestionGenerator=new CapitalQuestionGenerator(categoryService,Question.SPANISH);
List<Question> questions = capitalQuestionGenerator.getQuestions();
Assertions.assertFalse(questions.isEmpty());
Expand All @@ -106,7 +106,7 @@ public void testCapitalQuestionsGenerator(){

@Test
@Order(5)
public void testContinentQuestionsGenerator(){
public void testContinentQuestionsGenerator() throws InterruptedException {
ContinentQuestionGeneration continentQuestionGenerator=new ContinentQuestionGeneration(categoryService,Question.SPANISH);
List<Question> questions = continentQuestionGenerator.getQuestions();
Assertions.assertFalse(questions.isEmpty());
Expand Down Expand Up @@ -1199,7 +1199,7 @@ private JSONObject parseJsonResponse(HttpResponse<String> response) throws JSONE
/**
* Inserts some sample questions into the database
*/
private void insertSomeQuestions() {
private void insertSomeQuestions() throws InterruptedException {
List<Question> qs = new ContinentQuestionGeneration(categoryService, Question.SPANISH).getQuestions();
qs.forEach(questionService::addNewQuestion);
}
Expand Down

0 comments on commit eedabb3

Please sign in to comment.