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 367588a12e4519d7f136b699cd1b85c859f8c4eb..73e9da9cc2b1f19747150131cc73e71591495734 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 @@ -60,6 +60,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())); return OzgCloudCommand.builder() .vorgangId(commandMapper.toOzgCloudVorgangId(collaborationRequest.getVorgangId())) .relationId(commandMapper.mapRelationId(collaborationRequest.getVorgangId())) @@ -135,12 +137,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) { 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 4d1f78dda4fac0508c147c1cd8e8c8a74767dfd0..763ca620ebfd814b7e784a768f40436b20922d9e 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 @@ -53,7 +53,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; @@ -257,7 +256,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()); } @@ -282,7 +281,7 @@ class CollaborationServiceTest { void shouldCallBuildSubCommands() { service.createFachstellenBeteiligungRequest(CollaborationRequestTestFactory.create()); - verify(service).buildSubCommands(ENRICHED_REQUEST, VorgangHeaderTestFactory.SERVICE_KONTO); + verify(service).buildSubCommands(ENRICHED_REQUEST); } @Test @@ -355,7 +354,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 @@ -369,7 +368,7 @@ class CollaborationServiceTest { void shouldCallBuildSendPostfachNachrichtCommand() { buildSubCommands(); - verify(service).buildSendPostfachNachrichtCommand(COLLABORATION_REQUEST, VorgangHeaderTestFactory.SERVICE_KONTO); + verify(service).buildSendPostfachNachrichtCommand(COLLABORATION_REQUEST); } @Test @@ -380,7 +379,7 @@ class CollaborationServiceTest { } private List<OzgCloudCommand> buildSubCommands() { - return service.buildSubCommands(COLLABORATION_REQUEST, VorgangHeaderTestFactory.SERVICE_KONTO); + return service.buildSubCommands(COLLABORATION_REQUEST); } } @@ -407,13 +406,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(); @@ -477,7 +476,7 @@ class CollaborationServiceTest { } private OzgCloudCommand buildSendPostfachNachrichtCommand() { - return service.buildSendPostfachNachrichtCommand(COLLABORATION_REQUEST, SERVICE_KONTO); + return service.buildSendPostfachNachrichtCommand(COLLABORATION_REQUEST); } } @@ -488,32 +487,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); } }