diff --git a/nachrichten-manager-server/pom.xml b/nachrichten-manager-server/pom.xml index 62b4aea0d3127fc92d8f287429a87272e5716a6e..6bf7913e69a308b529d5969465a08ca00f241d38 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.0-SNAPSHOT</osiv2-postfach.version> + <osiv2-postfach.version>0.1.0</osiv2-postfach.version> <api-lib.version>0.16.0</api-lib.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 deleted file mode 100644 index efe8e237c63a38070000b63ba4245a9646b0afed..0000000000000000000000000000000000000000 --- a/nachrichten-manager-server/src/test/java/de/ozgcloud/nachrichten/postfach/Osi2PostfachServiceITCase.java +++ /dev/null @@ -1,99 +0,0 @@ -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.context.SpringBootTest; -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.ActiveProfiles; - -import de.ozgcloud.nachrichten.NachrichtenManagerTestApplication; -import de.ozgcloud.nachrichten.attributes.ClientAttributeService; -import de.ozgcloud.nachrichten.email.EmailGrpcService; -import de.ozgcloud.nachrichten.postfach.osiv2.config.Osi2PostfachProperties; -import de.ozgcloud.nachrichten.postfach.osiv2.transfer.PostfachApiFacadeService; -import de.ozgcloud.vorgang.callcontext.WithMockCustomUser; - -@SpringBootTest(classes = NachrichtenManagerTestApplication.class, - properties = { - "ozgcloud.osiv2.enabled=true" - }) -@ActiveProfiles({ "itcase", "stage" }) -class Osi2PostfachServiceITCase { - - @Autowired - private PostfachService postfachService; - - @Autowired - private Osi2PostfachProperties.ApiConfiguration osi2ApiConfiguration; - - @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 use stage profile properties") - @Test - void shouldUseStageProfileProperties() { - var url = osi2ApiConfiguration.getUrl(); - - assertThat(url).isNotEmpty(); - } - - @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(); - } - } -} diff --git a/nachrichten-manager-server/src/test/java/de/ozgcloud/nachrichten/postfach/OsiPostfachServiceITCase.java b/nachrichten-manager-server/src/test/java/de/ozgcloud/nachrichten/postfach/OsiPostfachServiceITCase.java deleted file mode 100644 index d647dcc27083707838b9d3f2cf510bf2b7242873..0000000000000000000000000000000000000000 --- a/nachrichten-manager-server/src/test/java/de/ozgcloud/nachrichten/postfach/OsiPostfachServiceITCase.java +++ /dev/null @@ -1,95 +0,0 @@ -package de.ozgcloud.nachrichten.postfach; - -import static org.assertj.core.api.Assertions.*; -import static org.mockito.Mockito.*; - -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.mockito.Mockito; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.event.EventListener; -import org.springframework.http.HttpMethod; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Component; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.web.client.RestTemplate; - -import de.ozgcloud.nachrichten.NachrichtenManagerTestApplication; -import de.ozgcloud.nachrichten.attributes.ClientAttributeService; -import de.ozgcloud.nachrichten.email.EmailGrpcService; -import de.ozgcloud.nachrichten.postfach.osi.MessageAttachmentService; -import lombok.SneakyThrows; - -@SpringBootTest(classes = NachrichtenManagerTestApplication.class, - properties = { - "ozgcloud.osi.postfach.proxyapi.key=key", - "ozgcloud.osi.postfach.proxyapi.realm=realm", - "ozgcloud.osi.postfach.proxyapi.url=url", - }) -@ActiveProfiles({ "itcase" }) -class OsiPostfachServiceITCase { - - @Autowired - private PostfachService postfachService; - - @MockBean - private ClientAttributeService clientAttributeRemoteService; - - @MockBean - private MessageAttachmentService messageAttachmentService; - - @MockBean - private EmailGrpcService emailGrpcService; - - @MockBean - private RestTemplate restTemplate; - - @Autowired - private SentEventTestListener sentEventTestListener; - - @BeforeEach - void mock() { - sentEventTestListener.reset(); - } - - @DisplayName("should call osi postfach send") - @Test - @SneakyThrows - void shouldCallOsiPostfachSend() { - var osiNachricht = PostfachNachrichtTestFactory.createBuilder() - .postfachAddress(PostfachAddressTestFactory.createBuilder() - .serviceKontoType("OSI") - .build() - ) - .build(); - var commandId = "aaaaa"; - when(restTemplate.exchange(eq("url"), eq(HttpMethod.POST), any(), Mockito.<Class<String>>any())).thenReturn(ResponseEntity.ok("true")); - - 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(); - } - } - -}