From 50a6d66718abbf08368c41ec9c0df536cf5771c1 Mon Sep 17 00:00:00 2001 From: Paul-Christian Volkmer Date: Mon, 19 Feb 2024 17:06:02 +0100 Subject: feat: new kafka config due to kafka input --- .../etl/processor/config/AppConfigurationTest.kt | 46 ++++++++++++++++++++-- 1 file changed, 42 insertions(+), 4 deletions(-) (limited to 'src/integrationTest/kotlin/dev') 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 b4e4b92..d37c251 100644 --- a/src/integrationTest/kotlin/dev/dnpm/etl/processor/config/AppConfigurationTest.kt +++ b/src/integrationTest/kotlin/dev/dnpm/etl/processor/config/AppConfigurationTest.kt @@ -20,6 +20,7 @@ package dev.dnpm.etl.processor.config import com.fasterxml.jackson.databind.ObjectMapper +import dev.dnpm.etl.processor.input.KafkaInputListener import dev.dnpm.etl.processor.monitoring.RequestRepository import dev.dnpm.etl.processor.output.KafkaMtbFileSender import dev.dnpm.etl.processor.output.RestMtbFileSender @@ -78,8 +79,8 @@ class AppConfigurationTest { @TestPropertySource( properties = [ "app.kafka.servers=localhost:9092", - "app.kafka.topic=test", - "app.kafka.response-topic=test-response", + "app.kafka.output-topic=test", + "app.kafka.output-response-topic=test-response", "app.kafka.group-id=test" ] ) @@ -99,8 +100,8 @@ class AppConfigurationTest { properties = [ "app.rest.uri=http://localhost:9000", "app.kafka.servers=localhost:9092", - "app.kafka.topic=test", - "app.kafka.response-topic=test-response", + "app.kafka.output-topic=test", + "app.kafka.output-response-topic=test-response", "app.kafka.group-id=test" ] ) @@ -114,6 +115,43 @@ class AppConfigurationTest { } + @Nested + @TestPropertySource( + properties = [ + "app.kafka.servers=localhost:9092", + "app.kafka.output-topic=test", + "app.kafka.output-response-topic=test-response", + "app.kafka.group-id=test" + ] + ) + inner class AppConfigurationWithoutKafkaInputTest(private val context: ApplicationContext) { + + @Test + fun shouldNotUseKafkaInputListener() { + assertThrows { context.getBean(KafkaInputListener::class.java) } + } + + } + + @Nested + @TestPropertySource( + properties = [ + "app.kafka.servers=localhost:9092", + "app.kafka.input-topic=test_input", + "app.kafka.output-topic=test", + "app.kafka.output-response-topic=test-response", + "app.kafka.group-id=test" + ] + ) + inner class AppConfigurationUsingKafkaInputTest(private val context: ApplicationContext) { + + @Test + fun shouldUseKafkaInputListener() { + assertThat(context.getBean(KafkaInputListener::class.java)).isNotNull + } + + } + @Nested @TestPropertySource( properties = [ -- cgit v1.2.3 From 408b121f269b49da1b2dbfa4c3d7190b6df6b010 Mon Sep 17 00:00:00 2001 From: Paul-Christian Volkmer Date: Thu, 29 Feb 2024 08:47:17 +0100 Subject: test: add test for max retry attempts --- .../etl/processor/config/AppConfigurationTest.kt | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/integrationTest/kotlin/dev') 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 d37c251..46a756b 100644 --- a/src/integrationTest/kotlin/dev/dnpm/etl/processor/config/AppConfigurationTest.kt +++ b/src/integrationTest/kotlin/dev/dnpm/etl/processor/config/AppConfigurationTest.kt @@ -38,6 +38,7 @@ import org.springframework.boot.test.context.SpringBootTest import org.springframework.boot.test.mock.mockito.MockBean import org.springframework.boot.test.mock.mockito.MockBeans import org.springframework.context.ApplicationContext +import org.springframework.retry.support.RetryTemplate import org.springframework.security.crypto.password.PasswordEncoder import org.springframework.security.provisioning.InMemoryUserDetailsManager import org.springframework.test.context.ContextConfiguration @@ -276,4 +277,30 @@ class AppConfigurationTest { } + @Nested + @TestPropertySource( + properties = [ + "app.rest.uri=http://localhost:9000", + "app.max-retry-attempts=5" + ] + ) + inner class AppConfigurationRetryTest(private val context: ApplicationContext) { + + private val maxRetryAttempts = 5 + + @Test + fun shouldUseRetryTemplateWithConfiguredMaxAttempts() { + val retryTemplate = context.getBean(RetryTemplate::class.java) + assertThat(retryTemplate).isNotNull + + assertThrows { + retryTemplate.execute { + assertThat(it.retryCount).isLessThan(maxRetryAttempts) + throw RuntimeException() + } + } + } + + } + } \ No newline at end of file -- cgit v1.2.3