refactor(ses): move the tag dispatch helpers into their domain services (#3090)

* refactor(ses): move the tag dispatch helpers into their domain services

* docs(ses): move the stranded tenant-ARN comment onto ResourceRef
This commit is contained in:
Kenshin Okinaka authored and GitHub committed 2026-09-05 15:41:46 -04:00
1 parent 3c6c005ff1
commit 15b401032d
7 files changed
+175 -111

No files matched your search

@@ -3,6 +3,7 @@ package io.github.hectorvent.floci.services.ses;
import io.github.hectorvent.floci.core.common.AwsException;
import io.github.hectorvent.floci.core.storage.InMemoryStorage;
import io.github.hectorvent.floci.services.ses.model.ConfigurationSet;
import io.github.hectorvent.floci.services.ses.model.Tag;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -100,4 +101,22 @@ class SesConfigurationSetServiceTest {
assertFalse(SesConfigurationSetService.isValidName("bad name!"));
assertFalse(SesConfigurationSetService.isValidName(null));
}
@Test
void tagOps_lifecycle_notFoundMessage() {
service.create(cs("my-cs"), REGION);
service.tag("my-cs", REGION, List.of(new Tag("team", "floci"), new Tag("env", "dev")));
assertEquals(2, service.listTags("my-cs", REGION).size());
// Re-tagging an existing key replaces its value; untagging a missing key is a silent success.
service.tag("my-cs", REGION, List.of(new Tag("env", "prod")));
service.untag("my-cs", REGION, List.of("team", "ghost-key"));
List<Tag> tags = service.listTags("my-cs", REGION);
assertEquals(1, tags.size());
assertEquals("env", tags.get(0).key());
assertEquals("prod", tags.get(0).value());
AwsException e = assertThrows(AwsException.class, () -> service.listTags("ghost", REGION));
assertEquals("No ConfigurationSet present with name: ghost", e.getMessage());
}
}
@@ -114,4 +114,22 @@ class SesTemplateServiceTest {
assertEquals("team", reloaded.getTags().get(0).key());
assertEquals("ses", reloaded.getTags().get(0).value());
}
@Test
void tagOps_lifecycle_notFoundMessage() {
service.createTemplate(template("welcome"), REGION);
service.tag("welcome", REGION, List.of(new Tag("team", "floci"), new Tag("env", "dev")));
assertEquals(2, service.listTags("welcome", REGION).size());
// Re-tagging an existing key replaces its value; untagging a missing key is a silent success.
service.tag("welcome", REGION, List.of(new Tag("env", "prod")));
service.untag("welcome", REGION, List.of("team", "ghost-key"));
List<Tag> tags = service.listTags("welcome", REGION);
assertEquals(1, tags.size());
assertEquals("env", tags.get(0).key());
assertEquals("prod", tags.get(0).value());
AwsException e = assertThrows(AwsException.class, () -> service.listTags("ghost", REGION));
assertEquals("No Template present with name: ghost", e.getMessage());
}
}
@@ -199,6 +199,28 @@ class SesTenantServiceTest {
assertEquals("team", tags.get(0).key());
}
@Test
void tagOps_lifecycle_listSortedByKey_notFoundMessage() {
Tenant tenant = service.createTenant("acme", List.of(new Tag("team", "floci")), ACCOUNT, REGION);
String remainder = "acme/" + tenant.tenantId();
service.tag(remainder, REGION, List.of(new Tag("env", "dev")));
// Ordered by key: env before team (probe-confirmed).
assertEquals(List.of("env", "team"),
service.listTags(remainder, REGION).stream().map(Tag::key).toList());
// Re-tagging an existing key replaces its value; untagging a missing key is a silent success.
service.tag(remainder, REGION, List.of(new Tag("env", "prod")));
service.untag(remainder, REGION, List.of("team", "ghost-key"));
List<Tag> tags = service.listTags(remainder, REGION);
assertEquals(1, tags.size());
assertEquals("prod", tags.get(0).value());
assertEquals("No Tenant present with name: acmewith tenantId: tn-0000",
assertThrows(AwsException.class,
() -> service.listTags("acme/tn-0000", REGION)).getMessage());
}
// ──────────────────────── Resource associations (Phase 2) ────────────────────────
private static SesTenantService.AssociationResource identityRef(String name) {