|
3 | 3 | import java.util.*;
|
4 | 4 |
|
5 | 5 | import dev.openfeature.sdk.fixtures.HookFixtures;
|
| 6 | + |
6 | 7 | import org.junit.jupiter.api.*;
|
7 | 8 | import org.mockito.Mockito;
|
8 | 9 | import org.simplify4u.slf4jmock.LoggerMock;
|
9 | 10 | import org.slf4j.Logger;
|
10 | 11 |
|
11 | 12 | import static org.assertj.core.api.Assertions.assertThat;
|
| 13 | +import static org.junit.jupiter.api.Assertions.assertEquals; |
| 14 | +import static org.mockito.ArgumentMatchers.any; |
| 15 | +import static org.mockito.ArgumentMatchers.anyString; |
| 16 | +import static org.mockito.ArgumentMatchers.argThat; |
| 17 | +import static org.mockito.ArgumentMatchers.eq; |
12 | 18 | import static org.mockito.Mockito.*;
|
13 | 19 |
|
14 | 20 | class OpenFeatureClientTest implements HookFixtures {
|
@@ -67,4 +73,28 @@ void mergeContextTest() {
|
67 | 73 |
|
68 | 74 | assertThat(result.getValue()).isTrue();
|
69 | 75 | }
|
| 76 | + |
| 77 | + @Test |
| 78 | + @DisplayName("addHooks should allow chaining by returning the same client instance") |
| 79 | + void addHooksShouldAllowChaining() { |
| 80 | + OpenFeatureAPI api = mock(OpenFeatureAPI.class); |
| 81 | + OpenFeatureClient client = new OpenFeatureClient(api, "name", "version"); |
| 82 | + Hook<?> hook1 = Mockito.mock(Hook.class); |
| 83 | + Hook<?> hook2 = Mockito.mock(Hook.class); |
| 84 | + |
| 85 | + OpenFeatureClient result = client.addHooks(hook1, hook2); |
| 86 | + assertEquals(client, result); |
| 87 | + } |
| 88 | + |
| 89 | + @Test |
| 90 | + @DisplayName("setEvaluationContext should allow chaining by returning the same client instance") |
| 91 | + void setEvaluationContextShouldAllowChaining() { |
| 92 | + OpenFeatureAPI api = mock(OpenFeatureAPI.class); |
| 93 | + OpenFeatureClient client = new OpenFeatureClient(api, "name", "version"); |
| 94 | + EvaluationContext ctx = new ImmutableContext("targeting key", new HashMap<>()); |
| 95 | + |
| 96 | + OpenFeatureClient result = client.setEvaluationContext(ctx); |
| 97 | + assertEquals(client, result); |
| 98 | + } |
| 99 | + |
70 | 100 | }
|
0 commit comments