From a54dfde6b30a9330285ad284a7cfb86ad019001e Mon Sep 17 00:00:00 2001 From: Saku K <6057704+saku-koodari@users.noreply.github.com> Date: Mon, 30 Dec 2024 14:25:43 +0200 Subject: [PATCH] test(oppijanumero): fix tests from CI by not using spring beans --- .../src/main/resources/application.properties | 1 - .../oppijanumero/OppijanumeroServiceTests.kt | 23 +++++-------------- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/server/src/main/resources/application.properties b/server/src/main/resources/application.properties index 6bb01b2b..95089f42 100644 --- a/server/src/main/resources/application.properties +++ b/server/src/main/resources/application.properties @@ -13,7 +13,6 @@ kitu.kotoutumiskoulutus.koealusta.scheduling.enabled=false kitu.oppijanumero.password=${OPPIJANUMERO_PASSWORD} kitu.oppijanumero.username=koto-rekisteri kitu.oppijanumero.callerid=1.2.246.562.10.00000000001.koto-rekisteri -kitu.oppijanumero.service.url= kitu.oppijanumero.service.use-mock-data=false db-scheduler.enabled=true diff --git a/server/src/test/kotlin/fi/oph/kitu/oppijanumero/OppijanumeroServiceTests.kt b/server/src/test/kotlin/fi/oph/kitu/oppijanumero/OppijanumeroServiceTests.kt index ea02ffc0..7c266c05 100644 --- a/server/src/test/kotlin/fi/oph/kitu/oppijanumero/OppijanumeroServiceTests.kt +++ b/server/src/test/kotlin/fi/oph/kitu/oppijanumero/OppijanumeroServiceTests.kt @@ -4,17 +4,10 @@ import HttpResponseMock import com.fasterxml.jackson.databind.ObjectMapper import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.context.SpringBootTest -import org.testcontainers.junit.jupiter.Testcontainers -@SpringBootTest -@Testcontainers class OppijanumeroServiceTests { @Test - fun `oppijanumero service returns identified user`( - @Autowired objectMapper: ObjectMapper, - ) { + fun `oppijanumero service returns identified user`() { // Facade val response = Result.success( @@ -34,7 +27,7 @@ class OppijanumeroServiceTests { OppijanumeroServiceImpl( casAuthenticatedService = CasAuthenticatedServiceMock(response), - objectMapper = objectMapper, + objectMapper = ObjectMapper(), ) oppijanumeroService.serviceUrl = "http://localhost:8080/oppijanumero-service" @@ -49,9 +42,7 @@ class OppijanumeroServiceTests { } @Test - fun `oppijanumero service returns unidentified user`( - @Autowired objectMapper: ObjectMapper, - ) { + fun `oppijanumero service returns unidentified user`() { // Facade val response = Result.success( @@ -71,7 +62,7 @@ class OppijanumeroServiceTests { OppijanumeroServiceImpl( casAuthenticatedService = CasAuthenticatedServiceMock(response), - objectMapper = objectMapper, + objectMapper = ObjectMapper(), ) oppijanumeroService.serviceUrl = "http://localhost:8080/oppijanumero-service" @@ -88,9 +79,7 @@ class OppijanumeroServiceTests { } @Test - fun `oppijanumero service returns error`( - @Autowired objectMapper: ObjectMapper, - ) { + fun `oppijanumero service returns error`() { // Facade val response = Result.success( @@ -112,7 +101,7 @@ class OppijanumeroServiceTests { OppijanumeroServiceImpl( casAuthenticatedService = CasAuthenticatedServiceMock(response), - objectMapper = objectMapper, + objectMapper = ObjectMapper(), ) oppijanumeroService.serviceUrl = "http://localhost:8080/oppijanumero-service"