|
1 | 1 | package de.unistuttgart.iste.meitrex.gamification_service.service; |
| 2 | +import static org.junit.jupiter.api.Assertions.assertFalse; |
| 3 | +import static org.junit.jupiter.api.Assertions.assertTrue; |
2 | 4 | import static org.mockito.ArgumentMatchers.any; |
3 | 5 | import static org.mockito.Mockito.*; |
4 | 6 | import static org.junit.jupiter.api.Assertions.assertEquals; |
5 | 7 | import static org.junit.jupiter.api.Assertions.assertThrows; |
6 | 8 | import java.util.Optional; |
7 | 9 |
|
| 10 | +import org.junit.jupiter.api.Assertions; |
8 | 11 | import org.junit.jupiter.api.BeforeEach; |
9 | 12 | import org.junit.jupiter.api.Test; |
10 | 13 | import org.mockito.*; |
@@ -68,8 +71,8 @@ void testEvaluateWithEmptyQuestions() { |
68 | 71 |
|
69 | 72 | @Test |
70 | 73 | public void testEvaluateWithInput(){ |
71 | | - // Arrange |
72 | | - PlayerHexadScoreService spyService = spy(playerHexadScoreService); |
| 74 | + // Arrange |
| 75 | + PlayerHexadScoreService spyService = spy(playerHexadScoreService); |
73 | 76 |
|
74 | 77 |
|
75 | 78 | AnswerInput answer1 = new AnswerInput( |
@@ -132,4 +135,19 @@ public void testEvaluateHexadScoreAlreadyEvaluated(){ |
132 | 135 | verify(spyService, times(0)).calculateDefault(); |
133 | 136 | verify(spyService, times(0)).calculateFromInput(input); |
134 | 137 | } |
| 138 | + |
| 139 | + @Test |
| 140 | + public void testPlayerHexadScoreNotExists() { |
| 141 | + PlayerHexadScoreService spyService = spy(playerHexadScoreService); |
| 142 | + assertFalse(spyService.hasHexadScore(UUID.randomUUID())); |
| 143 | + } |
| 144 | + |
| 145 | + @Test |
| 146 | + public void testPlayerHexadScoreExists() { |
| 147 | + PlayerHexadScoreService spyService = spy(playerHexadScoreService); |
| 148 | + Optional<PlayerHexadScoreEntity> existingScore = Optional.of(new PlayerHexadScoreEntity()); |
| 149 | + when(playerHexadScoreRepository.findByUserId(any(UUID.class))) |
| 150 | + .thenReturn(existingScore); |
| 151 | + assertTrue(spyService.hasHexadScore(UUID.randomUUID())); |
| 152 | + } |
135 | 153 | } |
0 commit comments