Skip to content

Commit 4ec5258

Browse files
committed
Remove flag eval options from provider API
1 parent 52c9730 commit 4ec5258

File tree

8 files changed

+45
-55
lines changed

8 files changed

+45
-55
lines changed

src/main/java/dev/openfeature/javasdk/FeatureProvider.java

+5-10
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,13 @@ default List<Hook> getProviderHooks() {
1313
return new ArrayList<>();
1414
}
1515

16-
ProviderEvaluation<Boolean> getBooleanEvaluation(String key, Boolean defaultValue, EvaluationContext ctx,
17-
FlagEvaluationOptions options);
16+
ProviderEvaluation<Boolean> getBooleanEvaluation(String key, Boolean defaultValue, EvaluationContext ctx);
1817

19-
ProviderEvaluation<String> getStringEvaluation(String key, String defaultValue, EvaluationContext ctx,
20-
FlagEvaluationOptions options);
18+
ProviderEvaluation<String> getStringEvaluation(String key, String defaultValue, EvaluationContext ctx);
2119

22-
ProviderEvaluation<Integer> getIntegerEvaluation(String key, Integer defaultValue, EvaluationContext ctx,
23-
FlagEvaluationOptions options);
20+
ProviderEvaluation<Integer> getIntegerEvaluation(String key, Integer defaultValue, EvaluationContext ctx);
2421

25-
ProviderEvaluation<Double> getDoubleEvaluation(String key, Double defaultValue, EvaluationContext ctx,
26-
FlagEvaluationOptions options);
22+
ProviderEvaluation<Double> getDoubleEvaluation(String key, Double defaultValue, EvaluationContext ctx);
2723

28-
ProviderEvaluation<Structure> getObjectEvaluation(String key, Structure defaultValue,
29-
EvaluationContext invocationContext, FlagEvaluationOptions options);
24+
ProviderEvaluation<Structure> getObjectEvaluation(String key, Structure defaultValue, EvaluationContext ctx);
3025
}

src/main/java/dev/openfeature/javasdk/NoOpProvider.java

+5-10
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ public String getName() {
2121
}
2222

2323
@Override
24-
public ProviderEvaluation<Boolean> getBooleanEvaluation(String key, Boolean defaultValue, EvaluationContext ctx,
25-
FlagEvaluationOptions options) {
24+
public ProviderEvaluation<Boolean> getBooleanEvaluation(String key, Boolean defaultValue, EvaluationContext ctx) {
2625
return ProviderEvaluation.<Boolean>builder()
2726
.value(defaultValue)
2827
.variant(PASSED_IN_DEFAULT)
@@ -31,8 +30,7 @@ public ProviderEvaluation<Boolean> getBooleanEvaluation(String key, Boolean defa
3130
}
3231

3332
@Override
34-
public ProviderEvaluation<String> getStringEvaluation(String key, String defaultValue, EvaluationContext ctx,
35-
FlagEvaluationOptions options) {
33+
public ProviderEvaluation<String> getStringEvaluation(String key, String defaultValue, EvaluationContext ctx) {
3634
return ProviderEvaluation.<String>builder()
3735
.value(defaultValue)
3836
.variant(PASSED_IN_DEFAULT)
@@ -41,8 +39,7 @@ public ProviderEvaluation<String> getStringEvaluation(String key, String default
4139
}
4240

4341
@Override
44-
public ProviderEvaluation<Integer> getIntegerEvaluation(String key, Integer defaultValue, EvaluationContext ctx,
45-
FlagEvaluationOptions options) {
42+
public ProviderEvaluation<Integer> getIntegerEvaluation(String key, Integer defaultValue, EvaluationContext ctx) {
4643
return ProviderEvaluation.<Integer>builder()
4744
.value(defaultValue)
4845
.variant(PASSED_IN_DEFAULT)
@@ -51,8 +48,7 @@ public ProviderEvaluation<Integer> getIntegerEvaluation(String key, Integer defa
5148
}
5249

5350
@Override
54-
public ProviderEvaluation<Double> getDoubleEvaluation(String key, Double defaultValue, EvaluationContext ctx,
55-
FlagEvaluationOptions options) {
51+
public ProviderEvaluation<Double> getDoubleEvaluation(String key, Double defaultValue, EvaluationContext ctx) {
5652
return ProviderEvaluation.<Double>builder()
5753
.value(defaultValue)
5854
.variant(PASSED_IN_DEFAULT)
@@ -62,8 +58,7 @@ public ProviderEvaluation<Double> getDoubleEvaluation(String key, Double default
6258

6359
@Override
6460
public ProviderEvaluation<Structure> getObjectEvaluation(String key, Structure defaultValue,
65-
EvaluationContext invocationContext,
66-
FlagEvaluationOptions options) {
61+
EvaluationContext invocationContext) {
6762
return ProviderEvaluation.<Structure>builder()
6863
.value(defaultValue)
6964
.variant(PASSED_IN_DEFAULT)

src/main/java/dev/openfeature/javasdk/OpenFeatureClient.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,15 @@ private <T> ProviderEvaluation<?> createProviderEvaluation(
115115
) {
116116
switch (type) {
117117
case BOOLEAN:
118-
return provider.getBooleanEvaluation(key, (Boolean) defaultValue, invocationContext, options);
118+
return provider.getBooleanEvaluation(key, (Boolean) defaultValue, invocationContext);
119119
case STRING:
120-
return provider.getStringEvaluation(key, (String) defaultValue, invocationContext, options);
120+
return provider.getStringEvaluation(key, (String) defaultValue, invocationContext);
121121
case INTEGER:
122-
return provider.getIntegerEvaluation(key, (Integer) defaultValue, invocationContext, options);
122+
return provider.getIntegerEvaluation(key, (Integer) defaultValue, invocationContext);
123123
case DOUBLE:
124-
return provider.getDoubleEvaluation(key, (Double) defaultValue, invocationContext, options);
124+
return provider.getDoubleEvaluation(key, (Double) defaultValue, invocationContext);
125125
case OBJECT:
126-
return provider.getObjectEvaluation(key, (Structure) defaultValue, invocationContext, options);
126+
return provider.getObjectEvaluation(key, (Structure) defaultValue, invocationContext);
127127
default:
128128
throw new GeneralError("Unknown flag type");
129129
}

src/test/java/dev/openfeature/javasdk/AlwaysBrokenProvider.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,27 @@ public String getName() {
1313
}
1414

1515
@Override
16-
public ProviderEvaluation<Boolean> getBooleanEvaluation(String key, Boolean defaultValue, EvaluationContext ctx, FlagEvaluationOptions options) {
16+
public ProviderEvaluation<Boolean> getBooleanEvaluation(String key, Boolean defaultValue, EvaluationContext ctx) {
1717
throw new NotImplementedException("BORK");
1818
}
1919

2020
@Override
21-
public ProviderEvaluation<String> getStringEvaluation(String key, String defaultValue, EvaluationContext ctx, FlagEvaluationOptions options) {
21+
public ProviderEvaluation<String> getStringEvaluation(String key, String defaultValue, EvaluationContext ctx) {
2222
throw new NotImplementedException("BORK");
2323
}
2424

2525
@Override
26-
public ProviderEvaluation<Integer> getIntegerEvaluation(String key, Integer defaultValue, EvaluationContext ctx, FlagEvaluationOptions options) {
26+
public ProviderEvaluation<Integer> getIntegerEvaluation(String key, Integer defaultValue, EvaluationContext ctx) {
2727
throw new NotImplementedException("BORK");
2828
}
2929

3030
@Override
31-
public ProviderEvaluation<Double> getDoubleEvaluation(String key, Double defaultValue, EvaluationContext ctx, FlagEvaluationOptions options) {
31+
public ProviderEvaluation<Double> getDoubleEvaluation(String key, Double defaultValue, EvaluationContext ctx) {
3232
throw new NotImplementedException("BORK");
3333
}
3434

3535
@Override
36-
public ProviderEvaluation<Structure> getObjectEvaluation(String key, Structure defaultValue, EvaluationContext invocationContext, FlagEvaluationOptions options) {
36+
public ProviderEvaluation<Structure> getObjectEvaluation(String key, Structure defaultValue, EvaluationContext invocationContext) {
3737
throw new NotImplementedException("BORK");
3838
}
3939
}

src/test/java/dev/openfeature/javasdk/DoSomethingProvider.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,37 +14,37 @@ public Metadata getMetadata() {
1414
}
1515

1616
@Override
17-
public ProviderEvaluation<Boolean> getBooleanEvaluation(String key, Boolean defaultValue, EvaluationContext ctx, FlagEvaluationOptions options) {
17+
public ProviderEvaluation<Boolean> getBooleanEvaluation(String key, Boolean defaultValue, EvaluationContext ctx) {
1818
savedContext = ctx;
1919
return ProviderEvaluation.<Boolean>builder()
2020
.value(!defaultValue).build();
2121
}
2222

2323
@Override
24-
public ProviderEvaluation<String> getStringEvaluation(String key, String defaultValue, EvaluationContext ctx, FlagEvaluationOptions options) {
24+
public ProviderEvaluation<String> getStringEvaluation(String key, String defaultValue, EvaluationContext ctx) {
2525
return ProviderEvaluation.<String>builder()
2626
.value(new StringBuilder(defaultValue).reverse().toString())
2727
.build();
2828
}
2929

3030
@Override
31-
public ProviderEvaluation<Integer> getIntegerEvaluation(String key, Integer defaultValue, EvaluationContext ctx, FlagEvaluationOptions options) {
31+
public ProviderEvaluation<Integer> getIntegerEvaluation(String key, Integer defaultValue, EvaluationContext ctx) {
3232
savedContext = ctx;
3333
return ProviderEvaluation.<Integer>builder()
3434
.value(defaultValue * 100)
3535
.build();
3636
}
3737

3838
@Override
39-
public ProviderEvaluation<Double> getDoubleEvaluation(String key, Double defaultValue, EvaluationContext ctx, FlagEvaluationOptions options) {
39+
public ProviderEvaluation<Double> getDoubleEvaluation(String key, Double defaultValue, EvaluationContext ctx) {
4040
savedContext = ctx;
4141
return ProviderEvaluation.<Double>builder()
4242
.value(defaultValue * 100)
4343
.build();
4444
}
4545

4646
@Override
47-
public ProviderEvaluation<Structure> getObjectEvaluation(String key, Structure defaultValue, EvaluationContext invocationContext, FlagEvaluationOptions options) {
47+
public ProviderEvaluation<Structure> getObjectEvaluation(String key, Structure defaultValue, EvaluationContext invocationContext) {
4848
savedContext = invocationContext;
4949
return ProviderEvaluation.<Structure>builder()
5050
.value(null)

src/test/java/dev/openfeature/javasdk/HookSpecTest.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ public void finallyAfter(HookContext<Boolean> ctx, Map<String, Object> hints) {
382382
@Test void flag_eval_hook_order() {
383383
Hook hook = mockBooleanHook();
384384
FeatureProvider provider = mock(FeatureProvider.class);
385-
when(provider.getBooleanEvaluation(any(), any(), any(), any()))
385+
when(provider.getBooleanEvaluation(any(), any(), any()))
386386
.thenReturn(ProviderEvaluation.<Boolean>builder()
387387
.value(true)
388388
.build());
@@ -395,7 +395,7 @@ public void finallyAfter(HookContext<Boolean> ctx, Map<String, Object> hints) {
395395
FlagEvaluationOptions.builder().hook(hook).build());
396396

397397
order.verify(hook).before(any(), any());
398-
order.verify(provider).getBooleanEvaluation(any(), any(), any(), any());
398+
order.verify(provider).getBooleanEvaluation(any(), any(), any());
399399
order.verify(hook).after(any(), any(), any());
400400
order.verify(hook).finallyAfter(any(), any());
401401
}
@@ -484,7 +484,7 @@ public void finallyAfter(HookContext<Boolean> ctx, Map<String, Object> hints) {
484484
when(hook.before(any(), any())).thenReturn(Optional.of(hookCtx));
485485

486486
FeatureProvider provider = mock(FeatureProvider.class);
487-
when(provider.getBooleanEvaluation(any(), any(), any(), any())).thenReturn(ProviderEvaluation.<Boolean>builder()
487+
when(provider.getBooleanEvaluation(any(), any(), any())).thenReturn(ProviderEvaluation.<Boolean>builder()
488488
.value(true)
489489
.build());
490490

@@ -497,7 +497,7 @@ public void finallyAfter(HookContext<Boolean> ctx, Map<String, Object> hints) {
497497
.build());
498498

499499
ArgumentCaptor<EvaluationContext> captor = ArgumentCaptor.forClass(EvaluationContext.class);
500-
verify(provider).getBooleanEvaluation(any(), any(), captor.capture(), any());
500+
verify(provider).getBooleanEvaluation(any(), any(), captor.capture());
501501
EvaluationContext ec = captor.getValue();
502502
assertEquals("works", ec.getValue("test").asString());
503503
assertEquals("exists", ec.getValue("another").asString());

src/test/java/dev/openfeature/javasdk/NoOpProviderTest.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,33 @@
77
public class NoOpProviderTest {
88
@Test void bool() {
99
NoOpProvider p = new NoOpProvider();
10-
ProviderEvaluation<Boolean> eval = p.getBooleanEvaluation("key", true, null, null);
10+
ProviderEvaluation<Boolean> eval = p.getBooleanEvaluation("key", true, null);
1111
assertEquals(true, eval.getValue());
1212
}
1313

1414
@Test void str() {
1515
NoOpProvider p = new NoOpProvider();
1616

17-
ProviderEvaluation<String> eval = p.getStringEvaluation("key", "works", null, null);
17+
ProviderEvaluation<String> eval = p.getStringEvaluation("key", "works", null);
1818
assertEquals("works", eval.getValue());
1919
}
2020

2121
@Test void integer() {
2222
NoOpProvider p = new NoOpProvider();
23-
ProviderEvaluation<Integer> eval = p.getIntegerEvaluation("key", 4, null, null);
23+
ProviderEvaluation<Integer> eval = p.getIntegerEvaluation("key", 4, null);
2424
assertEquals(4, eval.getValue());
2525
}
2626

2727
@Test void noOpdouble() {
2828
NoOpProvider p = new NoOpProvider();
29-
ProviderEvaluation<Double> eval = p.getDoubleEvaluation("key", 0.4, null, null);
29+
ProviderEvaluation<Double> eval = p.getDoubleEvaluation("key", 0.4, null);
3030
assertEquals(0.4, eval.getValue());
3131
}
3232

3333
@Test void structure() {
3434
NoOpProvider p = new NoOpProvider();
3535
Structure s = new Structure();
36-
ProviderEvaluation<Structure> eval = p.getObjectEvaluation("key", s, null, null);
36+
ProviderEvaluation<Structure> eval = p.getObjectEvaluation("key", s, null);
3737
assertEquals(s, eval.getValue());
3838
}
3939
}

src/test/java/dev/openfeature/javasdk/ProviderSpecTest.java

+11-11
Original file line numberDiff line numberDiff line change
@@ -24,34 +24,34 @@ public class ProviderSpecTest {
2424
@Specification(number="2.9.1", text="The flag resolution structure SHOULD accept a generic " +
2525
"argument (or use an equivalent language feature) which indicates the type of the wrapped value field.")
2626
@Test void flag_value_set() {
27-
ProviderEvaluation<Integer> int_result = p.getIntegerEvaluation("key", 4, new EvaluationContext(), FlagEvaluationOptions.builder().build());
27+
ProviderEvaluation<Integer> int_result = p.getIntegerEvaluation("key", 4, new EvaluationContext());
2828
assertNotNull(int_result.getValue());
2929

30-
ProviderEvaluation<Double> double_result = p.getDoubleEvaluation("key", 0.4, new EvaluationContext(), FlagEvaluationOptions.builder().build());
30+
ProviderEvaluation<Double> double_result = p.getDoubleEvaluation("key", 0.4, new EvaluationContext());
3131
assertNotNull(double_result.getValue());
3232

33-
ProviderEvaluation<String> string_result = p.getStringEvaluation("key", "works", new EvaluationContext(), FlagEvaluationOptions.builder().build());
33+
ProviderEvaluation<String> string_result = p.getStringEvaluation("key", "works", new EvaluationContext());
3434
assertNotNull(string_result.getValue());
3535

36-
ProviderEvaluation<Boolean> boolean_result = p.getBooleanEvaluation("key", false, new EvaluationContext(), FlagEvaluationOptions.builder().build());
36+
ProviderEvaluation<Boolean> boolean_result = p.getBooleanEvaluation("key", false, new EvaluationContext());
3737
assertNotNull(boolean_result.getValue());
3838

39-
ProviderEvaluation<Structure> object_result = p.getObjectEvaluation("key", new Structure(), new EvaluationContext(), FlagEvaluationOptions.builder().build());
39+
ProviderEvaluation<Structure> object_result = p.getObjectEvaluation("key", new Structure(), new EvaluationContext());
4040
assertNotNull(object_result.getValue());
4141

4242
}
4343

4444
@Specification(number="2.6", text="The provider SHOULD populate the flag resolution structure's " +
4545
"reason field with a string indicating the semantic reason for the returned flag value.")
4646
@Test void has_reason() {
47-
ProviderEvaluation<Boolean> result = p.getBooleanEvaluation("key", false, new EvaluationContext(), FlagEvaluationOptions.builder().build());
47+
ProviderEvaluation<Boolean> result = p.getBooleanEvaluation("key", false, new EvaluationContext());
4848
assertEquals(Reason.DEFAULT, result.getReason());
4949
}
5050

5151
@Specification(number="2.7", text="In cases of normal execution, the provider MUST NOT populate " +
5252
"the flag resolution structure's error code field, or otherwise must populate it with a null or falsy value.")
5353
@Test void no_error_code_by_default() {
54-
ProviderEvaluation<Boolean> result = p.getBooleanEvaluation("key", false, new EvaluationContext(), FlagEvaluationOptions.builder().build());
54+
ProviderEvaluation<Boolean> result = p.getBooleanEvaluation("key", false, new EvaluationContext());
5555
assertNull(result.getErrorCode());
5656
}
5757

@@ -63,16 +63,16 @@ public class ProviderSpecTest {
6363
@Specification(number="2.5", text="In cases of normal execution, the provider SHOULD populate the " +
6464
"flag resolution structure's variant field with a string identifier corresponding to the returned flag value.")
6565
@Test void variant_set() {
66-
ProviderEvaluation<Integer> int_result = p.getIntegerEvaluation("key", 4, new EvaluationContext(), FlagEvaluationOptions.builder().build());
66+
ProviderEvaluation<Integer> int_result = p.getIntegerEvaluation("key", 4, new EvaluationContext());
6767
assertNotNull(int_result.getReason());
6868

69-
ProviderEvaluation<Double> double_result = p.getDoubleEvaluation("key", 0.4, new EvaluationContext(), FlagEvaluationOptions.builder().build());
69+
ProviderEvaluation<Double> double_result = p.getDoubleEvaluation("key", 0.4, new EvaluationContext());
7070
assertNotNull(double_result.getReason());
7171

72-
ProviderEvaluation<String> string_result = p.getStringEvaluation("key", "works", new EvaluationContext(), FlagEvaluationOptions.builder().build());
72+
ProviderEvaluation<String> string_result = p.getStringEvaluation("key", "works", new EvaluationContext());
7373
assertNotNull(string_result.getReason());
7474

75-
ProviderEvaluation<Boolean> boolean_result = p.getBooleanEvaluation("key", false, new EvaluationContext(), FlagEvaluationOptions.builder().build());
75+
ProviderEvaluation<Boolean> boolean_result = p.getBooleanEvaluation("key", false, new EvaluationContext());
7676
assertNotNull(boolean_result.getReason());
7777
}
7878

0 commit comments

Comments
 (0)