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

OZG-3841 implement comments from code review

parent 6bbb43e6
No related branches found
No related tags found
No related merge requests found
......@@ -34,6 +34,7 @@ import org.springframework.stereotype.Service;
import de.itvsh.kop.notification.email.EmailRemoteService;
import de.itvsh.kop.notification.email.UserEmail;
import de.itvsh.kop.notification.vorgang.Vorgang;
import lombok.NonNull;
@Service
public class UserNotificationService {
......@@ -48,7 +49,7 @@ public class UserNotificationService {
private UserRemoteService userRemoteService;
@Async
public void sendNotification(Vorgang vorgang) {
public void sendNotification(@NonNull Vorgang vorgang) {
if (nonNull(vorgang.getOrganisationseinheitenId())) {
var recipients = userRemoteService.getRecipients(vorgang.getOrganisationseinheitenId());
emailRemoteService.sendEmail(buildUserEmail(recipients, MAIL_SUBJECT_TEMPLATE.formatted(vorgang.getVorgangName())));
......
......@@ -23,6 +23,7 @@
*/
package de.itvsh.kop.notification.user;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.*;
......@@ -88,7 +89,7 @@ class UserNotificationServiceTest {
void shouldSetSubject() {
service.sendNotification(VorgangTestFactory.create());
verify(service).buildUserEmail(anyList(), eq(UserNotificationService.MAIL_SUBJECT_TEMPLATE.formatted(VorgangTestFactory.VORGANG_NAME)));
verify(service).buildUserEmail(anyList(), eq("Neuer Vorgang: " + VorgangTestFactory.VORGANG_NAME));
}
}
......@@ -113,5 +114,12 @@ class UserNotificationServiceTest {
verify(emailRemoteService, never()).sendEmail(any(UserEmail.class));
}
}
@Test
void shouldThrowExceptionWhenVorgangNull() {
assertThatThrownBy(() -> service.sendNotification(null))
.withFailMessage("organisationsEinheitId cannot be null.")
.isInstanceOf(IllegalArgumentException.class);
}
}
}
\ 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