Make ResendEmailSender asynchronous

This commit is contained in:
Tim
2025-07-30 12:54:59 +08:00
parent 9347d423e2
commit 2a64e3ed14
4 changed files with 71 additions and 28 deletions

View File

@@ -4,6 +4,8 @@ import com.openisle.model.*;
import com.openisle.repository.NotificationRepository;
import com.openisle.repository.UserRepository;
import com.openisle.service.PushNotificationService;
import com.openisle.repository.ReactionRepository;
import java.util.concurrent.Executor;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
@@ -21,7 +23,9 @@ class NotificationServiceTest {
UserRepository uRepo = mock(UserRepository.class);
EmailSender email = mock(EmailSender.class);
PushNotificationService push = mock(PushNotificationService.class);
NotificationService service = new NotificationService(nRepo, uRepo, email, push);
ReactionRepository rRepo = mock(ReactionRepository.class);
Executor executor = Runnable::run;
NotificationService service = new NotificationService(nRepo, uRepo, email, push, rRepo, executor);
org.springframework.test.util.ReflectionTestUtils.setField(service, "websiteUrl", "https://ex.com");
User user = new User();
@@ -50,7 +54,9 @@ class NotificationServiceTest {
UserRepository uRepo = mock(UserRepository.class);
EmailSender email = mock(EmailSender.class);
PushNotificationService push = mock(PushNotificationService.class);
NotificationService service = new NotificationService(nRepo, uRepo, email, push);
ReactionRepository rRepo = mock(ReactionRepository.class);
Executor executor = Runnable::run;
NotificationService service = new NotificationService(nRepo, uRepo, email, push, rRepo, executor);
org.springframework.test.util.ReflectionTestUtils.setField(service, "websiteUrl", "https://ex.com");
User user = new User();
@@ -73,7 +79,9 @@ class NotificationServiceTest {
UserRepository uRepo = mock(UserRepository.class);
EmailSender email = mock(EmailSender.class);
PushNotificationService push = mock(PushNotificationService.class);
NotificationService service = new NotificationService(nRepo, uRepo, email, push);
ReactionRepository rRepo = mock(ReactionRepository.class);
Executor executor = Runnable::run;
NotificationService service = new NotificationService(nRepo, uRepo, email, push, rRepo, executor);
org.springframework.test.util.ReflectionTestUtils.setField(service, "websiteUrl", "https://ex.com");
User user = new User();
@@ -94,7 +102,9 @@ class NotificationServiceTest {
UserRepository uRepo = mock(UserRepository.class);
EmailSender email = mock(EmailSender.class);
PushNotificationService push = mock(PushNotificationService.class);
NotificationService service = new NotificationService(nRepo, uRepo, email, push);
ReactionRepository rRepo = mock(ReactionRepository.class);
Executor executor = Runnable::run;
NotificationService service = new NotificationService(nRepo, uRepo, email, push, rRepo, executor);
org.springframework.test.util.ReflectionTestUtils.setField(service, "websiteUrl", "https://ex.com");
User admin = new User();
@@ -116,7 +126,9 @@ class NotificationServiceTest {
UserRepository uRepo = mock(UserRepository.class);
EmailSender email = mock(EmailSender.class);
PushNotificationService push = mock(PushNotificationService.class);
NotificationService service = new NotificationService(nRepo, uRepo, email, push);
ReactionRepository rRepo = mock(ReactionRepository.class);
Executor executor = Runnable::run;
NotificationService service = new NotificationService(nRepo, uRepo, email, push, rRepo, executor);
org.springframework.test.util.ReflectionTestUtils.setField(service, "websiteUrl", "https://ex.com");
User admin = new User();
@@ -138,7 +150,9 @@ class NotificationServiceTest {
UserRepository uRepo = mock(UserRepository.class);
EmailSender email = mock(EmailSender.class);
PushNotificationService push = mock(PushNotificationService.class);
NotificationService service = new NotificationService(nRepo, uRepo, email, push);
ReactionRepository rRepo = mock(ReactionRepository.class);
Executor executor = Runnable::run;
NotificationService service = new NotificationService(nRepo, uRepo, email, push, rRepo, executor);
org.springframework.test.util.ReflectionTestUtils.setField(service, "websiteUrl", "https://ex.com");
User user = new User();