|
28 | 28 | import static org.mockito.Mockito.verify; |
29 | 29 |
|
30 | 30 | @SpringBootTest(properties = { |
31 | | - "aboutbits.emailservice.scheduling.batch-size=5", |
32 | 31 | "aboutbits.emailservice.scheduling.max-attempts=3", |
33 | 32 | "aboutbits.emailservice.scheduling.stuck-sending-recovery-threshold=PT5M", |
34 | 33 | "aboutbits.emailservice.scheduling.interval=30000" |
35 | 34 | }) |
36 | 35 | @WithPostgres |
37 | 36 | @NullMarked |
38 | 37 | class SendScheduledEmailsTest { |
39 | | - private static final int BATCH_SIZE = 5; |
40 | 38 | private static final int MAX_ATTEMPTS = 3; |
41 | 39 | private static final int SCHEDULER_INTERVAL_SECONDS = 30; |
42 | 40 |
|
@@ -69,19 +67,6 @@ void givenPendingEmails_sendEmails_shouldMarkAllAsSent() { |
69 | 67 | verify(javaMailSender, times(3)).send(any(MimeMessage.class)); |
70 | 68 | } |
71 | 69 |
|
72 | | - @Test |
73 | | - void givenMoreEmailsThanBatchSize_sendEmails_shouldProcessOnlyBatchSizePerPass() { |
74 | | - var pending = 3 * BATCH_SIZE; |
75 | | - emailRepository.saveAll(IntStream.range(0, pending).mapToObj(_ -> EmailFactory.once().build()).toList()); |
76 | | - |
77 | | - sendScheduledEmails.sendEmails(); |
78 | | - |
79 | | - assertThat(emailRepository.findAll()) |
80 | | - .filteredOn(email -> email.getState() == EmailState.SENT) |
81 | | - .hasSize(BATCH_SIZE); |
82 | | - verify(javaMailSender, times(BATCH_SIZE)).send(any(MimeMessage.class)); |
83 | | - } |
84 | | - |
85 | 70 | @Test |
86 | 71 | void givenRetryableFailure_sendEmails_shouldRescheduleWithBackoffAndIncrementAttempts() { |
87 | 72 | doThrow(new MailSendException("smtp blip")).when(javaMailSender).send(any(MimeMessage.class)); |
|
0 commit comments