From 2ccf672c00eb0cd524cd45cd271b537547540f56 Mon Sep 17 00:00:00 2001 From: Merethe Hansen Date: Thu, 26 Dec 2024 10:15:31 -0800 Subject: [PATCH] Bug fix: reminder service not using config (#8369) * fix ID reminders config * Turn on reminder property for tests --- .../usds/simplereport/service/ReminderService.java | 12 +++++++++--- .../simplereport/service/ReminderServiceTest.java | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/backend/src/main/java/gov/cdc/usds/simplereport/service/ReminderService.java b/backend/src/main/java/gov/cdc/usds/simplereport/service/ReminderService.java index 6de413c167..cf7745bc78 100644 --- a/backend/src/main/java/gov/cdc/usds/simplereport/service/ReminderService.java +++ b/backend/src/main/java/gov/cdc/usds/simplereport/service/ReminderService.java @@ -15,7 +15,7 @@ import java.util.TimeZone; import lombok.extern.slf4j.Slf4j; import net.javacrumbs.shedlock.spring.annotation.SchedulerLock; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.beans.factory.annotation.Value; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -28,6 +28,9 @@ public class ReminderService { private final OrganizationQueueRepository _orgQueueRepo; private final EmailService _emailService; + @Value("${simple-report.id-verification-reminders.enabled}") + private boolean remindersEnabled; + public ReminderService(OrganizationQueueRepository orgQueueRepo, EmailService emailService) { _orgQueueRepo = orgQueueRepo; _emailService = emailService; @@ -42,9 +45,12 @@ public ReminderService(OrganizationQueueRepository orgQueueRepo, EmailService em name = "ReminderService_sendAccountReminderEmails", lockAtLeastFor = "PT30S", lockAtMostFor = "PT30M") - @ConditionalOnProperty("simple-report.id-verification-reminders.enabled") public void scheduledSendAccountReminderEmails() { - sendAccountReminderEmails(); + if (remindersEnabled) { + sendAccountReminderEmails(); + } else { + log.info("Skipping sending ID verification reminder emails"); + } } /* diff --git a/backend/src/test/java/gov/cdc/usds/simplereport/service/ReminderServiceTest.java b/backend/src/test/java/gov/cdc/usds/simplereport/service/ReminderServiceTest.java index 5363c7fdff..da1a066881 100644 --- a/backend/src/test/java/gov/cdc/usds/simplereport/service/ReminderServiceTest.java +++ b/backend/src/test/java/gov/cdc/usds/simplereport/service/ReminderServiceTest.java @@ -24,8 +24,10 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.test.context.TestPropertySource; import org.springframework.transaction.annotation.Transactional; +@TestPropertySource(properties = {"simple-report.id-verification-reminders.enabled=true"}) class ReminderServiceTest extends BaseServiceTest { @Autowired private JdbcTemplate _jdbc;