From 91879c6220894402c4ae32099b1fc8eb2c276fc7 Mon Sep 17 00:00:00 2001 From: Ralf Ueberfuhr Date: Fri, 28 Jun 2024 07:54:29 +0200 Subject: [PATCH] Disable transactional events in tests. --- .../schulung/accounts/kafka/CustomerEventsProducer.java | 2 ++ .../accounts/kafka/AutoConfigureKafkaTemplateMock.java | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/account-service-provider/src/main/java/de/sample/schulung/accounts/kafka/CustomerEventsProducer.java b/account-service-provider/src/main/java/de/sample/schulung/accounts/kafka/CustomerEventsProducer.java index cd6e342..23aac4c 100644 --- a/account-service-provider/src/main/java/de/sample/schulung/accounts/kafka/CustomerEventsProducer.java +++ b/account-service-provider/src/main/java/de/sample/schulung/accounts/kafka/CustomerEventsProducer.java @@ -5,6 +5,7 @@ import de.sample.schulung.accounts.domain.events.CustomerReplacedEvent; import de.sample.schulung.accounts.kafka.interceptor.KafkaProducer; import de.sample.schulung.accounts.kafka.interceptor.KafkaRecord; +import de.sample.schulung.accounts.persistence.transactions.events.ConditionalOnTransactionsDisabled; import lombok.RequiredArgsConstructor; import org.springframework.context.event.EventListener; import org.springframework.stereotype.Component; @@ -13,6 +14,7 @@ @Component @RequiredArgsConstructor +@ConditionalOnTransactionsDisabled public class CustomerEventsProducer { private final CustomerEventRecordMapper mapper; diff --git a/account-service-provider/src/test/java/de/sample/schulung/accounts/kafka/AutoConfigureKafkaTemplateMock.java b/account-service-provider/src/test/java/de/sample/schulung/accounts/kafka/AutoConfigureKafkaTemplateMock.java index d7b1242..610a46e 100644 --- a/account-service-provider/src/test/java/de/sample/schulung/accounts/kafka/AutoConfigureKafkaTemplateMock.java +++ b/account-service-provider/src/test/java/de/sample/schulung/accounts/kafka/AutoConfigureKafkaTemplateMock.java @@ -4,6 +4,7 @@ import org.springframework.boot.autoconfigure.kafka.KafkaAutoConfiguration; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.kafka.core.KafkaTemplate; +import org.springframework.test.context.TestPropertySource; import java.lang.annotation.*; @@ -21,6 +22,9 @@ @Target(ElementType.TYPE) @EnableAutoConfiguration(exclude = KafkaAutoConfiguration.class) @MockBean(KafkaTemplate.class) +@TestPropertySource( + properties = "application.persistence.enable-transactional-events=false" +) public @interface AutoConfigureKafkaTemplateMock { }