mirror of
https://github.com/floci-io/floci.git
synced 2026-11-29 00:21:51 -05:00
refactor(ses): keep single-caller SesV2Json member helpers private (#5932)
parseSuppressedReasons moves into SesConfigurationSetController, its only caller. structureMemberOrAbsent and typedStringMemberOrAbsent are now used only by stringMapMemberOrAbsent, so they become private and their unit tests go through that method instead. The dropped unit test was the only check that an explicit null SuppressedReasons clears the override, so that case moves to an integration test. No behaviour change.
This commit is contained in:
1 parent
8db159761c
commit
83bc2bd2bf
4 files changed
+61
-49
No files matched your search
+24
@@ -202,6 +202,30 @@ class SesConfigurationSetSuppressionOptionsV2IntegrationTest {
|
||||
.body("SuppressionOptions.SuppressedReasons", empty());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(11)
|
||||
void putSuppressionOptions_nullSuppressedReasons_treatedAsEmptyList() {
|
||||
// Start from a non-empty override so an ignored null would leave BOUNCE behind.
|
||||
configSetService.putSuppressionOptions(CS, List.of("BOUNCE"), REGION);
|
||||
|
||||
given()
|
||||
.contentType("application/json")
|
||||
.header("Authorization", AUTH)
|
||||
.body("{\"SuppressedReasons\":null}")
|
||||
.when()
|
||||
.put("/v2/email/configuration-sets/" + CS + "/suppression-options")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
|
||||
given()
|
||||
.header("Authorization", AUTH)
|
||||
.when()
|
||||
.get("/v2/email/configuration-sets/" + CS)
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("SuppressionOptions.SuppressedReasons", empty());
|
||||
}
|
||||
|
||||
// ─── getEffectiveSuppressedReasons helper (forward-looking integration with #1109) ───
|
||||
|
||||
@Test
|
||||
|
||||
@@ -9,8 +9,9 @@ import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.function.Executable;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
@@ -165,35 +166,34 @@ class SesV2JsonTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void structureMemberOrAbsent_rejectsANonObjectTheWayAwsDoes() {
|
||||
JsonNode node = json("{\"o\":{},\"n\":null,\"a\":[],\"s\":\"x\",\"i\":1}");
|
||||
assertTrue(SesV2Json.structureMemberOrAbsent(node, "o").isObject());
|
||||
assertTrue(SesV2Json.structureMemberOrAbsent(node, "n").isNull());
|
||||
assertTrue(SesV2Json.structureMemberOrAbsent(node, "missing").isMissingNode());
|
||||
void stringMapMemberOrAbsent_rejectsANonObjectTheWayAwsDoes() {
|
||||
JsonNode node = json("{\"n\":null,\"a\":[],\"s\":\"x\",\"i\":1}");
|
||||
assertNull(SesV2Json.stringMapMemberOrAbsent(node, "n"));
|
||||
assertNull(SesV2Json.stringMapMemberOrAbsent(node, "missing"));
|
||||
assertEquals("Start of list found where not expected", assertAws("SerializationException", 400,
|
||||
() -> SesV2Json.structureMemberOrAbsent(node, "a")).getMessage());
|
||||
() -> SesV2Json.stringMapMemberOrAbsent(node, "a")).getMessage());
|
||||
assertEquals("Expected null", assertAws("SerializationException", 400,
|
||||
() -> SesV2Json.structureMemberOrAbsent(node, "s")).getMessage());
|
||||
() -> SesV2Json.stringMapMemberOrAbsent(node, "s")).getMessage());
|
||||
assertEquals("Expected null", assertAws("SerializationException", 400,
|
||||
() -> SesV2Json.structureMemberOrAbsent(node, "i")).getMessage());
|
||||
() -> SesV2Json.stringMapMemberOrAbsent(node, "i")).getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void typedStringMemberOrAbsent_namesTheWrongType() {
|
||||
JsonNode node = json("{\"s\":\"x\",\"n\":null,\"i\":1,\"t\":true,\"f\":false,\"o\":{},\"a\":[]}");
|
||||
assertEquals("x", SesV2Json.typedStringMemberOrAbsent(node, "s"));
|
||||
assertNull(SesV2Json.typedStringMemberOrAbsent(node, "n"));
|
||||
assertNull(SesV2Json.typedStringMemberOrAbsent(node, "missing"));
|
||||
void stringMapMemberOrAbsent_keepsNullValues_andNamesTheWrongValueType() {
|
||||
Map<String, String> expected = new LinkedHashMap<>();
|
||||
expected.put("s", "x");
|
||||
expected.put("n", null);
|
||||
assertEquals(expected, SesV2Json.stringMapMemberOrAbsent(json("{\"m\":{\"s\":\"x\",\"n\":null}}"), "m"));
|
||||
assertEquals("NUMBER_VALUE can not be converted to a String", assertAws("SerializationException", 400,
|
||||
() -> SesV2Json.typedStringMemberOrAbsent(node, "i")).getMessage());
|
||||
() -> SesV2Json.stringMapMemberOrAbsent(json("{\"m\":{\"i\":1}}"), "m")).getMessage());
|
||||
assertEquals("TRUE_VALUE can not be converted to a String", assertAws("SerializationException", 400,
|
||||
() -> SesV2Json.typedStringMemberOrAbsent(node, "t")).getMessage());
|
||||
() -> SesV2Json.stringMapMemberOrAbsent(json("{\"m\":{\"t\":true}}"), "m")).getMessage());
|
||||
assertEquals("FALSE_VALUE can not be converted to a String", assertAws("SerializationException", 400,
|
||||
() -> SesV2Json.typedStringMemberOrAbsent(node, "f")).getMessage());
|
||||
() -> SesV2Json.stringMapMemberOrAbsent(json("{\"m\":{\"f\":false}}"), "m")).getMessage());
|
||||
assertEquals("Start of structure or map found where not expected.", assertAws("SerializationException",
|
||||
400, () -> SesV2Json.typedStringMemberOrAbsent(node, "o")).getMessage());
|
||||
400, () -> SesV2Json.stringMapMemberOrAbsent(json("{\"m\":{\"o\":{}}}"), "m")).getMessage());
|
||||
assertEquals("Start of list found where not expected", assertAws("SerializationException", 400,
|
||||
() -> SesV2Json.typedStringMemberOrAbsent(node, "a")).getMessage());
|
||||
() -> SesV2Json.stringMapMemberOrAbsent(json("{\"m\":{\"a\":[]}}"), "m")).getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -248,18 +248,6 @@ class SesV2JsonTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void parseSuppressedReasons_absentIsEmpty_keepsNullElements() {
|
||||
assertEquals(List.of(),
|
||||
SesV2Json.parseSuppressedReasons(json("{}").path("SuppressedReasons")));
|
||||
assertEquals(List.of(), SesV2Json.parseSuppressedReasons(json("null")));
|
||||
assertEquals(List.of("BOUNCE", "COMPLAINT"),
|
||||
SesV2Json.parseSuppressedReasons(json("[\"BOUNCE\",\"COMPLAINT\"]")));
|
||||
// A null element passes deserialization and is left to the service-layer value check.
|
||||
assertEquals(Arrays.asList("BOUNCE", null),
|
||||
SesV2Json.parseSuppressedReasons(json("[\"BOUNCE\",null]")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void coerceBooleanOrFalse_missingIsFalse_otherwiseCoerces() {
|
||||
assertFalse(SesV2Json.coerceBooleanOrFalse(json("{}").path("SendingEnabled")));
|
||||
|
||||
Reference in new issue
Block a user