1- package dev .openfeature .sdk .e2e ;
1+ package dev .openfeature .sdk .e2e . evaluation ;
22
33import dev .openfeature .sdk .Value ;
44import dev .openfeature .sdk .EvaluationContext ;
1515import io .cucumber .java .en .Then ;
1616import io .cucumber .java .en .When ;
1717import lombok .SneakyThrows ;
18+ import org .mockito .Mockito ;
1819
1920import java .util .HashMap ;
2021import java .util .Map ;
2526
2627public class StepDefinitions {
2728
28- private static Client client ;
29+ static Client client ;
2930 private boolean booleanFlagValue ;
3031 private String stringFlagValue ;
3132 private int intFlagValue ;
@@ -53,9 +54,10 @@ public class StepDefinitions {
5354 @ SneakyThrows
5455 @ BeforeAll ()
5556 @ Given ("an openfeature client is registered with cache disabled" )
57+ @ Given ("a provider is registered" )
5658 public static void setup () {
5759 Map <String , Flag <?>> flags = buildFlags ();
58- InMemoryProvider provider = new InMemoryProvider (flags );
60+ InMemoryProvider provider = Mockito . spy ( new InMemoryProvider (flags ) );
5961 OpenFeatureAPI .getInstance ().setProviderAndWait (provider );
6062 client = OpenFeatureAPI .getInstance ().getClient ();
6163 }
@@ -67,7 +69,7 @@ public static void setup() {
6769 // boolean value
6870 @ When ("a boolean flag with key {string} is evaluated with default value {string}" )
6971 public void a_boolean_flag_with_key_boolean_flag_is_evaluated_with_default_value_false (String flagKey ,
70- String defaultValue ) {
72+ String defaultValue ) {
7173 this .booleanFlagValue = client .getBooleanValue (flagKey , Boolean .valueOf (defaultValue ));
7274 }
7375
@@ -117,7 +119,7 @@ public void an_object_flag_with_key_is_evaluated_with_a_null_default_value(Strin
117119
118120 @ Then ("the resolved object value should be contain fields {string}, {string}, and {string}, with values {string}, {string} and {int}, respectively" )
119121 public void the_resolved_object_value_should_be_contain_fields_and_with_values_and_respectively (String boolField ,
120- String stringField , String numberField , String boolValue , String stringValue , int numberValue ) {
122+ String stringField , String numberField , String boolValue , String stringValue , int numberValue ) {
121123 Structure structure = this .objectFlagValue .asStructure ();
122124
123125 assertEquals (Boolean .valueOf (boolValue ), structure .asMap ().get (boolField ).asBoolean ());
@@ -132,7 +134,7 @@ public void the_resolved_object_value_should_be_contain_fields_and_with_values_a
132134 // boolean details
133135 @ When ("a boolean flag with key {string} is evaluated with details and default value {string}" )
134136 public void a_boolean_flag_with_key_is_evaluated_with_details_and_default_value (String flagKey ,
135- String defaultValue ) {
137+ String defaultValue ) {
136138 this .booleanFlagDetails = client .getBooleanDetails (flagKey , Boolean .valueOf (defaultValue ));
137139 }
138140
@@ -148,13 +150,13 @@ public void the_resolved_boolean_value_should_be_the_variant_should_be_and_the_r
148150 // string details
149151 @ When ("a string flag with key {string} is evaluated with details and default value {string}" )
150152 public void a_string_flag_with_key_is_evaluated_with_details_and_default_value (String flagKey ,
151- String defaultValue ) {
153+ String defaultValue ) {
152154 this .stringFlagDetails = client .getStringDetails (flagKey , defaultValue );
153155 }
154156
155157 @ Then ("the resolved string details value should be {string}, the variant should be {string}, and the reason should be {string}" )
156158 public void the_resolved_string_value_should_be_the_variant_should_be_and_the_reason_should_be (String expectedValue ,
157- String expectedVariant , String expectedReason ) {
159+ String expectedVariant , String expectedReason ) {
158160 assertEquals (expectedValue , this .stringFlagDetails .getValue ());
159161 assertEquals (expectedVariant , this .stringFlagDetails .getVariant ());
160162 assertEquals (expectedReason , this .stringFlagDetails .getReason ());
@@ -168,7 +170,7 @@ public void an_integer_flag_with_key_is_evaluated_with_details_and_default_value
168170
169171 @ Then ("the resolved integer details value should be {int}, the variant should be {string}, and the reason should be {string}" )
170172 public void the_resolved_integer_value_should_be_the_variant_should_be_and_the_reason_should_be (int expectedValue ,
171- String expectedVariant , String expectedReason ) {
173+ String expectedVariant , String expectedReason ) {
172174 assertEquals (expectedValue , this .intFlagDetails .getValue ());
173175 assertEquals (expectedVariant , this .intFlagDetails .getVariant ());
174176 assertEquals (expectedReason , this .intFlagDetails .getReason ());
@@ -182,7 +184,7 @@ public void a_float_flag_with_key_is_evaluated_with_details_and_default_value(St
182184
183185 @ Then ("the resolved float details value should be {double}, the variant should be {string}, and the reason should be {string}" )
184186 public void the_resolved_float_value_should_be_the_variant_should_be_and_the_reason_should_be (double expectedValue ,
185- String expectedVariant , String expectedReason ) {
187+ String expectedVariant , String expectedReason ) {
186188 assertEquals (expectedValue , this .doubleFlagDetails .getValue ());
187189 assertEquals (expectedVariant , this .doubleFlagDetails .getVariant ());
188190 assertEquals (expectedReason , this .doubleFlagDetails .getReason ());
@@ -217,7 +219,7 @@ public void the_variant_should_be_and_the_reason_should_be(String expectedVarian
217219
218220 @ When ("context contains keys {string}, {string}, {string}, {string} with values {string}, {string}, {int}, {string}" )
219221 public void context_contains_keys_with_values (String field1 , String field2 , String field3 , String field4 ,
220- String value1 , String value2 , Integer value3 , String value4 ) {
222+ String value1 , String value2 , Integer value3 , String value4 ) {
221223 Map <String , Value > attributes = new HashMap <>();
222224 attributes .put (field1 , new Value (value1 ));
223225 attributes .put (field2 , new Value (value2 ));
@@ -253,7 +255,7 @@ public void the_resolved_flag_value_is_when_the_context_is_empty(String expected
253255 // not found
254256 @ When ("a non-existent string flag with key {string} is evaluated with details and a default value {string}" )
255257 public void a_non_existent_string_flag_with_key_is_evaluated_with_details_and_a_default_value (String flagKey ,
256- String defaultValue ) {
258+ String defaultValue ) {
257259 notFoundFlagKey = flagKey ;
258260 notFoundDefaultValue = defaultValue ;
259261 notFoundDetails = client .getStringDetails (notFoundFlagKey , notFoundDefaultValue );
@@ -273,7 +275,7 @@ public void the_reason_should_indicate_an_error_and_the_error_code_should_be_fla
273275 // type mismatch
274276 @ When ("a string flag with key {string} is evaluated as an integer, with details and a default value {int}" )
275277 public void a_string_flag_with_key_is_evaluated_as_an_integer_with_details_and_a_default_value (String flagKey ,
276- int defaultValue ) {
278+ int defaultValue ) {
277279 typeErrorFlagKey = flagKey ;
278280 typeErrorDefaultValue = defaultValue ;
279281 typeErrorDetails = client .getIntegerDetails (typeErrorFlagKey , typeErrorDefaultValue );
0 commit comments