diff --git a/collaboration-manager-server/src/main/java/de/ozgcloud/collaboration/CollaborationService.java b/collaboration-manager-server/src/main/java/de/ozgcloud/collaboration/CollaborationService.java index 257d19c5ad692c1f026bdff02e62d96175857aca..7ae428fb57a036cbf7f501b900d8eba9977c3ce6 100644 --- a/collaboration-manager-server/src/main/java/de/ozgcloud/collaboration/CollaborationService.java +++ b/collaboration-manager-server/src/main/java/de/ozgcloud/collaboration/CollaborationService.java @@ -59,6 +59,9 @@ public class CollaborationService { static final String FIELD_SUBJECT = "subject"; static final String FIELD_MAIL_BODY = "mailBody"; static final String SUBJECT = "Kooperationsanfrage"; + static final String MUK_SERVICEKONTO_TYPE = "MUK"; + static final String MUK_POSTFACH_ADDRESS_VERSION = "1.0"; + static final int MUK_POSTFACH_ADDRESS_TYPE = 1; @Qualifier(CollaborationManagerConfiguration.VORGANG_SERVICE_NAME) // NOSONAR private final VorgangService vorgangService; @@ -100,8 +103,7 @@ public class CollaborationService { public void createFachstellenBeteiligungRequest(@Valid CollaborationRequest collaborationRequest) { var vorgang = vorgangService.getVorgang(collaborationRequest.getVorgangId()); var enrichedRequest = enrichCollaborationRequest(collaborationRequest, vorgang.getId().toString()); - var addSubCommandsRequest = buildCreateSubCommandsRequest(enrichedRequest, - buildSubCommands(enrichedRequest, vorgang.getHeader().getServiceKonto())); + var addSubCommandsRequest = buildCreateSubCommandsRequest(enrichedRequest, buildSubCommands(enrichedRequest)); commandService.addSubCommands(addSubCommandsRequest); } @@ -118,14 +120,14 @@ public class CollaborationService { .build(); } - List<OzgCloudCommand> buildSubCommands(CollaborationRequest collaborationRequest, ServiceKonto serviceKonto) { + List<OzgCloudCommand> buildSubCommands(CollaborationRequest collaborationRequest) { return List.of( collaborationRequestMapper.toOzgCloudCommand(collaborationRequest, CREATE_ATTACHED_ITEM_ORDER), - buildSendPostfachNachrichtCommand(collaborationRequest, serviceKonto)); + buildSendPostfachNachrichtCommand(collaborationRequest)); } - OzgCloudCommand buildSendPostfachNachrichtCommand(CollaborationRequest collaborationRequest, ServiceKonto serviceKonto) { - var bodyObject = buildPostfachSendNachrichtCommandBody(buildPostfachAddress(serviceKonto.getAddresses().getFirst(), serviceKonto.getType()), + OzgCloudCommand buildSendPostfachNachrichtCommand(CollaborationRequest collaborationRequest) { + var bodyObject = buildPostfachSendNachrichtCommandBody(buildMukPostfachAddress(collaborationRequest.getZustaendigeStelle()), collaborationRequest.getVorgangId()); return OzgCloudCommand.builder() .vorgangId(commandMapper.toOzgCloudVorgangId(collaborationRequest.getVorgangId())) @@ -136,12 +138,16 @@ public class CollaborationService { .build(); } - Map<String, Object> buildPostfachAddress(ServiceKonto.PostfachAddress postfachAddress, String serviceKontoType) { + Map<String, Object> buildMukPostfachAddress(String postfachId) { return Map.of( - ServiceKonto.PostfachAddress.FIELD_TYPE, postfachAddress.getType(), - ServiceKonto.PostfachAddress.FIELD_VERSION, postfachAddress.getVersion(), - ServiceKonto.PostfachAddress.FIELD_IDENTIFIER, postfachAddress.getIdentifier(), - ServiceKonto.FIELD_SERVICEKONTO_TYPE, serviceKontoType); + ServiceKonto.PostfachAddress.FIELD_TYPE, MUK_POSTFACH_ADDRESS_TYPE, + ServiceKonto.PostfachAddress.FIELD_VERSION, MUK_POSTFACH_ADDRESS_VERSION, + ServiceKonto.PostfachAddress.FIELD_IDENTIFIER, buildPostfachIdentifier(postfachId), + ServiceKonto.FIELD_SERVICEKONTO_TYPE, MUK_SERVICEKONTO_TYPE); + } + + Map<String, Object> buildPostfachIdentifier(String postfachId) { + return Map.of(ServiceKonto.PostfachAddress.FIELD_IDENTIFIER_POSTFACH_ID, postfachId); } Map<String, Object> buildPostfachSendNachrichtCommandBody(Map<String, Object> postfachAddress, String vorgangId) { diff --git a/collaboration-manager-server/src/main/java/de/ozgcloud/collaboration/vorgang/ServiceKonto.java b/collaboration-manager-server/src/main/java/de/ozgcloud/collaboration/vorgang/ServiceKonto.java index 08c511c3731fd1a1feb09e9514c6c6adc411d2a4..348519cede06273dc380eee0cfcfbeb906f0ca5a 100644 --- a/collaboration-manager-server/src/main/java/de/ozgcloud/collaboration/vorgang/ServiceKonto.java +++ b/collaboration-manager-server/src/main/java/de/ozgcloud/collaboration/vorgang/ServiceKonto.java @@ -49,6 +49,7 @@ public class ServiceKonto { public static final String FIELD_VERSION = "version"; public static final String FIELD_TYPE = "type"; public static final String FIELD_IDENTIFIER = "identifier"; + public static final String FIELD_IDENTIFIER_POSTFACH_ID = "postfachId"; private String version; private int type; diff --git a/collaboration-manager-server/src/test/java/de/ozgcloud/collaboration/CollaborationServiceTest.java b/collaboration-manager-server/src/test/java/de/ozgcloud/collaboration/CollaborationServiceTest.java index 68dc021e4f75af3f230a19d73cbe778a91b9aa74..cecf47b8e6af03ea0e7da3a11e830d406309e2d5 100644 --- a/collaboration-manager-server/src/test/java/de/ozgcloud/collaboration/CollaborationServiceTest.java +++ b/collaboration-manager-server/src/test/java/de/ozgcloud/collaboration/CollaborationServiceTest.java @@ -56,7 +56,6 @@ import de.ozgcloud.collaboration.vorgang.PostfachAddressTestFactory; import de.ozgcloud.collaboration.vorgang.ServiceKonto; import de.ozgcloud.collaboration.vorgang.ServiceKontoTestFactory; import de.ozgcloud.collaboration.vorgang.Vorgang; -import de.ozgcloud.collaboration.vorgang.VorgangHeaderTestFactory; import de.ozgcloud.collaboration.vorgang.VorgangService; import de.ozgcloud.collaboration.vorgang.VorgangTestFactory; import de.ozgcloud.command.CommandTestFactory; @@ -262,7 +261,7 @@ class CollaborationServiceTest { @BeforeEach void init() { - doReturn(List.of(subCommand)).when(service).buildSubCommands(any(), any()); + doReturn(List.of(subCommand)).when(service).buildSubCommands(any()); when(vorgangService.getVorgang(any())).thenReturn(VORGANG); doReturn(ENRICHED_REQUEST).when(service).enrichCollaborationRequest(any(), any()); } @@ -287,7 +286,7 @@ class CollaborationServiceTest { void shouldCallBuildSubCommands() { service.createFachstellenBeteiligungRequest(CollaborationRequestTestFactory.create()); - verify(service).buildSubCommands(ENRICHED_REQUEST, VorgangHeaderTestFactory.SERVICE_KONTO); + verify(service).buildSubCommands(ENRICHED_REQUEST); } @Test @@ -360,7 +359,7 @@ class CollaborationServiceTest { @BeforeEach void init() { when(collaborationRequestMapper.toOzgCloudCommand(any(), any())).thenReturn(persistCollaborationRequestCommand); - doReturn(sendPostfachNachrichtCommand).when(service).buildSendPostfachNachrichtCommand(any(), any()); + doReturn(sendPostfachNachrichtCommand).when(service).buildSendPostfachNachrichtCommand(any()); } @Test @@ -374,7 +373,7 @@ class CollaborationServiceTest { void shouldCallBuildSendPostfachNachrichtCommand() { buildSubCommands(); - verify(service).buildSendPostfachNachrichtCommand(COLLABORATION_REQUEST, VorgangHeaderTestFactory.SERVICE_KONTO); + verify(service).buildSendPostfachNachrichtCommand(COLLABORATION_REQUEST); } @Test @@ -385,7 +384,7 @@ class CollaborationServiceTest { } private List<OzgCloudCommand> buildSubCommands() { - return service.buildSubCommands(COLLABORATION_REQUEST, VorgangHeaderTestFactory.SERVICE_KONTO); + return service.buildSubCommands(COLLABORATION_REQUEST); } } @@ -412,13 +411,13 @@ class CollaborationServiceTest { void shouldCallBuildPostfachAddress() { buildSendPostfachNachrichtCommand(); - verify(service).buildPostfachAddress(POSTFACH_ADDRESS, ServiceKontoTestFactory.TYPE); + verify(service).buildMukPostfachAddress(CollaborationRequestTestFactory.ZUSTAENDIGE_STELLE); } @Test void shouldCallBuildSenNachrichtCommandBody() { var postfachAddressMap = Map.<String, Object>of("key", "value"); - doReturn(postfachAddressMap).when(service).buildPostfachAddress(any(), any()); + doReturn(postfachAddressMap).when(service).buildMukPostfachAddress(any()); buildSendPostfachNachrichtCommand(); @@ -482,7 +481,7 @@ class CollaborationServiceTest { } private OzgCloudCommand buildSendPostfachNachrichtCommand() { - return service.buildSendPostfachNachrichtCommand(COLLABORATION_REQUEST, SERVICE_KONTO); + return service.buildSendPostfachNachrichtCommand(COLLABORATION_REQUEST); } } @@ -493,32 +492,33 @@ class CollaborationServiceTest { void shouldSetType() { var result = buildPostfachAddress(); - assertThat(result).containsEntry(ServiceKonto.PostfachAddress.FIELD_TYPE, PostfachAddressTestFactory.TYPE); + assertThat(result).containsEntry(ServiceKonto.PostfachAddress.FIELD_TYPE, CollaborationService.MUK_POSTFACH_ADDRESS_TYPE); } @Test void shouldSetVersion() { var result = buildPostfachAddress(); - assertThat(result).containsEntry(ServiceKonto.PostfachAddress.FIELD_VERSION, PostfachAddressTestFactory.VERSION); + assertThat(result).containsEntry(ServiceKonto.PostfachAddress.FIELD_VERSION, CollaborationService.MUK_POSTFACH_ADDRESS_VERSION); } @Test void shouldSetIdentifier() { var result = buildPostfachAddress(); - assertThat(result).extracting(ServiceKonto.PostfachAddress.FIELD_IDENTIFIER, MAP).containsValue(PostfachAddressTestFactory.POSTFACH_ID); + assertThat(result).extracting(ServiceKonto.PostfachAddress.FIELD_IDENTIFIER, MAP) + .containsEntry(ServiceKonto.PostfachAddress.FIELD_IDENTIFIER_POSTFACH_ID, CollaborationRequestTestFactory.ZUSTAENDIGE_STELLE); } @Test void shouldSetServicekontoType() { var result = buildPostfachAddress(); - assertThat(result).containsEntry(ServiceKonto.FIELD_SERVICEKONTO_TYPE, ServiceKontoTestFactory.TYPE); + assertThat(result).containsEntry(ServiceKonto.FIELD_SERVICEKONTO_TYPE, CollaborationService.MUK_SERVICEKONTO_TYPE); } private Map<String, Object> buildPostfachAddress() { - return service.buildPostfachAddress(PostfachAddressTestFactory.create(), ServiceKontoTestFactory.TYPE); + return service.buildMukPostfachAddress(CollaborationRequestTestFactory.ZUSTAENDIGE_STELLE); } }