|
1 | 1 | package dev.openfeature.sdk;
|
2 | 2 |
|
3 |
| -import static org.junit.jupiter.api.Assertions.*; |
| 3 | +import static org.junit.jupiter.api.Assertions.assertArrayEquals; |
| 4 | +import static org.junit.jupiter.api.Assertions.assertEquals; |
| 5 | +import static org.junit.jupiter.api.Assertions.assertNotEquals; |
| 6 | +import static org.junit.jupiter.api.Assertions.assertNotSame; |
| 7 | +import static org.junit.jupiter.api.Assertions.assertNull; |
| 8 | +import static org.junit.jupiter.api.Assertions.assertTrue; |
4 | 9 |
|
5 | 10 | import java.time.Instant;
|
6 | 11 | import java.time.temporal.ChronoUnit;
|
@@ -154,4 +159,42 @@ void constructorHandlesNullValue() {
|
154 | 159 | attrs.put("null", null);
|
155 | 160 | new ImmutableStructure(attrs);
|
156 | 161 | }
|
| 162 | + |
| 163 | + @Test |
| 164 | + void unequalImmutableStructuresAreNotEqual() { |
| 165 | + Map<String, Value> attrs1 = new HashMap<>(); |
| 166 | + attrs1.put("test", new Value(45)); |
| 167 | + ImmutableStructure structure1 = new ImmutableStructure(attrs1); |
| 168 | + |
| 169 | + Map<String, Value> attrs2 = new HashMap<>(); |
| 170 | + attrs2.put("test", new Value(2)); |
| 171 | + ImmutableStructure structure2 = new ImmutableStructure(attrs2); |
| 172 | + |
| 173 | + assertNotEquals(structure1, structure2); |
| 174 | + } |
| 175 | + |
| 176 | + @Test |
| 177 | + void equalImmutableStructuresAreEqual() { |
| 178 | + Map<String, Value> attrs1 = new HashMap<>(); |
| 179 | + attrs1.put("test", new Value(45)); |
| 180 | + ImmutableStructure structure1 = new ImmutableStructure(attrs1); |
| 181 | + |
| 182 | + Map<String, Value> attrs2 = new HashMap<>(); |
| 183 | + attrs2.put("test", new Value(45)); |
| 184 | + ImmutableStructure structure2 = new ImmutableStructure(attrs2); |
| 185 | + |
| 186 | + assertEquals(structure1, structure2); |
| 187 | + } |
| 188 | + |
| 189 | + @Test |
| 190 | + void emptyImmutableStructureIsEmpty() { |
| 191 | + ImmutableStructure m1 = new ImmutableStructure(); |
| 192 | + assertTrue(m1.isEmpty()); |
| 193 | + } |
| 194 | + |
| 195 | + @Test |
| 196 | + void immutableStructureWithNullAttributesIsEmpty() { |
| 197 | + ImmutableStructure m1 = new ImmutableStructure(null); |
| 198 | + assertTrue(m1.isEmpty()); |
| 199 | + } |
157 | 200 | }
|
0 commit comments