summaryrefslogtreecommitdiff
path: root/src/integrationTest
diff options
context:
space:
mode:
authorPaul-Christian Volkmer2024-02-29 08:51:28 +0100
committerPaul-Christian Volkmer2024-02-29 08:57:00 +0100
commit46ddaf10f7a5f0f3da121ef219442109a209db0b (patch)
treee8bab6455f7aa41bb168dd9689fc5df923782929 /src/integrationTest
parent25f286f73bb649558850d69bf063130ede3cfc08 (diff)
parent408b121f269b49da1b2dbfa4c3d7190b6df6b010 (diff)
Merge pull request #45 from CCC-MF/issue_34
Verwendung einer applikationsweiten Retry-Konfiguration
Diffstat (limited to 'src/integrationTest')
-rw-r--r--src/integrationTest/kotlin/dev/dnpm/etl/processor/config/AppConfigurationTest.kt73
1 files changed, 69 insertions, 4 deletions
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..46a756b 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
@@ -37,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
@@ -78,8 +80,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 +101,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"
]
)
@@ -117,6 +119,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<NoSuchBeanDefinitionException> { 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 = [
"app.transformations[0].path=consent.status",
"app.transformations[0].from=rejected",
"app.transformations[0].to=accept",
@@ -238,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<RuntimeException> {
+ retryTemplate.execute<Void, RuntimeException> {
+ assertThat(it.retryCount).isLessThan(maxRetryAttempts)
+ throw RuntimeException()
+ }
+ }
+ }
+
+ }
+
} \ No newline at end of file