refactor(ses): clean up what the controller split left behind (#3841)

Four leftovers from splitting SesController by domain, none of them changing
behavior.

SesInspectionController now injects SesSentEmailService and calls listAll and
clear on it. SesService.getEmails and clearEmails were one-line forwards to
that service, the last pure delegations the split missed, so they go; the
field comment and the class Javadoc that still claimed inspection read through
the facade are corrected. SesServiceTestBuilder gains a sentEmailService
accessor and SesServiceSmtpTest reads through it, matching how the other
domain services are reached from tests.

Three test classes are renamed to the service they actually drive:
SesServiceDkimLookupCacheTest and SesServiceLegacyDkimTokensTest become
SesIdentityDkimLookupCacheTest and SesIdentityLegacyDkimTokensTest, and
SesServiceSuppressionLegacyKeyTest becomes SesSuppressionLegacyKeyTest. None
of them was referenced from anywhere else.

SesSendController imports JsonProcessingException instead of writing it out
inline, and SesService drops six imports left unused by earlier steps.
This commit is contained in:
Kenshin Okinaka authored and GitHub committed 2026-09-18 06:59:25 -04:00
1 parent 18a2f36eda
commit 6e53c5275a
8 files changed
+32 -33

No files matched your search

@@ -21,7 +21,7 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
class SesServiceDkimLookupCacheTest {
class SesIdentityDkimLookupCacheTest {
private static final String REGION = "us-east-1";
private static final String DOMAIN = "example.com";
@@ -14,7 +14,7 @@ import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertTrue;
class SesServiceLegacyDkimTokensTest {
class SesIdentityLegacyDkimTokensTest {
private static final String REGION = "us-east-1";
@@ -23,6 +23,7 @@ class SesServiceSmtpTest {
private SesService service;
private SesConfigurationSetService configSets;
private SesSentEmailService sentEmails;
private InMemoryStorage<String, SentEmail> emailStore;
@BeforeEach
@@ -31,10 +32,11 @@ class SesServiceSmtpTest {
emailStore = builder.emailStore();
service = builder.build();
configSets = builder.configSetService();
sentEmails = builder.sentEmailService();
}
private SentEmail storedEmail(String messageId) {
return service.getEmails().stream()
return sentEmails.listAll().stream()
.filter(e -> messageId.equals(e.getMessageId()))
.findFirst()
.orElseThrow();
@@ -58,6 +58,7 @@ final class SesServiceTestBuilder {
private SesSuppressionService suppressionService;
private SesConfigurationSetService configSetService;
private SesIdentityService identityService;
private SesSentEmailService sentEmailService;
static SesServiceTestBuilder create() {
return new SesServiceTestBuilder();
@@ -134,6 +135,13 @@ final class SesServiceTestBuilder {
return configSetService;
}
SesSentEmailService sentEmailService() {
if (sentEmailService == null) {
throw new IllegalStateException("call build() first");
}
return sentEmailService;
}
SesIdentityService identityService() {
if (identityService == null) {
throw new IllegalStateException("call build() first");
@@ -147,9 +155,10 @@ final class SesServiceTestBuilder {
new InMemoryStorage<>());
configSetService = new SesConfigurationSetService(configSetStore);
identityService = new SesIdentityService(identityStore, route53Service, clock);
sentEmailService = new SesSentEmailService(emailStore);
return new SesService(
identityService,
new SesSentEmailService(emailStore),
sentEmailService,
new SesTemplateService(templateStore, objectMapper, new SecureRandom()),
configSetService,
suppressionService,
@@ -16,7 +16,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
* the legacy key, and PUT migrates it onto the canonical key. Only reachable by seeding
* the store directly (the HTTP API always normalizes), so it lives at the unit layer.
*/
class SesServiceSuppressionLegacyKeyTest {
class SesSuppressionLegacyKeyTest {
private static final String REGION = "us-east-1";
// A pre-canonicalization entry: trim-only key with an upper-case domain.