Skip to content

Commit b452c2b

Browse files
chrfwowtoddbaert
authored andcommitted
add test
Signed-off-by: christian.lutnik <christian.lutnik@dynatrace.com>
1 parent d504547 commit b452c2b

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

src/test/java/dev/openfeature/sdk/LayeredEvaluationContextTest.java

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -277,17 +277,31 @@ void nestedContextsAreUnwrappedCorrectly() {
277277
assertEquals(Map.of("outer", Map.of("inner", "client")), objectMap);
278278
}
279279

280+
@Test
281+
void nestedStructuresInContextsAreUnwrappedCorrectly() {
282+
var innerApiStructure = new ImmutableStructure(Map.of("inner", new Value("api")));
283+
var outerApiContext = new ImmutableContext(Map.of("outer", new Value(innerApiStructure)));
284+
285+
var innerClientStructure = new ImmutableStructure(Map.of("inner", new Value("client")));
286+
var outerClientContext = new ImmutableContext(Map.of("outer", new Value(innerClientStructure)));
287+
var layeredContext = new LayeredEvaluationContext(outerApiContext, null, outerClientContext, null);
288+
289+
var objectMap = layeredContext.asObjectMap();
290+
291+
assertEquals(Map.of("outer", Map.of("inner", "client")), objectMap);
292+
}
293+
280294
@Test
281295
void nestedHookContextsAreUnwrappedCorrectly() {
282-
var innerApiContext = new ImmutableContext(Map.of("inner", new Value("api")));
283-
var outerApiContext = new ImmutableContext(Map.of("outer", new Value(innerApiContext)));
296+
var innerApiStructure = new ImmutableStructure(Map.of("inner", new Value("api")));
297+
var outerApiContext = new ImmutableContext(Map.of("outer", new Value(innerApiStructure)));
284298

285-
var innerClientContext = new ImmutableContext(Map.of("inner", new Value("client")));
286-
var outerClientContext = new ImmutableContext(Map.of("outer", new Value(innerClientContext)));
299+
var innerClientStructure = new ImmutableStructure(Map.of("inner", new Value("client")));
300+
var outerClientContext = new ImmutableContext(Map.of("outer", new Value(innerClientStructure)));
287301
var layeredContext = new LayeredEvaluationContext(outerApiContext, null, outerClientContext, null);
288302

289-
var innerHookContext = new ImmutableContext(Map.of("inner", new Value("hook")));
290-
var outerHookContext = new ImmutableContext(Map.of("outer", new Value(innerHookContext)));
303+
var innerHookStructure = new ImmutableStructure(Map.of("inner", new Value("hook")));
304+
var outerHookContext = new ImmutableContext(Map.of("outer", new Value(innerHookStructure)));
291305

292306
layeredContext.putHookContext(outerHookContext);
293307

0 commit comments

Comments
 (0)