forked from open-feature/java-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: issue open-feature#859 Added failing tests
- Loading branch information
1 parent
e1e15f4
commit 7fc10c2
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package dev.openfeature.sdk; | ||
|
||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
|
||
import static dev.openfeature.sdk.EvaluationContext.TARGETING_KEY; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class MutableContextTest { | ||
@DisplayName("attributes unable to allow mutation should not affect the Mutable context") | ||
@Test | ||
void shouldNotAttemptToModifyAttributesForMutableContext() { | ||
final Map<String, Value> attributes = new HashMap<>(); | ||
attributes.put("key1", new Value("val1")); | ||
attributes.put("key2", new Value("val2")); | ||
// should check the usage of Map.of() which is a more likely use case, but that API isn't available in Java 8 | ||
EvaluationContext ctx = new MutableContext("targeting key", Collections.unmodifiableMap(attributes)); | ||
attributes.put("key3", new Value("val3")); | ||
assertArrayEquals(new Object[]{"key1", "key2", TARGETING_KEY}, ctx.keySet().toArray()); | ||
} | ||
} |