Skip to content
Snippets Groups Projects
Commit 1093f583 authored by OZGCloud's avatar OZGCloud
Browse files

OZG-6180 set reply option forbidden for bayernId only

parent 69efeacd
Branches
Tags
No related merge requests found
...@@ -46,6 +46,7 @@ class BescheidService { ...@@ -46,6 +46,7 @@ class BescheidService {
static final String VORGANG_BESCHEIDEN_ORDER = "VORGANG_BESCHEIDEN"; static final String VORGANG_BESCHEIDEN_ORDER = "VORGANG_BESCHEIDEN";
static final String SUBCOMMANDS_EXECUTION_MODE = "PARALLEL"; static final String SUBCOMMANDS_EXECUTION_MODE = "PARALLEL";
static final String SEND_POSTFACH_NACHRICHT_ORDER = "SEND_POSTFACH_NACHRICHT"; static final String SEND_POSTFACH_NACHRICHT_ORDER = "SEND_POSTFACH_NACHRICHT";
static final String BAYERN_ID_SERVICE_KONTO_TYPE = "BayernId";
private final VorgangService vorgangService; private final VorgangService vorgangService;
private final AttachedItemService attachedItemService; private final AttachedItemService attachedItemService;
...@@ -210,12 +211,18 @@ class BescheidService { ...@@ -210,12 +211,18 @@ class BescheidService {
Map<String, Object> buildSendNachrichtCommandBody(AttachedItem bescheidItem, Map<String, Object> postfachAddress) { Map<String, Object> buildSendNachrichtCommandBody(AttachedItem bescheidItem, Map<String, Object> postfachAddress) {
return Map.of( return Map.of(
NachrichtService.FIELD_REPLY_OPTION, NachrichtService.REPLY_OPTION, NachrichtService.FIELD_REPLY_OPTION, getReplyOption(postfachAddress),
NachrichtService.FIELD_SUBJECT, getNachrichtSubject(bescheidItem).orElse(NachrichtService.SUBJECT), NachrichtService.FIELD_SUBJECT, getNachrichtSubject(bescheidItem).orElse(NachrichtService.SUBJECT),
NachrichtService.FIELD_MAIL_BODY, getNachrichtText(bescheidItem).orElse(StringUtils.EMPTY), NachrichtService.FIELD_MAIL_BODY, getNachrichtText(bescheidItem).orElse(StringUtils.EMPTY),
NachrichtService.FIELD_ATTACHMENTS, buildAttachments(bescheidItem), NachrichtService.FIELD_ATTACHMENTS, buildAttachments(bescheidItem),
Vorgang.ServiceKonto.FIELD_POSTFACH_ADDRESS, postfachAddress); Vorgang.ServiceKonto.FIELD_POSTFACH_ADDRESS, postfachAddress);
}
String getReplyOption(Map<String, Object> postfachAddress) {
var serviceKontoType = MapUtils.getString(postfachAddress, Vorgang.ServiceKonto.FIELD_SERVICEKONTO_TYPE);
return StringUtils.equalsIgnoreCase(serviceKontoType, BAYERN_ID_SERVICE_KONTO_TYPE)
? NachrichtService.REPLY_OPTION_BAYERN_ID
: NachrichtService.REPLY_OPTION;
} }
List<String> buildAttachments(AttachedItem bescheidItem) { List<String> buildAttachments(AttachedItem bescheidItem) {
......
...@@ -20,7 +20,8 @@ public class NachrichtService { ...@@ -20,7 +20,8 @@ public class NachrichtService {
public static final String FIELD_POSTFACH_ID = "postfachId"; public static final String FIELD_POSTFACH_ID = "postfachId";
public static final String FIELD_REPLY_OPTION = "replyOption"; public static final String FIELD_REPLY_OPTION = "replyOption";
public static final String REPLY_OPTION = "FORBIDDEN"; public static final String REPLY_OPTION = "POSSIBLE";
public static final String REPLY_OPTION_BAYERN_ID = "FORBIDDEN";
public static final String FIELD_SUBJECT = "subject"; public static final String FIELD_SUBJECT = "subject";
public static final String FIELD_MAIL_BODY = "mailBody"; public static final String FIELD_MAIL_BODY = "mailBody";
public static final String FIELD_ATTACHMENTS = "attachments"; public static final String FIELD_ATTACHMENTS = "attachments";
......
...@@ -952,13 +952,13 @@ class BescheidServiceTest { ...@@ -952,13 +952,13 @@ class BescheidServiceTest {
@Nested @Nested
class TestBuildSendNachrichtCommandBody { class TestBuildSendNachrichtCommandBody {
private static final Map<String, Object> SERVICE_KONTO_MAP = Map.of("key", "value"); private static final Map<String, Object> POSTFACH_ADDRESS_MAP = Map.of("key", "value");
@Mock @Mock
private AttachedItem bescheidItem; private AttachedItem bescheidItem;
private Map<String, Object> buildSendNachrichtCommandBody() { private Map<String, Object> buildSendNachrichtCommandBody() {
return service.buildSendNachrichtCommandBody(bescheidItem, SERVICE_KONTO_MAP); return service.buildSendNachrichtCommandBody(bescheidItem, POSTFACH_ADDRESS_MAP);
} }
@Nested @Nested
...@@ -971,11 +971,21 @@ class BescheidServiceTest { ...@@ -971,11 +971,21 @@ class BescheidServiceTest {
doReturn(List.of(AttachedItemTestFactory.ATTACHMENT)).when(service).buildAttachments(any()); doReturn(List.of(AttachedItemTestFactory.ATTACHMENT)).when(service).buildAttachments(any());
} }
@Test
void shouldCallGetReplyOption() {
buildSendNachrichtCommandBody();
verify(service).getReplyOption(POSTFACH_ADDRESS_MAP);
}
@Test @Test
void shouldSetReplyOption() { void shouldSetReplyOption() {
var replayOption = "replay-option";
doReturn(replayOption).when(service).getReplyOption(any());
var result = buildSendNachrichtCommandBody(); var result = buildSendNachrichtCommandBody();
assertThat(result).containsEntry(NachrichtService.FIELD_REPLY_OPTION, NachrichtService.REPLY_OPTION); assertThat(result).containsEntry(NachrichtService.FIELD_REPLY_OPTION, replayOption);
} }
@Test @Test
...@@ -1024,7 +1034,7 @@ class BescheidServiceTest { ...@@ -1024,7 +1034,7 @@ class BescheidServiceTest {
void shouldSetPostfachAddress() { void shouldSetPostfachAddress() {
var result = buildSendNachrichtCommandBody(); var result = buildSendNachrichtCommandBody();
assertThat(result).containsEntry(Vorgang.ServiceKonto.FIELD_POSTFACH_ADDRESS, SERVICE_KONTO_MAP); assertThat(result).containsEntry(Vorgang.ServiceKonto.FIELD_POSTFACH_ADDRESS, POSTFACH_ADDRESS_MAP);
} }
} }
...@@ -1054,6 +1064,24 @@ class BescheidServiceTest { ...@@ -1054,6 +1064,24 @@ class BescheidServiceTest {
} }
} }
@Nested
class TestGetReplyOption {
@Test
void shouldReturnReplyOption() {
var result = service.getReplyOption(Map.of(Vorgang.ServiceKonto.FIELD_SERVICEKONTO_TYPE, "servicekonto-type"));
assertThat(result).isEqualTo(NachrichtService.REPLY_OPTION);
}
@Test
void shouldReturnDefault() {
var result = service.getReplyOption(Map.of(Vorgang.ServiceKonto.FIELD_SERVICEKONTO_TYPE, BescheidService.BAYERN_ID_SERVICE_KONTO_TYPE));
assertThat(result).isEqualTo(NachrichtService.REPLY_OPTION_BAYERN_ID);
}
}
@Nested @Nested
class TestBuildAttachments { class TestBuildAttachments {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment