From 18640103831e1dc2d21bc0c3c91263ddf3f8503c Mon Sep 17 00:00:00 2001 From: Paul-Christian Volkmer Date: Wed, 6 May 2026 10:12:38 +0200 Subject: test: code cleanup in test classes --- .../etl/processor/config/AppConfigurationTest.kt | 37 +++++++++++----------- .../processor/config/GPasConfigPropertiesTest.kt | 5 +-- .../dnpm/etl/processor/web/ConfigControllerTest.kt | 3 +- .../processor/web/StatisticsRestControllerTest.kt | 3 +- 4 files changed, 26 insertions(+), 22 deletions(-) (limited to 'src/integrationTest/kotlin/dev/dnpm/etl/processor') diff --git a/src/integrationTest/kotlin/dev/dnpm/etl/processor/config/AppConfigurationTest.kt b/src/integrationTest/kotlin/dev/dnpm/etl/processor/config/AppConfigurationTest.kt index a932ab7..b0fa70f 100644 --- a/src/integrationTest/kotlin/dev/dnpm/etl/processor/config/AppConfigurationTest.kt +++ b/src/integrationTest/kotlin/dev/dnpm/etl/processor/config/AppConfigurationTest.kt @@ -39,6 +39,7 @@ import org.junit.jupiter.api.Nested import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows import org.springframework.beans.factory.NoSuchBeanDefinitionException +import org.springframework.beans.factory.getBean import org.springframework.boot.kafka.autoconfigure.KafkaAutoConfiguration import org.springframework.boot.test.context.SpringBootTest import org.springframework.context.ApplicationContext @@ -76,9 +77,9 @@ class AppConfigurationTest { ) { @Test fun shouldUseRestMtbFileSenderNotKafkaMtbFileSender() { - assertThat(context.getBean(RestMtbFileSender::class.java)).isNotNull + assertThat(context.getBean()).isNotNull assertThrows { - context.getBean(KafkaMtbFileSender::class.java) + context.getBean() } } } @@ -99,8 +100,8 @@ class AppConfigurationTest { ) { @Test fun shouldUseKafkaMtbFileSenderNotRestMtbFileSender() { - assertThrows { context.getBean(RestMtbFileSender::class.java) } - assertThat(context.getBean(KafkaMtbFileSender::class.java)).isNotNull + assertThrows { context.getBean() } + assertThat(context.getBean()).isNotNull } } @@ -120,9 +121,9 @@ class AppConfigurationTest { ) { @Test fun shouldUseRestMtbFileSenderNotKafkaMtbFileSender() { - assertThat(context.getBean(RestMtbFileSender::class.java)).isNotNull + assertThat(context.getBean()).isNotNull assertThrows { - context.getBean(KafkaMtbFileSender::class.java) + context.getBean() } } } @@ -143,7 +144,7 @@ class AppConfigurationTest { @Test fun shouldNotUseKafkaInputListener() { assertThrows { - context.getBean(KafkaInputListener::class.java) + context.getBean() } } } @@ -165,7 +166,7 @@ class AppConfigurationTest { ) { @Test fun shouldUseKafkaInputListener() { - assertThat(context.getBean(KafkaInputListener::class.java)).isNotNull + assertThat(context.getBean()).isNotNull } } @@ -183,7 +184,7 @@ class AppConfigurationTest { ) { @Test fun shouldRecognizeTransformations() { - val appConfigProperties = context.getBean(AppConfigProperties::class.java) + val appConfigProperties = context.getBean() assertThat(appConfigProperties).isNotNull assertThat(appConfigProperties.transformations).hasSize(1) @@ -199,7 +200,7 @@ class AppConfigurationTest { ) { @Test fun shouldUseConfiguredGenerator() { - assertThat(context.getBean(AnonymizingGenerator::class.java)).isNotNull + assertThat(context.getBean()).isNotNull } } @@ -213,7 +214,7 @@ class AppConfigurationTest { ) { @Test fun shouldUseConfiguredGenerator() { - assertThat(context.getBean(GpasPseudonymGenerator::class.java)).isNotNull + assertThat(context.getBean()).isNotNull } } @@ -230,7 +231,7 @@ class AppConfigurationTest { ) { @Test fun shouldUseConfiguredGenerator() { - assertThat(context.getBean(GpasSoapPseudonymGenerator::class.java)).isNotNull + assertThat(context.getBean()).isNotNull } } @@ -244,7 +245,7 @@ class AppConfigurationTest { ) { @Test fun checkTokenService() { - assertThat(context.getBean(TokenService::class.java)).isNotNull + assertThat(context.getBean()).isNotNull } } @@ -257,7 +258,7 @@ class AppConfigurationTest { ) { @Test fun checkTokenService() { - assertThrows { context.getBean(TokenService::class.java) } + assertThrows { context.getBean() } } } } @@ -273,7 +274,7 @@ class AppConfigurationTest { @Test fun shouldUseRetryTemplateWithConfiguredMaxAttempts() { - val retryTemplate = context.getBean(RetryTemplate::class.java) + val retryTemplate = context.getBean() assertThat(retryTemplate).isNotNull assertThrows { @@ -298,7 +299,7 @@ class AppConfigurationTest { ) { @Test fun shouldUseConfiguredGenerator() { - assertThat(context.getBean(GicsConsentService::class.java)).isNotNull + assertThat(context.getBean()).isNotNull } } @@ -315,7 +316,7 @@ class AppConfigurationTest { ) { @Test fun shouldUseConfiguredGenerator() { - assertThat(context.getBean(GicsGetBroadConsentService::class.java)).isNotNull + assertThat(context.getBean()).isNotNull } } @@ -325,7 +326,7 @@ class AppConfigurationTest { ) { @Test fun shouldUseConfiguredGenerator() { - assertThat(context.getBean(MtbFileConsentService::class.java)).isNotNull + assertThat(context.getBean()).isNotNull } } } diff --git a/src/integrationTest/kotlin/dev/dnpm/etl/processor/config/GPasConfigPropertiesTest.kt b/src/integrationTest/kotlin/dev/dnpm/etl/processor/config/GPasConfigPropertiesTest.kt index bda5b79..7ba171e 100644 --- a/src/integrationTest/kotlin/dev/dnpm/etl/processor/config/GPasConfigPropertiesTest.kt +++ b/src/integrationTest/kotlin/dev/dnpm/etl/processor/config/GPasConfigPropertiesTest.kt @@ -2,6 +2,7 @@ package dev.dnpm.etl.processor.config import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test +import org.springframework.beans.factory.getBean import org.springframework.boot.context.properties.EnableConfigurationProperties import org.springframework.boot.test.context.SpringBootTest import org.springframework.boot.test.context.runner.ApplicationContextRunner @@ -26,7 +27,7 @@ class GPasConfigPropertiesTest { "app.pseudonymize.gpas.uri=http://localhost/", "app.pseudonymize.gpas.pid-domain=test-pid-domain", ).run { context -> - val properties = context.getBean(GPasConfigProperties::class.java) + val properties = context.getBean() assertThat(properties).isNotNull assertThat(properties.patientDomain).isEqualTo("test-pid-domain") @@ -41,7 +42,7 @@ class GPasConfigPropertiesTest { "app.pseudonymize.gpas.uri=http://localhost/", "app.pseudonymize.gpas.patient-domain=test-patient-domain", ).run { context -> - val properties = context.getBean(GPasConfigProperties::class.java) + val properties = context.getBean() assertThat(properties).isNotNull assertThat(properties.patientDomain).isEqualTo("test-patient-domain") diff --git a/src/integrationTest/kotlin/dev/dnpm/etl/processor/web/ConfigControllerTest.kt b/src/integrationTest/kotlin/dev/dnpm/etl/processor/web/ConfigControllerTest.kt index 0e24870..b946da8 100644 --- a/src/integrationTest/kotlin/dev/dnpm/etl/processor/web/ConfigControllerTest.kt +++ b/src/integrationTest/kotlin/dev/dnpm/etl/processor/web/ConfigControllerTest.kt @@ -58,6 +58,7 @@ import org.springframework.test.context.TestPropertySource import org.springframework.test.context.bean.override.mockito.MockitoBean import org.springframework.test.context.junit.jupiter.SpringExtension import org.springframework.test.web.reactive.server.WebTestClient +import org.springframework.test.web.reactive.server.returnResult import org.springframework.test.web.servlet.* import org.springframework.test.web.servlet.client.MockMvcWebTestClient import org.springframework.test.web.servlet.htmlunit.MockMvcWebClientBuilder @@ -351,7 +352,7 @@ class ConfigControllerTest { .isOk() .expectHeader() .contentType(TEXT_EVENT_STREAM) - .returnResult(ConnectionCheckResult.GPasConnectionCheckResult::class.java) + .returnResult() StepVerifier.create(result.responseBody).expectNext(expectedEvent).expectComplete().verify() } diff --git a/src/integrationTest/kotlin/dev/dnpm/etl/processor/web/StatisticsRestControllerTest.kt b/src/integrationTest/kotlin/dev/dnpm/etl/processor/web/StatisticsRestControllerTest.kt index 2568b1b..cb19cf4 100644 --- a/src/integrationTest/kotlin/dev/dnpm/etl/processor/web/StatisticsRestControllerTest.kt +++ b/src/integrationTest/kotlin/dev/dnpm/etl/processor/web/StatisticsRestControllerTest.kt @@ -49,6 +49,7 @@ import org.springframework.test.context.TestPropertySource import org.springframework.test.context.bean.override.mockito.MockitoBean import org.springframework.test.context.junit.jupiter.SpringExtension import org.springframework.test.web.reactive.server.WebTestClient +import org.springframework.test.web.reactive.server.returnResult import org.springframework.test.web.servlet.MockMvc import org.springframework.test.web.servlet.client.MockMvcWebTestClient import org.springframework.test.web.servlet.get @@ -333,7 +334,7 @@ class StatisticsRestControllerTest { .isOk() .expectHeader() .contentType(TEXT_EVENT_STREAM) - .returnResult(String::class.java) + .returnResult() StepVerifier.create(result.responseBody).expectComplete().verify() } -- cgit v1.2.3