diff --git a/backend/src/test/java/cz/scrumdojo/quizmaster/quiz/QuizControllerTest.java b/backend/src/test/java/cz/scrumdojo/quizmaster/quiz/QuizControllerTest.java index 8153141..d09f319 100644 --- a/backend/src/test/java/cz/scrumdojo/quizmaster/quiz/QuizControllerTest.java +++ b/backend/src/test/java/cz/scrumdojo/quizmaster/quiz/QuizControllerTest.java @@ -47,6 +47,15 @@ public void shouldThrowExceptionWhenNoQuizFound() { @Test public void returnAllQuizes() { + createQuiz(); + + ResponseEntity> response = quizController.getAllQuizes(); + + assertEquals(HttpStatus.OK, response.getStatusCode()); + assertNotNull(response.getBody()); + } + + private void createQuiz() { int questionId[] = {0, 1, 2, 3}; QuizCreateData quizData = new QuizCreateData("TestName", questionId); Quiz quiz = Quiz.builder() @@ -55,11 +64,6 @@ public void returnAllQuizes() { .build(); quizRepository.save(quiz).getId(); - - ResponseEntity> response = quizController.getAllQuizes(); - - assertEquals(HttpStatus.OK, response.getStatusCode()); - assertNotNull(response.getBody()); } @Test @@ -72,6 +76,8 @@ public void shouldThrowExceptionWhenNoQuizForRunFound() { @Test public void runQuizCreated() { + createQuiz(); + ResponseEntity response = quizController.runQuiz(1); assertEquals(HttpStatus.OK, response.getStatusCode());