Skip to content
Snippets Groups Projects
Commit 38bb443a authored by OZGCloud's avatar OZGCloud
Browse files

Merge pull request 'OZG-6953 Bug: Kein Mail-Icon in Vorgangsliste nach dem...

Merge pull request 'OZG-6953 Bug: Kein Mail-Icon in Vorgangsliste nach dem Schicken einer Nachricht' (#36) from OZG-6953-Bug-Kein-Mail-Icon-in-Vorgangsliste-nach-dem-Schicken-einer-Nachricht into master

Reviewed-on: https://git.ozg-sh.de/ozgcloud-app/nachrichten-manager/pulls/36


Reviewed-by: default avatarOZGCloud <ozgcloud@mgm-tp.com>
parents d225eeb3 dcf7f5ee
No related branches found
No related tags found
No related merge requests found
......@@ -29,6 +29,7 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.function.Predicate;
import java.util.stream.Stream;
import jakarta.annotation.PostConstruct;
......@@ -41,6 +42,7 @@ import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import de.ozgcloud.nachrichten.antragraum.AntragraumService;
import de.ozgcloud.nachrichten.attributes.ClientAttributeService;
import de.ozgcloud.nachrichten.info.InfoManagerService;
import de.ozgcloud.nachrichten.postfach.PostfachNachricht.Direction;
import de.ozgcloud.nachrichten.postfach.PostfachNachricht.ReplyOption;
......@@ -56,6 +58,7 @@ class PostfachService {
static final Set<ReplyOption> REPLY_POSSIBLE_OPTION = EnumSet.of(ReplyOption.POSSIBLE, ReplyOption.MANDATORY);
private static final Set<String> POSTFACH_TYPES_WITH_ANTRAGSRAUM = Set.of("BAYERN_ID");
private static final Predicate<PostfachNachricht> IS_FROM_HUMAN_USER = nachricht -> !StringUtils.startsWith(nachricht.getCreatedBy(), "system");
@Autowired
private Optional<Collection<PostfachRemoteService>> postfachRemoteServices;
......@@ -67,6 +70,8 @@ class PostfachService {
private PersistPostfachNachrichtService persistingService;
@Autowired
private CurrentUserService userService;
@Autowired
private ClientAttributeService clientAttributeService;
@Autowired
private PostfachNachrichtMapper mapper;
......@@ -151,6 +156,9 @@ class PostfachService {
void persistPostfachNachricht(Optional<String> userId, PostfachNachricht mail) {
persistingService.persistNachricht(userId, mail);
if (IS_FROM_HUMAN_USER.test(mail)) {
clientAttributeService.setHasPostfachNachricht(mail.getVorgangId());
}
}
public void resendMail(String commandId, String postfachMailId) {
......
......@@ -53,6 +53,7 @@ import org.springframework.context.ApplicationEventPublisher;
import org.springframework.test.util.ReflectionTestUtils;
import de.ozgcloud.nachrichten.antragraum.AntragraumService;
import de.ozgcloud.nachrichten.attributes.ClientAttributeService;
import de.ozgcloud.nachrichten.info.InfoManagerService;
import de.ozgcloud.nachrichten.postfach.osi.MessageTestFactory;
import de.ozgcloud.nachrichten.postfach.osi.OsiPostfachServerProcessExceptionTestFactory;
......@@ -85,6 +86,8 @@ class PostfachServiceTest {
private Optional<AntragraumService> antragsraumService = Optional.of(mock(AntragraumService.class));
@Spy
private Optional<InfoManagerService> infomanagerService = Optional.of(mock(InfoManagerService.class));
@Mock
private ClientAttributeService clientAttributeService;
@Nested
class TestSaveDraft {
......@@ -1113,4 +1116,37 @@ class PostfachServiceTest {
}
}
@Nested
class TestPersistPostfachnachricht {
private static final PostfachNachricht POSTFACH_NACHRICHT = PostfachNachrichtTestFactory.create();
@Test
void shouldCallPersistNachricht() {
persistPostfachNachricht();
verify(persistingService).persistNachricht(Optional.of(USER_ID), POSTFACH_NACHRICHT);
}
@Test
void shouldSetClientAttribute() {
persistPostfachNachricht();
verify(clientAttributeService).setHasPostfachNachricht(MessageTestFactory.VORGANG_ID);
}
@Test
@DisplayName("should NOT set hasPostfachNachricht if Nachricht is sent from system")
void shouldNOTSetHasNachrichtForSystemNachricht() {
var mail = PostfachNachrichtTestFactory.createBuilder().createdBy("system-123").build();
service.persistPostfachNachricht(Optional.of(USER_ID), mail);
verify(clientAttributeService, never()).setHasPostfachNachricht(any());
}
private void persistPostfachNachricht() {
service.persistPostfachNachricht(Optional.of(USER_ID), POSTFACH_NACHRICHT);
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment