Skip to content
Snippets Groups Projects
Commit 97ec4b1d authored by OZGCloud's avatar OZGCloud
Browse files

Merge branch 'master' into OZG-7131-Erweiterung-muk-Nachricht

# Conflicts:
#	collaboration-manager-server/src/main/java/de/ozgcloud/collaboration/CollaborationService.java
parents b1851bff 039d5d9e
Branches
Tags
No related merge requests found
......@@ -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) {
......
......@@ -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;
......
......@@ -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);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment