Skip to content

Commit 16d9a1a

Browse files
committed
add tests for PlayerHexadScoreExists
1 parent b536a88 commit 16d9a1a

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/test/java/de/unistuttgart/iste/meitrex/gamification_service/service/PlayerHexadScoreServiceTest.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
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;
24
import static org.mockito.ArgumentMatchers.any;
35
import static org.mockito.Mockito.*;
46
import static org.junit.jupiter.api.Assertions.assertEquals;
57
import static org.junit.jupiter.api.Assertions.assertThrows;
68
import java.util.Optional;
79

10+
import org.junit.jupiter.api.Assertions;
811
import org.junit.jupiter.api.BeforeEach;
912
import org.junit.jupiter.api.Test;
1013
import org.mockito.*;
@@ -68,8 +71,8 @@ void testEvaluateWithEmptyQuestions() {
6871

6972
@Test
7073
public void testEvaluateWithInput(){
71-
// Arrange
72-
PlayerHexadScoreService spyService = spy(playerHexadScoreService);
74+
// Arrange
75+
PlayerHexadScoreService spyService = spy(playerHexadScoreService);
7376

7477

7578
AnswerInput answer1 = new AnswerInput(
@@ -132,4 +135,19 @@ public void testEvaluateHexadScoreAlreadyEvaluated(){
132135
verify(spyService, times(0)).calculateDefault();
133136
verify(spyService, times(0)).calculateFromInput(input);
134137
}
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+
}
135153
}

0 commit comments

Comments
 (0)