From 702f979e99f76a51704ef994dd33ba97d2419d62 Mon Sep 17 00:00:00 2001 From: Dario Date: Wed, 24 Apr 2024 22:45:10 +0200 Subject: [PATCH 1/8] test: coverage completion --- .../statistics/StatisticsServiceTest.java | 290 +++--------------- 1 file changed, 35 insertions(+), 255 deletions(-) diff --git a/api/src/test/java/lab/en2b/quizapi/statistics/StatisticsServiceTest.java b/api/src/test/java/lab/en2b/quizapi/statistics/StatisticsServiceTest.java index 60349876..85061f87 100644 --- a/api/src/test/java/lab/en2b/quizapi/statistics/StatisticsServiceTest.java +++ b/api/src/test/java/lab/en2b/quizapi/statistics/StatisticsServiceTest.java @@ -1,9 +1,11 @@ package lab.en2b.quizapi.statistics; import ch.qos.logback.core.util.TimeUtil; +import jakarta.validation.constraints.AssertFalse; import lab.en2b.quizapi.commons.user.User; import lab.en2b.quizapi.commons.user.dtos.UserResponseDto; import lab.en2b.quizapi.commons.user.UserService; +import lab.en2b.quizapi.commons.user.mappers.UserResponseDtoMapper; import lab.en2b.quizapi.game.GameRepository; import lab.en2b.quizapi.statistics.dtos.StatisticsResponseDto; import lab.en2b.quizapi.statistics.mappers.StatisticsResponseDtoMapper; @@ -21,6 +23,7 @@ import java.util.List; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -40,9 +43,6 @@ public class StatisticsServiceTest { @Mock private Authentication authentication; - @Mock - private StatisticsResponseDtoMapper statisticsResponseDtoMapper; - @Mock private GameRepository gameRepository; @@ -60,7 +60,7 @@ public class StatisticsServiceTest { @BeforeEach public void setUp(){ - this.statisticsService = new StatisticsService(statisticsRepository, userService, statisticsResponseDtoMapper, gameRepository); + this.statisticsService = new StatisticsService(statisticsRepository, userService, new StatisticsResponseDtoMapper(new UserResponseDtoMapper()), gameRepository); this.defaultUser = User.builder() .id(1L) .email("test@email.com") @@ -73,7 +73,7 @@ public void setUp(){ this.defaultUserResponseDto = UserResponseDto.builder() .id(1L) - .email("test") + .email("test@email.com") .username("test") .build(); @@ -121,16 +121,43 @@ public void getStatisticsForUserTest(){ Authentication authentication = mock(Authentication.class); when(userService.getUserByAuthentication(any())).thenReturn(defaultUser); when(statisticsRepository.findByUserId(any())).thenReturn(Optional.of(defaultStatistics1)); - when(statisticsResponseDtoMapper.apply(any())).thenReturn(defaultStatisticsResponseDto1); StatisticsResponseDto result = statisticsService.getStatisticsForUser(authentication); Assertions.assertEquals(defaultStatisticsResponseDto1, result); } + @Test + public void getStatisticsForUserTestEmpty(){ + Authentication authentication = mock(Authentication.class); + when(userService.getUserByAuthentication(any())).thenReturn(defaultUser); + when(statisticsRepository.findByUserId(any())).thenReturn(Optional.empty()); + when(statisticsRepository.save(any())).thenAnswer(invocation -> invocation.getArgument(0)); + StatisticsResponseDto result = statisticsService.getStatisticsForUser(authentication); + Assertions.assertEquals(StatisticsResponseDto.builder() + .id(null) + .right(0L) + .wrong(0L) + .total(0L) + .correctRate(0L) + .finishedGames(0L) + .user(defaultUserResponseDto).build() + , result); + } + + @Test + public void getCorrectRateTotalZero(){ + Statistics statistics = Statistics.builder() + .id(1L) + .user(defaultUser) + .correct(0L) + .wrong(0L) + .total(0L) + .finishedGames(1L) + .build(); + Assertions.assertEquals(0L, statistics.getCorrectRate()); + } @Test public void getTopTenStatisticsTestWhenThereAreNotTen(){ when(statisticsRepository.findAll()).thenReturn(List.of(defaultStatistics2, defaultStatistics1)); - when(statisticsResponseDtoMapper.apply(defaultStatistics1)).thenReturn(defaultStatisticsResponseDto1); - when(statisticsResponseDtoMapper.apply(defaultStatistics2)).thenReturn(defaultStatisticsResponseDto2); List result = statisticsService.getTopTenStatistics(); Assertions.assertEquals(List.of(defaultStatisticsResponseDto2,defaultStatisticsResponseDto1), result); } @@ -155,255 +182,8 @@ public void getTopTenStatisticsTestWhenThereAreNotTenAndAreEqual(){ .finishedGames(1L) .build(); when(statisticsRepository.findAll()).thenReturn(List.of(defaultStatistics1, defaultStatistics3)); - when(statisticsResponseDtoMapper.apply(defaultStatistics1)).thenReturn(defaultStatisticsResponseDto1); - when(statisticsResponseDtoMapper.apply(defaultStatistics3)).thenReturn(defaultStatisticsResponseDto3); List result = statisticsService.getTopTenStatistics(); Assertions.assertEquals(List.of(defaultStatisticsResponseDto1,defaultStatisticsResponseDto3), result); } - @Test - public void getTopTenStatisticsWhenThereAreTen(){ - Statistics defaultStatistics3 = Statistics.builder() - .id(3L) - .user(defaultUser) - .correct(1L) - .wrong(9L) - .total(10L) - .finishedGames(1L) - .build(); - Statistics defaultStatistics4 = Statistics.builder() - .id(4L) - .user(defaultUser) - .correct(2L) - .wrong(8L) - .total(10L) - .finishedGames(1L) - .build(); - Statistics defaultStatistics5 = Statistics.builder() - .id(5L) - .user(defaultUser) - .correct(3L) - .wrong(7L) - .total(10L) - .finishedGames(1L) - .build(); - Statistics defaultStatistics6 = Statistics.builder() - .id(6L) - .user(defaultUser) - .correct(4L) - .wrong(6L) - .total(10L) - .finishedGames(1L) - .build(); - Statistics defaultStatistics7 = Statistics.builder() - .id(7L) - .user(defaultUser) - .correct(6L) - .wrong(4L) - .total(10L) - .finishedGames(1L) - .build(); - Statistics defaultStatistics8 = Statistics.builder() - .id(8L) - .user(defaultUser) - .correct(8L) - .wrong(2L) - .total(10L) - .finishedGames(1L) - .build(); - List statistics = List.of(defaultStatistics8, defaultStatistics2, defaultStatistics7, - defaultStatistics1, defaultStatistics6, defaultStatistics5, defaultStatistics4, defaultStatistics3); - when(statisticsRepository.findAll()).thenReturn(statistics); - when(statisticsResponseDtoMapper.apply(defaultStatistics1)).thenReturn(defaultStatisticsResponseDto1); - when(statisticsResponseDtoMapper.apply(defaultStatistics2)).thenReturn(defaultStatisticsResponseDto2); - when(statisticsResponseDtoMapper.apply(defaultStatistics3)).thenReturn(StatisticsResponseDto.builder() - .id(3L) - .right(1L) - .wrong(9L) - .total(10L) - .correctRate(10L) - .finishedGames(1L) - .user(defaultUserResponseDto) - .build()); - when(statisticsResponseDtoMapper.apply(defaultStatistics4)).thenReturn(StatisticsResponseDto.builder() - .id(4L) - .right(2L) - .wrong(8L) - .total(10L) - .correctRate(20L) - .finishedGames(1L) - .user(defaultUserResponseDto) - .build()); - when(statisticsResponseDtoMapper.apply(defaultStatistics5)).thenReturn(StatisticsResponseDto.builder() - .id(5L) - .right(3L) - .wrong(7L) - .total(10L) - .correctRate(30L) - .finishedGames(1L) - .user(defaultUserResponseDto) - .build()); - when(statisticsResponseDtoMapper.apply(defaultStatistics6)).thenReturn(StatisticsResponseDto.builder() - .id(6L) - .right(4L) - .wrong(6L) - .total(10L) - .correctRate(40L) - .finishedGames(1L) - .user(defaultUserResponseDto) - .build()); - when(statisticsResponseDtoMapper.apply(defaultStatistics7)).thenReturn(StatisticsResponseDto.builder() - .id(7L) - .right(6L) - .wrong(4L) - .total(10L) - .correctRate(60L) - .finishedGames(1L) - .user(defaultUserResponseDto) - .build()); - when(statisticsResponseDtoMapper.apply(defaultStatistics8)).thenReturn(StatisticsResponseDto.builder() - .id(8L) - .right(8L) - .wrong(2L) - .total(10L) - .correctRate(80L) - .finishedGames(1L) - .user(defaultUserResponseDto) - .build()); - List result = statistics.stream().map(statisticsResponseDtoMapper::apply).toList(); - Assertions.assertEquals(statisticsService.getTopTenStatistics(), result); - } - - @Test - public void getTopTenWhenThereAreMoreThanTen(){ - Statistics defaultStatistics3 = Statistics.builder() - .id(3L) - .user(defaultUser) - .correct(1L) - .wrong(9L) - .total(10L) - .finishedGames(1L) - .build(); - Statistics defaultStatistics4 = Statistics.builder() - .id(4L) - .user(defaultUser) - .correct(2L) - .wrong(8L) - .total(10L) - .finishedGames(1L) - .build(); - Statistics defaultStatistics5 = Statistics.builder() - .id(5L) - .user(defaultUser) - .correct(3L) - .wrong(7L) - .total(10L) - .finishedGames(1L) - .build(); - Statistics defaultStatistics6 = Statistics.builder() - .id(6L) - .user(defaultUser) - .correct(4L) - .wrong(6L) - .total(10L) - .finishedGames(1L) - .build(); - Statistics defaultStatistics7 = Statistics.builder() - .id(7L) - .user(defaultUser) - .correct(6L) - .wrong(4L) - .total(10L) - .finishedGames(1L) - .build(); - Statistics defaultStatistics8 = Statistics.builder() - .id(8L) - .user(defaultUser) - .correct(8L) - .wrong(2L) - .total(10L) - .finishedGames(1L) - .build(); - Statistics defaultStatistics9 = Statistics.builder() - .id(9L) - .user(defaultUser) - .correct(9L) - .wrong(1L) - .total(10L) - .finishedGames(1L) - .build(); - List statistics = List.of(defaultStatistics9, defaultStatistics8, defaultStatistics2, - defaultStatistics7, defaultStatistics1, defaultStatistics6, defaultStatistics5, defaultStatistics4, - defaultStatistics3); - when(statisticsRepository.findAll()).thenReturn(statistics); - when(statisticsResponseDtoMapper.apply(defaultStatistics1)).thenReturn(defaultStatisticsResponseDto1); - when(statisticsResponseDtoMapper.apply(defaultStatistics2)).thenReturn(defaultStatisticsResponseDto2); - when(statisticsResponseDtoMapper.apply(defaultStatistics3)).thenReturn(StatisticsResponseDto.builder() - .id(3L) - .right(1L) - .wrong(9L) - .total(10L) - .correctRate(10L) - .finishedGames(1L) - .user(defaultUserResponseDto) - .build()); - when(statisticsResponseDtoMapper.apply(defaultStatistics4)).thenReturn(StatisticsResponseDto.builder() - .id(4L) - .right(2L) - .wrong(8L) - .total(10L) - .correctRate(20L) - .finishedGames(1L) - .user(defaultUserResponseDto) - .build()); - when(statisticsResponseDtoMapper.apply(defaultStatistics5)).thenReturn(StatisticsResponseDto.builder() - .id(5L) - .right(3L) - .wrong(7L) - .total(10L) - .correctRate(30L) - .finishedGames(1L) - .user(defaultUserResponseDto) - .build()); - when(statisticsResponseDtoMapper.apply(defaultStatistics6)).thenReturn(StatisticsResponseDto.builder() - .id(6L) - .right(4L) - .wrong(6L) - .total(10L) - .correctRate(40L) - .finishedGames(1L) - .user(defaultUserResponseDto) - .build()); - when(statisticsResponseDtoMapper.apply(defaultStatistics7)).thenReturn(StatisticsResponseDto.builder() - .id(7L) - .right(6L) - .wrong(4L) - .total(10L) - .correctRate(60L) - .finishedGames(1L) - .user(defaultUserResponseDto) - .build()); - when(statisticsResponseDtoMapper.apply(defaultStatistics8)).thenReturn(StatisticsResponseDto.builder() - .id(8L) - .right(8L) - .wrong(2L) - .total(10L) - .correctRate(80L) - .finishedGames(1L) - .user(defaultUserResponseDto) - .build()); - when(statisticsResponseDtoMapper.apply(defaultStatistics9)).thenReturn(StatisticsResponseDto.builder() - .id(9L) - .right(9L) - .wrong(1L) - .total(10L) - .correctRate(90L) - .finishedGames(1L) - .user(defaultUserResponseDto) - .build()); - List result = statistics.stream().limit(10). - map(statisticsResponseDtoMapper::apply).toList(); - Assertions.assertEquals(statisticsService.getTopTenStatistics(), result); - } - } From 60487cd8351552ac152fe30f396d54e2653fb568 Mon Sep 17 00:00:00 2001 From: Dario Date: Wed, 24 Apr 2024 22:47:45 +0200 Subject: [PATCH 2/8] refactor: renamed var to match standard --- .../quizapi/questions/question/QuestionService.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/api/src/main/java/lab/en2b/quizapi/questions/question/QuestionService.java b/api/src/main/java/lab/en2b/quizapi/questions/question/QuestionService.java index 093a1368..0bd2cf2e 100644 --- a/api/src/main/java/lab/en2b/quizapi/questions/question/QuestionService.java +++ b/api/src/main/java/lab/en2b/quizapi/questions/question/QuestionService.java @@ -84,13 +84,13 @@ public List getQuestionsWithPage(Long page){ private List getPage(List result, Long page) { try{ - int QUESTION_PAGE_SIZE = 100; - int startIndex = Math.toIntExact((page-1)* QUESTION_PAGE_SIZE); + int questionPageSize = 100; + int startIndex = Math.toIntExact((page-1)* questionPageSize); if(startIndex > result.size()) - throw new IllegalArgumentException("Invalid page number, maximum page is "+(result.size()/ QUESTION_PAGE_SIZE +1) + " and you requested page "+page); - if (result.size() < page* QUESTION_PAGE_SIZE) + throw new IllegalArgumentException("Invalid page number, maximum page is "+(result.size()/ questionPageSize +1) + " and you requested page "+page); + if (result.size() < page* questionPageSize) return result.subList(startIndex,result.size()); - return result.subList(startIndex, Math.toIntExact(page* QUESTION_PAGE_SIZE)); + return result.subList(startIndex, Math.toIntExact(page* questionPageSize)); } catch (ArithmeticException e) { throw new IllegalArgumentException("Invalid page number"); } From 411999164e691f02dfd1727a95cf469fc85d031b Mon Sep 17 00:00:00 2001 From: Dario Date: Wed, 24 Apr 2024 22:52:43 +0200 Subject: [PATCH 3/8] test: page size greater than int val --- .../lab/en2b/quizapi/questions/QuestionServiceTest.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/api/src/test/java/lab/en2b/quizapi/questions/QuestionServiceTest.java b/api/src/test/java/lab/en2b/quizapi/questions/QuestionServiceTest.java index a773740c..5d99584f 100644 --- a/api/src/test/java/lab/en2b/quizapi/questions/QuestionServiceTest.java +++ b/api/src/test/java/lab/en2b/quizapi/questions/QuestionServiceTest.java @@ -190,7 +190,6 @@ void getQuestionsWithPageInvalidPage() { @Test void getQuestionsWithPageGreaterThanSize() { when(questionRepository.findAll()).thenReturn(List.of(defaultQuestion)); - assertThrows(IllegalArgumentException.class,() -> questionService.getQuestionsWithPage(2L)); } @@ -200,4 +199,11 @@ void getQuestionsWithPageNoQuestions() { Assertions.assertEquals(questionService.getQuestionsWithPage(1L), List.of()); } + @Test + void getQuestionsWithPageTooBig() { + when(questionRepository.findAll()).thenReturn(List.of(defaultQuestion)); + Assertions.assertThrows(IllegalArgumentException.class, () -> questionService.getQuestionsWithPage(100000000L)); + + } + } From c2f4dae924f58d4aeabc36d134360f38daa2807c Mon Sep 17 00:00:00 2001 From: Dario Date: Wed, 24 Apr 2024 22:53:02 +0200 Subject: [PATCH 4/8] refactor: removed todo, written as technical debt --- .../lab/en2b/quizapi/questions/question/QuestionService.java | 1 - 1 file changed, 1 deletion(-) diff --git a/api/src/main/java/lab/en2b/quizapi/questions/question/QuestionService.java b/api/src/main/java/lab/en2b/quizapi/questions/question/QuestionService.java index 0bd2cf2e..667cfd8a 100644 --- a/api/src/main/java/lab/en2b/quizapi/questions/question/QuestionService.java +++ b/api/src/main/java/lab/en2b/quizapi/questions/question/QuestionService.java @@ -101,7 +101,6 @@ private List getPage(List result, Long * Load the answers for a question (The distractors and the correct one) * @param question The question to load the answers for */ - //TODO: CHAPUZAS, FIXEAR ESTO private void loadAnswers(Question question) { // Create the new answers list with the distractors if(question.getAnswers().size() > 1) { From 2a700fdf1c7b4b245d0ebc7078248e3b5d5b1fd2 Mon Sep 17 00:00:00 2001 From: Diego Villanueva Date: Wed, 24 Apr 2024 23:11:48 +0200 Subject: [PATCH 5/8] Fix: Eliminated unnecessary code --- .../questions/question/QuestionHelper.java | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/api/src/main/java/lab/en2b/quizapi/questions/question/QuestionHelper.java b/api/src/main/java/lab/en2b/quizapi/questions/question/QuestionHelper.java index 2cab945b..595f2529 100644 --- a/api/src/main/java/lab/en2b/quizapi/questions/question/QuestionHelper.java +++ b/api/src/main/java/lab/en2b/quizapi/questions/question/QuestionHelper.java @@ -12,20 +12,9 @@ @Component public class QuestionHelper { - private static int MAX_DISTRACTORS = 3; + private static final int MAX_DISTRACTORS = 3; public static List getDistractors(AnswerRepository answerRepository, Question question){ - List distractors = new ArrayList<>(); - AnswerCategory cat = question.getAnswerCategory(); - - switch (cat){ // Write the case only for the exceptions - case COUNTRY: - // Implement more cases - break; - default: - distractors = answerRepository.findDistractors(question.getAnswerCategory().toString(), question.getLanguage(), question.getCorrectAnswer().getText(), MAX_DISTRACTORS); - } - - return distractors; + return answerRepository.findDistractors(question.getAnswerCategory().toString(), question.getLanguage(), question.getCorrectAnswer().getText(), MAX_DISTRACTORS); } } From 2d222ad173d563ca39e90dd3188a8d2ab8345786 Mon Sep 17 00:00:00 2001 From: Diego Villanueva Date: Wed, 24 Apr 2024 23:16:38 +0200 Subject: [PATCH 6/8] Fix: Hide constructor --- .../lab/en2b/quizapi/questions/question/QuestionHelper.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/api/src/main/java/lab/en2b/quizapi/questions/question/QuestionHelper.java b/api/src/main/java/lab/en2b/quizapi/questions/question/QuestionHelper.java index 595f2529..f5c20c61 100644 --- a/api/src/main/java/lab/en2b/quizapi/questions/question/QuestionHelper.java +++ b/api/src/main/java/lab/en2b/quizapi/questions/question/QuestionHelper.java @@ -12,6 +12,8 @@ @Component public class QuestionHelper { + private QuestionHelper(){} // To hide the implicit public constructor as this is static only + private static final int MAX_DISTRACTORS = 3; public static List getDistractors(AnswerRepository answerRepository, Question question){ From e69b15523c80583bf92e695712b00cb6f1073957 Mon Sep 17 00:00:00 2001 From: Dario Date: Wed, 24 Apr 2024 23:17:23 +0200 Subject: [PATCH 7/8] fix: suppressed sonar warnings and removed imports --- api/src/main/java/lab/en2b/quizapi/game/Game.java | 2 +- .../main/java/lab/en2b/quizapi/questions/answer/Answer.java | 1 + .../java/lab/en2b/quizapi/questions/question/Question.java | 1 + .../lab/en2b/quizapi/statistics/StatisticsServiceTest.java | 5 ----- 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/api/src/main/java/lab/en2b/quizapi/game/Game.java b/api/src/main/java/lab/en2b/quizapi/game/Game.java index a12cb59d..c359fd79 100644 --- a/api/src/main/java/lab/en2b/quizapi/game/Game.java +++ b/api/src/main/java/lab/en2b/quizapi/game/Game.java @@ -15,7 +15,7 @@ import java.util.List; import static lab.en2b.quizapi.game.GameMode.*; - +@SuppressWarnings("java:S1068") @Entity @Table(name = "games") @NoArgsConstructor diff --git a/api/src/main/java/lab/en2b/quizapi/questions/answer/Answer.java b/api/src/main/java/lab/en2b/quizapi/questions/answer/Answer.java index 1c8bd8ad..a9d2b77f 100644 --- a/api/src/main/java/lab/en2b/quizapi/questions/answer/Answer.java +++ b/api/src/main/java/lab/en2b/quizapi/questions/answer/Answer.java @@ -6,6 +6,7 @@ import java.util.List; +@SuppressWarnings("java:S1068") @Entity @Table(name = "answers") @NoArgsConstructor diff --git a/api/src/main/java/lab/en2b/quizapi/questions/question/Question.java b/api/src/main/java/lab/en2b/quizapi/questions/question/Question.java index 17234423..30662f27 100644 --- a/api/src/main/java/lab/en2b/quizapi/questions/question/Question.java +++ b/api/src/main/java/lab/en2b/quizapi/questions/question/Question.java @@ -9,6 +9,7 @@ import java.util.List; +@SuppressWarnings("java:S1068") @Entity @Table(name = "questions") @NoArgsConstructor diff --git a/api/src/test/java/lab/en2b/quizapi/statistics/StatisticsServiceTest.java b/api/src/test/java/lab/en2b/quizapi/statistics/StatisticsServiceTest.java index 85061f87..cdbfdd7d 100644 --- a/api/src/test/java/lab/en2b/quizapi/statistics/StatisticsServiceTest.java +++ b/api/src/test/java/lab/en2b/quizapi/statistics/StatisticsServiceTest.java @@ -1,7 +1,6 @@ package lab.en2b.quizapi.statistics; import ch.qos.logback.core.util.TimeUtil; -import jakarta.validation.constraints.AssertFalse; import lab.en2b.quizapi.commons.user.User; import lab.en2b.quizapi.commons.user.dtos.UserResponseDto; import lab.en2b.quizapi.commons.user.UserService; @@ -23,7 +22,6 @@ import java.util.List; import java.util.Optional; -import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -40,9 +38,6 @@ public class StatisticsServiceTest { @Mock private StatisticsRepository statisticsRepository; - @Mock - private Authentication authentication; - @Mock private GameRepository gameRepository; From afac713fedaf35cec8468f0c7a961921ac566c71 Mon Sep 17 00:00:00 2001 From: Dario Date: Wed, 24 Apr 2024 23:18:47 +0200 Subject: [PATCH 8/8] refactor: unused imports --- api/src/main/java/lab/en2b/quizapi/game/GameController.java | 1 - api/src/main/java/lab/en2b/quizapi/game/GameService.java | 2 -- api/src/main/java/lab/en2b/quizapi/game/dtos/GameAnswerDto.java | 1 - api/src/test/java/lab/en2b/quizapi/auth/AuthControllerTest.java | 1 - api/src/test/java/lab/en2b/quizapi/user/UserServiceTest.java | 1 - 5 files changed, 6 deletions(-) diff --git a/api/src/main/java/lab/en2b/quizapi/game/GameController.java b/api/src/main/java/lab/en2b/quizapi/game/GameController.java index 99c1d872..8b21c4c9 100644 --- a/api/src/main/java/lab/en2b/quizapi/game/GameController.java +++ b/api/src/main/java/lab/en2b/quizapi/game/GameController.java @@ -7,7 +7,6 @@ import io.swagger.v3.oas.annotations.responses.ApiResponses; import jakarta.validation.Valid; import lab.en2b.quizapi.game.dtos.*; -import lab.en2b.quizapi.questions.question.QuestionCategory; import lab.en2b.quizapi.questions.question.dtos.QuestionCategoryDto; import lab.en2b.quizapi.questions.question.dtos.QuestionResponseDto; import lombok.RequiredArgsConstructor; diff --git a/api/src/main/java/lab/en2b/quizapi/game/GameService.java b/api/src/main/java/lab/en2b/quizapi/game/GameService.java index 36b9d8a1..d78db2f4 100644 --- a/api/src/main/java/lab/en2b/quizapi/game/GameService.java +++ b/api/src/main/java/lab/en2b/quizapi/game/GameService.java @@ -4,7 +4,6 @@ import lab.en2b.quizapi.commons.utils.GameModeUtils; import lab.en2b.quizapi.game.dtos.*; import lab.en2b.quizapi.game.mappers.GameResponseDtoMapper; -import lab.en2b.quizapi.questions.question.QuestionCategory; import lab.en2b.quizapi.questions.question.QuestionService; import lab.en2b.quizapi.questions.question.dtos.QuestionCategoryDto; import lab.en2b.quizapi.questions.question.dtos.QuestionResponseDto; @@ -16,7 +15,6 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.Arrays; import java.util.List; import java.util.Optional; diff --git a/api/src/main/java/lab/en2b/quizapi/game/dtos/GameAnswerDto.java b/api/src/main/java/lab/en2b/quizapi/game/dtos/GameAnswerDto.java index 54cc8634..80c60996 100644 --- a/api/src/main/java/lab/en2b/quizapi/game/dtos/GameAnswerDto.java +++ b/api/src/main/java/lab/en2b/quizapi/game/dtos/GameAnswerDto.java @@ -1,7 +1,6 @@ package lab.en2b.quizapi.game.dtos; import com.fasterxml.jackson.annotation.JsonProperty; -import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.PositiveOrZero; import lombok.*; diff --git a/api/src/test/java/lab/en2b/quizapi/auth/AuthControllerTest.java b/api/src/test/java/lab/en2b/quizapi/auth/AuthControllerTest.java index 1871688f..bd336638 100644 --- a/api/src/test/java/lab/en2b/quizapi/auth/AuthControllerTest.java +++ b/api/src/test/java/lab/en2b/quizapi/auth/AuthControllerTest.java @@ -18,7 +18,6 @@ import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.ResultMatcher; -import java.util.Arrays; import java.util.List; import static lab.en2b.quizapi.commons.utils.TestUtils.asJsonString; diff --git a/api/src/test/java/lab/en2b/quizapi/user/UserServiceTest.java b/api/src/test/java/lab/en2b/quizapi/user/UserServiceTest.java index ed698280..79e76a43 100644 --- a/api/src/test/java/lab/en2b/quizapi/user/UserServiceTest.java +++ b/api/src/test/java/lab/en2b/quizapi/user/UserServiceTest.java @@ -13,7 +13,6 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.core.Authentication; import org.springframework.test.context.junit.jupiter.SpringExtension;