@@ -66,9 +66,9 @@ void shouldAlwaysCallGenericHook(FlagValueType flagValueType) {
6666 var hookSupportData = new HookSupportData ();
6767 hookSupport .setHooks (
6868 hookSupportData ,
69+ List .of (genericHook ),
6970 Collections .emptyList (),
7071 Collections .emptyList (),
71- List .of (genericHook ),
7272 Collections .emptyList (),
7373 flagValueType );
7474
@@ -89,9 +89,9 @@ void shouldPassDataAcrossStages(FlagValueType flagValueType) {
8989 hookSupport .setHooks (
9090 hookSupportData ,
9191 Collections .emptyList (),
92- Collections .emptyList (),
9392 List .of (testHook ),
9493 Collections .emptyList (),
94+ Collections .emptyList (),
9595 flagValueType );
9696 hookSupport .setHookContexts (
9797 hookSupportData ,
@@ -125,8 +125,8 @@ void shouldIsolateDataBetweenHooks(FlagValueType flagValueType) {
125125 hookSupportData ,
126126 Collections .emptyList (),
127127 Collections .emptyList (),
128- List .of (testHook1 , testHook2 ),
129128 Collections .emptyList (),
129+ List .of (testHook1 , testHook2 ),
130130 flagValueType );
131131 hookSupport .setHookContexts (
132132 hookSupportData ,
@@ -139,6 +139,28 @@ void shouldIsolateDataBetweenHooks(FlagValueType flagValueType) {
139139 assertHookData (testHook2 , 2 , "before" , "after" , "finallyAfter" , "error" );
140140 }
141141
142+ @ Test
143+ @ DisplayName ("should place hooks in provider → options → client → API order" )
144+ void shouldOrderHooksBySource () {
145+ Hook <?> providerHook = mockGenericHook ();
146+ Hook <?> optionHook = mockGenericHook ();
147+ Hook <?> clientHook = mockGenericHook ();
148+ Hook <?> apiHook = mockGenericHook ();
149+
150+ var hookSupportData = new HookSupportData ();
151+ hookSupport .setHooks (
152+ hookSupportData ,
153+ List .of (providerHook ),
154+ List .of (optionHook ),
155+ List .of (clientHook ),
156+ List .of (apiHook ),
157+ FlagValueType .STRING );
158+
159+ assertThat (hookSupportData .getHooks ())
160+ .extracting (Pair ::getKey )
161+ .containsExactly (providerHook , optionHook , clientHook , apiHook );
162+ }
163+
142164 @ Test
143165 void hookThatReturnsTheGivenContext_doesNotResultInAStackOverflow () {
144166 var hookSupportData = new HookSupportData ();
0 commit comments