From e278c17e27f8fb66595cacbd6290e04babc35c3d Mon Sep 17 00:00:00 2001 From: Diego Villanueva Date: Wed, 24 Apr 2024 23:03:11 +0200 Subject: [PATCH] Test: Added coverage for 4 lines because I want the 80% --- .../en2b/quizapi/game/GameServiceTest.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/api/src/test/java/lab/en2b/quizapi/game/GameServiceTest.java b/api/src/test/java/lab/en2b/quizapi/game/GameServiceTest.java index ef3d483a..cc5b5e57 100644 --- a/api/src/test/java/lab/en2b/quizapi/game/GameServiceTest.java +++ b/api/src/test/java/lab/en2b/quizapi/game/GameServiceTest.java @@ -476,4 +476,24 @@ public void testGetGameModes(){ assertFalse(gameService.getQuestionGameModes().isEmpty()); } + @Test + public void testGameSetQuestionCategoriesInvalidGameMode(){ + Game g = new Game(); + g.setGameMode(GameMode.KIWI_QUEST); + assertThrows(IllegalStateException.class, () -> g.setQuestionCategoriesForCustom(List.of(QuestionCategory.GEOGRAPHY))); + } + @Test + public void testGameSetQuestionCategoriesInvalidNullCategories(){ + Game g = new Game(); + g.setGameMode(GameMode.CUSTOM); + assertThrows(IllegalArgumentException.class, () -> g.setQuestionCategoriesForCustom(null)); + } + @Test + public void testGameSetQuestionCategoriesInvalidEmptyCategories(){ + Game g = new Game(); + g.setGameMode(null); + g.setGameMode(GameMode.CUSTOM); + List qc = new ArrayList<>(); + assertThrows(IllegalArgumentException.class, () -> g.setQuestionCategoriesForCustom(qc)); + } }