@@ -147,7 +147,7 @@ void emptyApiHooks() {
147
147
client .getBooleanValue ("key" , false , new EvaluationContext (),
148
148
FlagEvaluationOptions .builder ().hook (evalHook ).build ());
149
149
150
- verify (evalHook , times (1 )).before (any ());
150
+ verify (evalHook , times (1 )).before (any (), any () );
151
151
}
152
152
153
153
@ Specification (spec ="hooks" , number ="5.1" , text ="Flag evalution options MUST contain a list of hooks to evaluate." )
@@ -160,25 +160,25 @@ void emptyApiHooks() {
160
160
@ Specification (spec ="hooks" , number ="4.3" , text ="If an error occurs in the finally hook, it MUST NOT trigger the error hook." )
161
161
@ Test void errors_in_finally () {
162
162
Hook <Boolean > h = mock (Hook .class );
163
- doThrow (RuntimeException .class ).when (h ).finallyAfter (any ());
163
+ doThrow (RuntimeException .class ).when (h ).finallyAfter (any (), any () );
164
164
165
165
OpenFeatureAPI api = OpenFeatureAPI .getInstance ();
166
166
api .setProvider (new NoOpProvider <>());
167
167
Client c = api .getClient ();
168
168
169
169
assertThrows (RuntimeException .class , () -> c .getBooleanValue ("key" , false , null , FlagEvaluationOptions .builder ().hook (h ).build ()));
170
170
171
- verify (h , times (1 )).finallyAfter (any ());
172
- verify (h , times (0 )).error (any (), any ());
171
+ verify (h , times (1 )).finallyAfter (any (), any () );
172
+ verify (h , times (0 )).error (any (), any (), any () );
173
173
}
174
174
175
175
@ Specification (spec ="hooks" , number ="3.4" , text ="The error hook MUST run when errors are encountered in the before stage, the after stage or during flag evaluation. It accepts hook context (required), exception for what went wrong (required), and HookHints (optional). It has no return value." )
176
176
@ Test void error_hook_run_during_non_finally_stage () {
177
177
final boolean [] error_called = {false };
178
178
Hook h = mock (Hook .class );
179
- doThrow (RuntimeException .class ).when (h ).finallyAfter (any ());
179
+ doThrow (RuntimeException .class ).when (h ).finallyAfter (any (), any () );
180
180
181
- verify (h , times (0 )).error (any (), any ());
181
+ verify (h , times (0 )).error (any (), any (), any () );
182
182
}
183
183
@ Specification (spec ="hooks" , number ="4.2" , text ="Hooks MUST be evaluated in the following order:" +
184
184
"before: API, Client, Invocation" +
@@ -189,33 +189,33 @@ void emptyApiHooks() {
189
189
List <String > evalOrder = new ArrayList <String >();
190
190
OpenFeatureAPI api = OpenFeatureAPI .getInstance ();
191
191
api .setProvider (new NoOpProvider ());
192
- api .registerHooks (new Hook () {
192
+ api .registerHooks (new Hook < Boolean > () {
193
193
@ Override
194
- void before (HookContext ctx ) {
194
+ void before (HookContext < Boolean > ctx , ImmutableMap < String , Object > hints ) {
195
195
evalOrder .add ("api before" );
196
196
}
197
197
198
198
@ Override
199
- void after (HookContext ctx , FlagEvaluationDetails details ) {
199
+ void after (HookContext < Boolean > ctx , FlagEvaluationDetails < Boolean > details , ImmutableMap < String , Object > hints ) {
200
200
evalOrder .add ("api after" );
201
201
throw new RuntimeException (); // trigger error flows.
202
202
}
203
203
204
204
@ Override
205
- void error (HookContext ctx , Exception error ) {
205
+ void error (HookContext < Boolean > ctx , Exception error , ImmutableMap < String , Object > hints ) {
206
206
evalOrder .add ("api error" );
207
207
}
208
208
209
209
@ Override
210
- void finallyAfter (HookContext ctx ) {
210
+ void finallyAfter (HookContext < Boolean > ctx , ImmutableMap < String , Object > hints ) {
211
211
evalOrder .add ("api finally" );
212
212
}
213
213
});
214
214
215
215
Client c = api .getClient ();
216
- c .registerHooks (new Hook () {
216
+ c .registerHooks (new Hook < Boolean > () {
217
217
@ Override
218
- void before (HookContext ctx ) {
218
+ void before (HookContext < Boolean > ctx , ImmutableMap < String , Object > hints ) {
219
219
evalOrder .add ("client before" );
220
220
}
221
221
@@ -225,35 +225,35 @@ void after(HookContext ctx, FlagEvaluationDetails details) {
225
225
}
226
226
227
227
@ Override
228
- void error (HookContext ctx , Exception error ) {
228
+ void error (HookContext < Boolean > ctx , Exception error , ImmutableMap < String , Object > hints ) {
229
229
evalOrder .add ("client error" );
230
230
}
231
231
232
232
@ Override
233
- void finallyAfter (HookContext ctx ) {
233
+ void finallyAfter (HookContext < Boolean > ctx , ImmutableMap < String , Object > hints ) {
234
234
evalOrder .add ("client finally" );
235
235
}
236
236
});
237
237
238
238
c .getBooleanValue ("key" , false , null , FlagEvaluationOptions .builder ()
239
- .hook (new Hook () {
239
+ .hook (new Hook < Boolean > () {
240
240
@ Override
241
- void before (HookContext ctx ) {
241
+ void before (HookContext < Boolean > ctx , ImmutableMap < String , Object > hints ) {
242
242
evalOrder .add ("invocation before" );
243
243
}
244
244
245
245
@ Override
246
- void after (HookContext ctx , FlagEvaluationDetails details ) {
246
+ void after (HookContext < Boolean > ctx , FlagEvaluationDetails < Boolean > details , ImmutableMap < String , Object > hints ) {
247
247
evalOrder .add ("invocation after" );
248
248
}
249
249
250
250
@ Override
251
- void error (HookContext ctx , Exception error ) {
251
+ void error (HookContext < Boolean > ctx , Exception error , ImmutableMap < String , Object > hints ) {
252
252
evalOrder .add ("invocation error" );
253
253
}
254
254
255
255
@ Override
256
- void finallyAfter (HookContext ctx ) {
256
+ void finallyAfter (HookContext < Boolean > ctx , ImmutableMap < String , Object > hints ) {
257
257
evalOrder .add ("invocation finally" );
258
258
}
259
259
})
0 commit comments