refactor(cloudformation): hoist resolveOrDefault onto ProvisionContext (#4049)

Seven per-service provisioners (Lambda, StepFunctions, ElbV2, Events, ApiGatewayRestApi, ApiGatewayV2, Cognito) each carried an identical private resolveOrDefault helper, differing only in argument order. Move it to ProvisionContext as an instance method next to resolveOptional and rewrite the 15 call sites to ctx.resolveOrDefault(props, name, default), removing the copies. Behavior is unchanged: the bodies were byte-identical (resolveOptional plus a non-blank fallback).

The monolith's own resolveOrDefault(props, name, engine, default) is left alone: it takes a raw engine rather than a ProvisionContext, is already dead (no callers), and belongs to the later dispatcher-retirement cleanup.

Refs #3885
This commit is contained in:
Hector Ventura authored and GitHub committed 2026-09-20 23:29:08 -04:00
1 parent 3976f2bd05
commit f9d1b8101c
9 files changed
+36 -48

No files matched your search

@@ -69,6 +69,17 @@ class ProvisionContextTest {
assertNull(ctx.priorPhysicalId());
}
@Test
void resolveOrDefaultReturnsTheValueOtherwiseTheDefault() {
ProvisionContext ctx = context(null);
assertEquals("HTTP", ctx.resolveOrDefault(props("{\"ProtocolType\":\"HTTP\"}"), "ProtocolType", "WEBSOCKET"));
assertEquals("WEBSOCKET", ctx.resolveOrDefault(props("{}"), "ProtocolType", "WEBSOCKET"), "absent falls back");
assertEquals("WEBSOCKET", ctx.resolveOrDefault(props("{\"ProtocolType\":\"\"}"), "ProtocolType", "WEBSOCKET"),
"blank falls back");
assertEquals("WEBSOCKET", ctx.resolveOrDefault(null, "ProtocolType", "WEBSOCKET"), "null props falls back");
}
@Test
void stablePhysicalNamePrefersTheTemplatesName() {
assertEquals("chosen",