diff --git a/nachrichten-manager-server/pom.xml b/nachrichten-manager-server/pom.xml index 76af39955f8d3d96e461467aacc12c6dfc111422..575746c78ca0badf6d04014ac986d0a1c7268e0c 100644 --- a/nachrichten-manager-server/pom.xml +++ b/nachrichten-manager-server/pom.xml @@ -48,7 +48,7 @@ <bayernid-proxy-interface.version>0.7.0</bayernid-proxy-interface.version> <vorgang-manager.version>2.17.0</vorgang-manager.version> <muk-postfach.version>0.1.0</muk-postfach.version> - <osiv2-postfach.version>0.1.1-SNAPSHOT</osiv2-postfach.version> + <osiv2-postfach.version>0.1.3-SNAPSHOT</osiv2-postfach.version> <api-lib.version>0.16.0</api-lib.version> <ozgcloud-common.version>4.7.0</ozgcloud-common.version> </properties> diff --git a/nachrichten-manager-server/src/test/java/de/ozgcloud/nachrichten/postfach/Osi2PostfachServiceITCase.java b/nachrichten-manager-server/src/test/java/de/ozgcloud/nachrichten/postfach/Osi2PostfachServiceITCase.java new file mode 100644 index 0000000000000000000000000000000000000000..55a583adc8bfcf43df8423b7730819f8f1535ca5 --- /dev/null +++ b/nachrichten-manager-server/src/test/java/de/ozgcloud/nachrichten/postfach/Osi2PostfachServiceITCase.java @@ -0,0 +1,85 @@ +package de.ozgcloud.nachrichten.postfach; + +import static org.assertj.core.api.Assertions.*; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.context.ApplicationEventPublisher; +import org.springframework.context.event.EventListener; +import org.springframework.stereotype.Component; +import org.springframework.test.context.TestPropertySource; + +import de.ozgcloud.common.test.ITCase; +import de.ozgcloud.nachrichten.attributes.ClientAttributeService; +import de.ozgcloud.nachrichten.email.EmailGrpcService; +import de.ozgcloud.nachrichten.postfach.osiv2.transfer.PostfachApiFacadeService; +import de.ozgcloud.vorgang.callcontext.WithMockCustomUser; + +@ITCase +@TestPropertySource(properties = { + "ozgcloud.osiv2-postfach.enabled=true" +}) +class Osi2PostfachServiceITCase { + + @Autowired + private PostfachService postfachService; + + @MockBean + private ApplicationEventPublisher publisher; + + @MockBean + private ClientAttributeService clientAttributeRemoteService; + + @MockBean + private PostfachApiFacadeService postfachApiFacadeService; + + @MockBean + private EmailGrpcService emailGrpcService; + + @Autowired + private OsiPostfachServiceITCase.SentEventTestListener sentEventTestListener; + + @BeforeEach + void mock() { + sentEventTestListener.reset(); + } + + @DisplayName("should call osi2 postfach send") + @Test + @WithMockCustomUser + void shouldCallOsi2PostfachSend() { + var osiNachricht = PostfachNachrichtTestFactory.createBuilder() + .postfachAddress(PostfachAddressTestFactory.createBuilder() + .serviceKontoType("OSI") + .build() + ) + .build(); + var commandId = "aaaaa"; + + postfachService.sendMail(commandId, "userId", osiNachricht); + + assertThat(sentEventTestListener.events) + .extracting(PostfachMailSentEvent::getSource) + .containsExactly(commandId); + } + + @Component + static class SentEventTestListener { + final List<PostfachMailSentEvent> events = new ArrayList<>(); + + @EventListener + void onEvent(PostfachMailSentEvent event) { + events.add(event); + } + + void reset() { + events.clear(); + } + } +}