forked from open-feature/java-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMutableStructureTest.java
67 lines (56 loc) · 1.77 KB
/
MutableStructureTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package dev.openfeature.sdk;
import static org.junit.jupiter.api.Assertions.*;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.junit.jupiter.api.Test;
class MutableStructureTest {
@Test
void emptyMutableStructureIsEmpty() {
MutableStructure m1 = new MutableStructure();
assertTrue(m1.isEmpty());
}
@Test
void mutableStructureWithNullBackingStructureIsEmpty() {
MutableStructure m1 = new MutableStructure(null);
assertTrue(m1.isEmpty());
}
@Test
void unequalMutableStructuresAreNotEqual() {
MutableStructure m1 = new MutableStructure();
m1.add("key1", "val1");
MutableStructure m2 = new MutableStructure();
m2.add("key2", "val2");
assertNotEquals(m1, m2);
}
@Test
void equalMutableStructuresAreEqual() {
MutableStructure m1 = new MutableStructure();
m1.add("key1", "val1");
MutableStructure m2 = new MutableStructure();
m2.add("key1", "val1");
assertEquals(m1, m2);
}
@Test
void equalAbstractStructuresOfDifferentTypesAreNotEqual() {
MutableStructure m1 = new MutableStructure();
m1.add("key1", "val1");
HashMap<String, Value> map = new HashMap<>();
map.put("key1", new Value("val1"));
AbstractStructure m2 = new AbstractStructure(map) {
@Override
public Set<String> keySet() {
return attributes.keySet();
}
@Override
public Value getValue(String key) {
return attributes.get(key);
}
@Override
public Map<String, Value> asMap() {
return attributes;
}
};
assertNotEquals(m1, m2);
}
}