@@ -195,69 +195,69 @@ void emptyApiHooks() {
195
195
api .setProvider (new NoOpProvider ());
196
196
api .registerHooks (new Hook <Boolean >() {
197
197
@ Override
198
- void before (HookContext <Boolean > ctx , ImmutableMap <String , Object > hints ) {
198
+ public void before (HookContext <Boolean > ctx , ImmutableMap <String , Object > hints ) {
199
199
evalOrder .add ("api before" );
200
200
}
201
201
202
202
@ Override
203
- void after (HookContext <Boolean > ctx , FlagEvaluationDetails <Boolean > details , ImmutableMap <String , Object > hints ) {
203
+ public void after (HookContext <Boolean > ctx , FlagEvaluationDetails <Boolean > details , ImmutableMap <String , Object > hints ) {
204
204
evalOrder .add ("api after" );
205
205
throw new RuntimeException (); // trigger error flows.
206
206
}
207
207
208
208
@ Override
209
- void error (HookContext <Boolean > ctx , Exception error , ImmutableMap <String , Object > hints ) {
209
+ public void error (HookContext <Boolean > ctx , Exception error , ImmutableMap <String , Object > hints ) {
210
210
evalOrder .add ("api error" );
211
211
}
212
212
213
213
@ Override
214
- void finallyAfter (HookContext <Boolean > ctx , ImmutableMap <String , Object > hints ) {
214
+ public void finallyAfter (HookContext <Boolean > ctx , ImmutableMap <String , Object > hints ) {
215
215
evalOrder .add ("api finally" );
216
216
}
217
217
});
218
218
219
219
Client c = api .getClient ();
220
220
c .registerHooks (new Hook <Boolean >() {
221
221
@ Override
222
- void before (HookContext <Boolean > ctx , ImmutableMap <String , Object > hints ) {
222
+ public void before (HookContext <Boolean > ctx , ImmutableMap <String , Object > hints ) {
223
223
evalOrder .add ("client before" );
224
224
}
225
225
226
226
@ Override
227
- void after (HookContext <Boolean > ctx , FlagEvaluationDetails <Boolean > details , ImmutableMap <String , Object > hints ) {
227
+ public void after (HookContext <Boolean > ctx , FlagEvaluationDetails <Boolean > details , ImmutableMap <String , Object > hints ) {
228
228
evalOrder .add ("client after" );
229
229
}
230
230
231
231
@ Override
232
- void error (HookContext <Boolean > ctx , Exception error , ImmutableMap <String , Object > hints ) {
232
+ public void error (HookContext <Boolean > ctx , Exception error , ImmutableMap <String , Object > hints ) {
233
233
evalOrder .add ("client error" );
234
234
}
235
235
236
236
@ Override
237
- void finallyAfter (HookContext <Boolean > ctx , ImmutableMap <String , Object > hints ) {
237
+ public void finallyAfter (HookContext <Boolean > ctx , ImmutableMap <String , Object > hints ) {
238
238
evalOrder .add ("client finally" );
239
239
}
240
240
});
241
241
242
242
c .getBooleanValue ("key" , false , null , FlagEvaluationOptions .builder ()
243
243
.hook (new Hook <Boolean >() {
244
244
@ Override
245
- void before (HookContext <Boolean > ctx , ImmutableMap <String , Object > hints ) {
245
+ public void before (HookContext <Boolean > ctx , ImmutableMap <String , Object > hints ) {
246
246
evalOrder .add ("invocation before" );
247
247
}
248
248
249
249
@ Override
250
- void after (HookContext <Boolean > ctx , FlagEvaluationDetails <Boolean > details , ImmutableMap <String , Object > hints ) {
250
+ public void after (HookContext <Boolean > ctx , FlagEvaluationDetails <Boolean > details , ImmutableMap <String , Object > hints ) {
251
251
evalOrder .add ("invocation after" );
252
252
}
253
253
254
254
@ Override
255
- void error (HookContext <Boolean > ctx , Exception error , ImmutableMap <String , Object > hints ) {
255
+ public void error (HookContext <Boolean > ctx , Exception error , ImmutableMap <String , Object > hints ) {
256
256
evalOrder .add ("invocation error" );
257
257
}
258
258
259
259
@ Override
260
- void finallyAfter (HookContext <Boolean > ctx , ImmutableMap <String , Object > hints ) {
260
+ public void finallyAfter (HookContext <Boolean > ctx , ImmutableMap <String , Object > hints ) {
261
261
evalOrder .add ("invocation finally" );
262
262
}
263
263
})
@@ -296,22 +296,22 @@ void finallyAfter(HookContext<Boolean> ctx, ImmutableMap<String, Object> hints)
296
296
Client client = api .getClient ();
297
297
Hook <Boolean > mutatingHook = new Hook <Boolean >() {
298
298
@ Override
299
- void before (HookContext <Boolean > ctx , ImmutableMap <String , Object > hints ) {
299
+ public void before (HookContext <Boolean > ctx , ImmutableMap <String , Object > hints ) {
300
300
assertTrue (hints instanceof ImmutableMap );
301
301
}
302
302
303
303
@ Override
304
- void after (HookContext <Boolean > ctx , FlagEvaluationDetails <Boolean > details , ImmutableMap <String , Object > hints ) {
304
+ public void after (HookContext <Boolean > ctx , FlagEvaluationDetails <Boolean > details , ImmutableMap <String , Object > hints ) {
305
305
assertTrue (hints instanceof ImmutableMap );
306
306
}
307
307
308
308
@ Override
309
- void error (HookContext <Boolean > ctx , Exception error , ImmutableMap <String , Object > hints ) {
309
+ public void error (HookContext <Boolean > ctx , Exception error , ImmutableMap <String , Object > hints ) {
310
310
assertTrue (hints instanceof ImmutableMap );
311
311
}
312
312
313
313
@ Override
314
- void finallyAfter (HookContext <Boolean > ctx , ImmutableMap <String , Object > hints ) {
314
+ public void finallyAfter (HookContext <Boolean > ctx , ImmutableMap <String , Object > hints ) {
315
315
assertTrue (hints instanceof ImmutableMap );
316
316
}
317
317
};
@@ -397,21 +397,14 @@ void finallyAfter(HookContext<Boolean> ctx, ImmutableMap<String, Object> hints)
397
397
398
398
@ SneakyThrows
399
399
@ Specification (spec ="hooks" , number ="3.6" , text ="Condition: If finally is a reserved word in the language, finallyAfter SHOULD be used." )
400
- @ Disabled ("Unsure why the getMethod() call doesn't work correctly" )
401
400
@ Test void doesnt_use_finally () {
402
- // Class [] carr = new Class[1];
403
- // carr[0] = HookContext.class;
404
- //
405
- // try {
406
- // Hook.class.getMethod("finally", carr);
407
- // fail("Not possible. Finally is a reserved word.");
408
- // } catch (NoSuchMethodException e) {
409
- // // expected
410
- // }
411
-
412
- Hook .class .getMethod ("finallyAfter" , HookContext .class );
401
+ try {
402
+ Hook .class .getMethod ("finally" , HookContext .class , ImmutableMap .class );
403
+ fail ("Not possible. Finally is a reserved word." );
404
+ } catch (NoSuchMethodException e ) {
405
+ // expected
406
+ }
413
407
408
+ Hook .class .getMethod ("finallyAfter" , HookContext .class , ImmutableMap .class );
414
409
}
415
-
416
-
417
410
}
0 commit comments