diff --git a/build.gradle.kts b/build.gradle.kts index e8fff64..8dfc1cc 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -72,7 +72,7 @@ sonar { val versions = mapOf( "QUARKUS_SCALA3" to "1.0.0", "SCALA3" to "3.5.1", - "SCALA_LIBRARY" to "2.13.18", + "SCALA_LIBRARY" to "2.13.16", "SCALATEST" to "3.2.19", "SCALATEST_JUNIT" to "0.1.11", "SCOVERAGE" to "2.1.1", diff --git a/modules/core/build.gradle.kts b/modules/core/build.gradle.kts index a02a07c..d572500 100644 --- a/modules/core/build.gradle.kts +++ b/modules/core/build.gradle.kts @@ -74,6 +74,7 @@ dependencies { testImplementation("org.scalatest:scalatest_3:${versions["SCALATEST"]!!}") testImplementation("co.helmethair:scalatest-junit-runner:${versions["SCALATEST_JUNIT"]!!}") testImplementation("io.quarkus:quarkus-junit5") + testImplementation("io.quarkus:quarkus-junit5-mockito") testImplementation("io.rest-assured:rest-assured") testRuntimeOnly("org.junit.platform:junit-platform-launcher") diff --git a/modules/core/src/test/scala/de/nowchess/chess/resource/GameResourceIntegrationTest.scala b/modules/core/src/test/scala/de/nowchess/chess/resource/GameResourceIntegrationTest.scala index bf165cc..1ee458e 100644 --- a/modules/core/src/test/scala/de/nowchess/chess/resource/GameResourceIntegrationTest.scala +++ b/modules/core/src/test/scala/de/nowchess/chess/resource/GameResourceIntegrationTest.scala @@ -1,11 +1,19 @@ package de.nowchess.chess.resource import de.nowchess.api.dto.* +import de.nowchess.api.game.GameContext +import de.nowchess.chess.client.IoServiceClient import de.nowchess.chess.exception.BadRequestException +import de.nowchess.io.fen.FenExporter +import de.nowchess.io.pgn.PgnParser +import io.quarkus.test.InjectMock import io.quarkus.test.junit.QuarkusTest import jakarta.inject.Inject -import org.junit.jupiter.api.{DisplayName, Test} +import org.eclipse.microprofile.rest.client.inject.RestClient +import org.junit.jupiter.api.{BeforeEach, DisplayName, Test} import org.junit.jupiter.api.Assertions.* +import org.mockito.ArgumentMatchers.any +import org.mockito.Mockito.when import scala.compiletime.uninitialized @@ -17,6 +25,19 @@ class GameResourceIntegrationTest: @Inject var resource: GameResource = uninitialized + @InjectMock + @RestClient + var ioClient: IoServiceClient = uninitialized + + @BeforeEach + def setupMocks(): Unit = + when(ioClient.importFen(any())).thenReturn(GameContext.initial) + when(ioClient.importPgn(any())).thenReturn( + PgnParser.importGameContext("1. e4 c5").toOption.get, + ) + when(ioClient.exportFen(any())).thenReturn(FenExporter.exportGameContext(GameContext.initial)) + when(ioClient.exportPgn(any())).thenReturn("1. e4 c5") + @Test @DisplayName("createGame returns 201") def testCreateGame(): Unit = diff --git a/modules/io/build.gradle.kts b/modules/io/build.gradle.kts index 7a6751d..61ea69d 100644 --- a/modules/io/build.gradle.kts +++ b/modules/io/build.gradle.kts @@ -77,6 +77,18 @@ dependencies { testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine") } + +configurations.matching { !it.name.startsWith("scoverage") }.configureEach { + resolutionStrategy.force("org.scala-lang:scala-library:${versions["SCALA_LIBRARY"]!!}") +} +configurations.scoverage { + resolutionStrategy.eachDependency { + if (requested.group == "org.scoverage" && requested.name.startsWith("scalac-scoverage-plugin_")) { + useTarget("${requested.group}:scalac-scoverage-plugin_2.13.16:2.3.0") + } + } +} + tasks.withType { options.encoding = "UTF-8" options.compilerArgs.add("-parameters")