Skip to content

Commit 8bdba67

Browse files
committed
No op provider isn't generic. Has tests
1 parent 69f6498 commit 8bdba67

File tree

3 files changed

+31
-5
lines changed

3 files changed

+31
-5
lines changed

lib/src/main/java/javasdk/NoOpProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import lombok.Getter;
44

5-
public class NoOpProvider<T extends EvaluationContext> implements FeatureProvider {
5+
public class NoOpProvider implements FeatureProvider {
66
@Getter
77
private final String name = "No-op Provider";
88

lib/src/test/java/javasdk/HookSpecTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ void emptyApiHooks() {
165165
doThrow(RuntimeException.class).when(h).finallyAfter(any(), any());
166166

167167
OpenFeatureAPI api = OpenFeatureAPI.getInstance();
168-
api.setProvider(new NoOpProvider<>());
168+
api.setProvider(new NoOpProvider());
169169
Client c= api.getClient();
170170

171171
assertThrows(RuntimeException.class, () -> c.getBooleanValue("key", false, null, FlagEvaluationOptions.builder().hook(h).build()));
@@ -292,7 +292,7 @@ void finallyAfter(HookContext<Boolean> ctx, ImmutableMap<String, Object> hints)
292292
@Specification(spec="hooks", number="6.1", text="HookHints MUST passed between each hook.")
293293
@Test void hook_hints() {
294294
OpenFeatureAPI api = OpenFeatureAPI.getInstance();
295-
api.setProvider(new NoOpProvider<>());
295+
api.setProvider(new NoOpProvider());
296296
Client client = api.getClient();
297297
Hook<Boolean> mutatingHook = new Hook<Boolean>() {
298298
@Override
@@ -359,7 +359,7 @@ void finallyAfter(HookContext<Boolean> ctx, ImmutableMap<String, Object> hints)
359359
Hook hook = mock(Hook.class);
360360
doThrow(RuntimeException.class).when(hook).before(any(), any());
361361
OpenFeatureAPI api = OpenFeatureAPI.getInstance();
362-
api.setProvider(new NoOpProvider<>());
362+
api.setProvider(new NoOpProvider());
363363
Client client = api.getClient();
364364
client.getBooleanValue("key", false, new EvaluationContext(),
365365
FlagEvaluationOptions.builder().hook(hook).build());
@@ -374,7 +374,7 @@ void finallyAfter(HookContext<Boolean> ctx, ImmutableMap<String, Object> hints)
374374
doThrow(RuntimeException.class).when(hook).before(any(), any());
375375

376376
OpenFeatureAPI api = OpenFeatureAPI.getInstance();
377-
api.setProvider(new NoOpProvider<>());
377+
api.setProvider(new NoOpProvider());
378378
Client client = api.getClient();
379379

380380
client.getBooleanValue("key", false, new EvaluationContext(),
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package javasdk;
2+
3+
import org.junit.jupiter.api.Test;
4+
5+
import static org.junit.jupiter.api.Assertions.assertEquals;
6+
7+
public class NoOpProviderTest {
8+
@Test void bool() {
9+
NoOpProvider p = new NoOpProvider();
10+
ProviderEvaluation<Boolean> eval = p.getBooleanEvaluation("key", true, null, null);
11+
assertEquals(true, eval.getValue());
12+
}
13+
14+
@Test void str() {
15+
NoOpProvider p = new NoOpProvider();
16+
17+
ProviderEvaluation<String> eval = p.getStringEvaluation("key", "works", null, null);
18+
assertEquals("works", eval.getValue());
19+
}
20+
21+
@Test void integer() {
22+
NoOpProvider p = new NoOpProvider();
23+
ProviderEvaluation<Integer> eval = p.getIntegerEvaluation("key", 4, null, null);
24+
assertEquals(4, eval.getValue());
25+
}
26+
}

0 commit comments

Comments
 (0)