|
1 | 1 | package dev.openfeature.javasdk;
|
2 | 2 |
|
| 3 | +import com.fasterxml.jackson.core.JsonProcessingException; |
| 4 | +import com.fasterxml.jackson.databind.ObjectMapper; |
3 | 5 | import org.junit.jupiter.api.Test;
|
4 | 6 |
|
5 | 7 | import java.time.ZonedDateTime;
|
|
8 | 10 | import static org.junit.jupiter.api.Assertions.assertEquals;
|
9 | 11 | import static org.junit.jupiter.api.Assertions.assertFalse;
|
10 | 12 | import static org.junit.jupiter.api.Assertions.assertTrue;
|
| 13 | +import static org.junit.jupiter.api.Assertions.fail; |
11 | 14 |
|
12 | 15 | public class EvalContextTest {
|
13 | 16 | @Specification(number="3.1.1",
|
@@ -88,18 +91,22 @@ public class EvalContextTest {
|
88 | 91 | ec.addStructureAttribute("obj", n2);
|
89 | 92 |
|
90 | 93 | Map<String, String> foundStr = ec.getStringAttributes();
|
91 |
| - assertEquals("test", foundStr.get("str")); |
92 |
| - assertEquals("test2", foundStr.get("str2")); |
| 94 | + assertEquals(ec.getStringAttribute("str"), foundStr.get("str")); |
| 95 | + assertEquals(ec.getStringAttribute("str2"), foundStr.get("str2")); |
93 | 96 |
|
94 | 97 | Map<String, Boolean> foundBool = ec.getBooleanAttributes();
|
95 |
| - assertTrue(foundBool.get("bool")); |
96 |
| - assertFalse(foundBool.get("bool2")); |
| 98 | + assertEquals(ec.getBooleanAttribute("bool"), foundBool.get("bool")); |
| 99 | + assertEquals(ec.getBooleanAttribute("bool2"), foundBool.get("bool2")); |
97 | 100 |
|
98 | 101 | Map<String, Integer> foundInt = ec.getIntegerAttributes();
|
99 |
| - assertEquals(4, foundInt.get("int")); |
100 |
| - assertEquals(2, foundInt.get("int2")); |
| 102 | + assertEquals(ec.getIntegerAttribute("int"), foundInt.get("int")); |
| 103 | + assertEquals(ec.getIntegerAttribute("int2"), foundInt.get("int2")); |
101 | 104 |
|
102 | 105 | Map<String, String> foundObj = ec.getStructureAttributes();
|
103 |
| - assertEquals("{\"left\":{\"left\":null,\"right\":null,\"value\":4},\"right\":null,\"value\":2}", foundObj.get("obj")); |
| 106 | + try { |
| 107 | + assertEquals(ec.getStructureAttribute("obj", Node.class), new ObjectMapper().readValue(foundObj.get("obj"), Node.class)); |
| 108 | + } catch (JsonProcessingException e) { |
| 109 | + fail("Unexpected exception occurred: ", e); |
| 110 | + } |
104 | 111 | }
|
105 | 112 | }
|
0 commit comments