Skip to content

Commit a7c2ef6

Browse files
check get all against get single
Signed-off-by: Robert Grassian <robert.grassian@split.io>
1 parent a60d530 commit a7c2ef6

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/test/java/dev/openfeature/javasdk/EvalContextTest.java

+14-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package dev.openfeature.javasdk;
22

3+
import com.fasterxml.jackson.core.JsonProcessingException;
4+
import com.fasterxml.jackson.databind.ObjectMapper;
35
import org.junit.jupiter.api.Test;
46

57
import java.time.ZonedDateTime;
@@ -8,6 +10,7 @@
810
import static org.junit.jupiter.api.Assertions.assertEquals;
911
import static org.junit.jupiter.api.Assertions.assertFalse;
1012
import static org.junit.jupiter.api.Assertions.assertTrue;
13+
import static org.junit.jupiter.api.Assertions.fail;
1114

1215
public class EvalContextTest {
1316
@Specification(number="3.1.1",
@@ -88,18 +91,22 @@ public class EvalContextTest {
8891
ec.addStructureAttribute("obj", n2);
8992

9093
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"));
9396

9497
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"));
97100

98101
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"));
101104

102105
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+
}
104111
}
105112
}

0 commit comments

Comments
 (0)