fix(test): mock IoGrpcClientWrapper in GameCreationServiceTest, disable stream listener in core tests
Build & Test (NowChessSystems) TeamCity build finished
Build & Test (NowChessSystems) TeamCity build finished
GameCreationServiceTest called createGame which routes through RedisGameRegistry.store → IoGrpcClientWrapper.exportCombined, hitting a real gRPC stub that fails with UNIMPLEMENTED in tests. MockRedisDataSourceProducer's RETURNS_DEEP_STUBS mock caused a classloader mismatch when GameCreationStreamListener called .stream() on it (PubSubCommands mock returned instead of StreamCommands). - Add @InjectMock IoGrpcClientWrapper + @BeforeEach stub in GameCreationServiceTest - Add nowchess.game-creation-stream.enabled: false to core test application.yml Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -18,6 +18,8 @@ nowchess:
|
||||
enabled: false
|
||||
coordinator:
|
||||
enabled: false
|
||||
game-creation-stream:
|
||||
enabled: false
|
||||
redis:
|
||||
host: localhost
|
||||
port: 6379
|
||||
|
||||
+13
-2
@@ -3,13 +3,16 @@ package de.nowchess.chess.service
|
||||
import de.nowchess.api.dto.{GameCreationRequestDto, PlayerInfoDto, TimeControlDto}
|
||||
import de.nowchess.api.game.{GameMode, TimeControl}
|
||||
import de.nowchess.api.player.PlayerType
|
||||
import de.nowchess.chess.client.CombinedExportResponse
|
||||
import de.nowchess.chess.grpc.IoGrpcClientWrapper
|
||||
import de.nowchess.chess.redis.GameRedisSubscriberManager
|
||||
import io.quarkus.test.InjectMock
|
||||
import io.quarkus.test.junit.QuarkusTest
|
||||
import jakarta.inject.Inject
|
||||
import org.junit.jupiter.api.Assertions.*
|
||||
import org.junit.jupiter.api.{DisplayName, Test}
|
||||
import org.mockito.Mockito.verify
|
||||
import org.junit.jupiter.api.{BeforeEach, DisplayName, Test}
|
||||
import org.mockito.ArgumentMatchers.any
|
||||
import org.mockito.Mockito.{verify, when}
|
||||
import scala.compiletime.uninitialized
|
||||
|
||||
// scalafix:off
|
||||
@@ -23,6 +26,14 @@ class GameCreationServiceTest:
|
||||
@InjectMock
|
||||
var subscriberManager: GameRedisSubscriberManager = uninitialized
|
||||
|
||||
@InjectMock
|
||||
var ioWrapper: IoGrpcClientWrapper = uninitialized
|
||||
|
||||
@BeforeEach
|
||||
def setup(): Unit =
|
||||
when(ioWrapper.exportCombined(any()))
|
||||
.thenReturn(CombinedExportResponse("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1", ""))
|
||||
|
||||
private def player(id: String, name: String): PlayerInfoDto =
|
||||
PlayerInfoDto(id, name, PlayerType.Human)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user