@@ -20,11 +20,11 @@ public class ParameterizedRuleExecutorTests extends AbstractRuleTestCase {
2020 // Test ParameterizedRuleExecutor implementation
2121 static class TestParameterizedRuleExecutor extends ParameterizedRuleExecutor <TestNode , String > {
2222 public List <RuleExecutor .Batch <TestNode >> batches = new ArrayList <>();
23-
23+
2424 public TestParameterizedRuleExecutor (String context ) {
2525 super (context );
2626 }
27-
27+
2828 @ Override
2929 public List <RuleExecutor .Batch <TestNode >> batches () {
3030 return batches ;
@@ -33,11 +33,11 @@ public List<RuleExecutor.Batch<TestNode>> batches() {
3333
3434 static class TestContextParameterizedRuleExecutor extends ParameterizedRuleExecutor <TestNode , TestContext > {
3535 public List <RuleExecutor .Batch <TestNode >> batches = new ArrayList <>();
36-
36+
3737 public TestContextParameterizedRuleExecutor (TestContext context ) {
3838 super (context );
3939 }
40-
40+
4141 @ Override
4242 public List <RuleExecutor .Batch <TestNode >> batches () {
4343 return batches ;
@@ -47,14 +47,14 @@ public List<RuleExecutor.Batch<TestNode>> batches() {
4747 public void testBasicParameterizedRuleExecution () {
4848 TestParameterizedRuleExecutor executor = new TestParameterizedRuleExecutor ("param_value" );
4949 TestNode input = new TestNode ("test" );
50-
50+
5151 TestParameterizedRule rule = new TestParameterizedRule ();
5252 RuleExecutor .Batch <TestNode > batch = new RuleExecutor .Batch <>("ParamBatch" , rule );
5353 executor .batches .add (batch );
54-
54+
5555 AsyncResult <TestParameterizedRuleExecutor .ExecutionInfo > result = new AsyncResult <>();
5656 executor .executeWithInfo (input , result .listener ());
57-
57+
5858 result .assertSuccess ();
5959 assertEquals ("test_param_value" , result .get ().after ().value ());
6060 }
@@ -63,34 +63,34 @@ public void testParameterizedRuleWithComplexContext() {
6363 TestContext context = new TestContext ("start_" , "_end" );
6464 TestContextParameterizedRuleExecutor executor = new TestContextParameterizedRuleExecutor (context );
6565 TestNode input = new TestNode ("middle" );
66-
66+
6767 TestContextParameterizedRule rule = new TestContextParameterizedRule ();
6868 RuleExecutor .Batch <TestNode > batch = new RuleExecutor .Batch <>("ContextBatch" , rule );
6969 executor .batches .add (batch );
70-
70+
7171 AsyncResult <TestContextParameterizedRuleExecutor .ExecutionInfo > result = new AsyncResult <>();
7272 executor .executeWithInfo (input , result .listener ());
73-
73+
7474 result .assertSuccess ();
7575 assertEquals ("start_middle_end" , result .get ().after ().value ());
7676 }
7777
7878 public void testMultipleParameterizedRulesInBatch () {
7979 TestParameterizedRuleExecutor executor = new TestParameterizedRuleExecutor ("X" );
8080 TestNode input = new TestNode ("base" );
81-
81+
8282 TestParameterizedRule rule1 = new TestParameterizedRule ();
8383 TestParameterizedRule rule2 = new TestParameterizedRule ();
84-
84+
8585 RuleExecutor .Batch <TestNode > batch = new RuleExecutor .Batch <>("MultiBatch" , rule1 , rule2 );
8686 executor .batches .add (batch );
87-
87+
8888 AsyncResult <TestParameterizedRuleExecutor .ExecutionInfo > result = new AsyncResult <>();
8989 executor .executeWithInfo (input , result .listener ());
90-
90+
9191 result .assertSuccess ();
9292 assertEquals ("base_X_X" , result .get ().after ().value ());
93-
93+
9494 // Check transformations
9595 var transformations = result .get ().transformations ();
9696 assertThat (transformations .keySet ().size (), equalTo (1 ));
@@ -103,17 +103,17 @@ public void testMultipleParameterizedRulesInBatch() {
103103 public void testMixedRulesInParameterizedExecutor () {
104104 TestParameterizedRuleExecutor executor = new TestParameterizedRuleExecutor ("param" );
105105 TestNode input = new TestNode ("test" );
106-
106+
107107 // Mix parameterized and non-parameterized rules
108108 AppendRule nonParamRule = new AppendRule ("_suffix" );
109109 TestParameterizedRule paramRule = new TestParameterizedRule ();
110-
110+
111111 RuleExecutor .Batch <TestNode > batch = new RuleExecutor .Batch <>("MixedBatch" , nonParamRule , paramRule );
112112 executor .batches .add (batch );
113-
113+
114114 AsyncResult <TestParameterizedRuleExecutor .ExecutionInfo > result = new AsyncResult <>();
115115 executor .executeWithInfo (input , result .listener ());
116-
116+
117117 result .assertSuccess ();
118118 // Should apply non-parameterized rule first, then parameterized rule
119119 assertEquals ("test_suffix_param" , result .get ().after ().value ());
@@ -122,67 +122,67 @@ public void testMixedRulesInParameterizedExecutor() {
122122 public void testParameterizedRuleFailure () {
123123 TestParameterizedRuleExecutor executor = new TestParameterizedRuleExecutor ("error_param" );
124124 TestNode input = new TestNode ("test" );
125-
125+
126126 // Create a failing parameterized rule
127127 ParameterizedRule <TestNode , TestNode , String > failingRule = new ParameterizedRule .Async <TestNode , TestNode , String >() {
128128 @ Override
129129 public void apply (TestNode node , String param , ActionListener <TestNode > listener ) {
130130 listener .onFailure (new RuntimeException ("Parameterized rule failed with: " + param ));
131131 }
132-
132+
133133 @ Override
134134 public String name () {
135135 return "FailingParameterizedRule" ;
136136 }
137137 };
138-
138+
139139 RuleExecutor .Batch <TestNode > batch = new RuleExecutor .Batch <>("FailingBatch" , failingRule );
140140 executor .batches .add (batch );
141-
141+
142142 AsyncResult <TestParameterizedRuleExecutor .ExecutionInfo > result = new AsyncResult <>();
143143 executor .executeWithInfo (input , result .listener ());
144-
144+
145145 result .assertFailure ("Parameterized rule failed with: error_param" );
146146 }
147147
148148 public void testParameterizedRuleExecutionOrder () {
149149 TestParameterizedRuleExecutor executor = new TestParameterizedRuleExecutor ("ORDER" );
150150 TestNode input = new TestNode ("" );
151-
151+
152152 List <String > executionOrder = new ArrayList <>();
153-
153+
154154 ParameterizedRule <TestNode , TestNode , String > rule1 = new ParameterizedRule .Sync <TestNode , TestNode , String >() {
155155 @ Override
156156 public TestNode apply (TestNode node , String param ) {
157157 executionOrder .add ("rule1_" + param );
158158 return new TestNode (node .value () + "1" , node .children ());
159159 }
160-
160+
161161 @ Override
162162 public String name () {
163163 return "ParamRule1" ;
164164 }
165165 };
166-
166+
167167 ParameterizedRule <TestNode , TestNode , String > rule2 = new ParameterizedRule .Sync <TestNode , TestNode , String >() {
168168 @ Override
169169 public TestNode apply (TestNode node , String param ) {
170170 executionOrder .add ("rule2_" + param );
171171 return new TestNode (node .value () + "2" , node .children ());
172172 }
173-
173+
174174 @ Override
175175 public String name () {
176176 return "ParamRule2" ;
177177 }
178178 };
179-
179+
180180 RuleExecutor .Batch <TestNode > batch = new RuleExecutor .Batch <>("OrderBatch" , rule1 , rule2 );
181181 executor .batches .add (batch );
182-
182+
183183 AsyncResult <TestParameterizedRuleExecutor .ExecutionInfo > result = new AsyncResult <>();
184184 executor .executeWithInfo (input , result .listener ());
185-
185+
186186 result .assertSuccess ();
187187 assertEquals ("12" , result .get ().after ().value ());
188188 assertEquals (Arrays .asList ("rule1_ORDER" , "rule2_ORDER" ), executionOrder );
@@ -191,29 +191,29 @@ public String name() {
191191 public void testParameterizedRuleNoChange () {
192192 TestParameterizedRuleExecutor executor = new TestParameterizedRuleExecutor ("ignored" );
193193 TestNode input = new TestNode ("test" );
194-
194+
195195 ParameterizedRule <TestNode , TestNode , String > noChangeRule = new ParameterizedRule .Sync <TestNode , TestNode , String >() {
196196 @ Override
197197 public TestNode apply (TestNode node , String param ) {
198198 return node ; // No change regardless of parameter
199199 }
200-
200+
201201 @ Override
202202 public String name () {
203203 return "NoChangeParamRule" ;
204204 }
205205 };
206-
206+
207207 RuleExecutor .Batch <TestNode > batch = new RuleExecutor .Batch <>("NoChangeBatch" , noChangeRule );
208208 executor .batches .add (batch );
209-
209+
210210 AsyncResult <TestParameterizedRuleExecutor .ExecutionInfo > result = new AsyncResult <>();
211211 executor .executeWithInfo (input , result .listener ());
212-
212+
213213 result .assertSuccess ();
214214 assertEquals ("test" , result .get ().after ().value ());
215215 assertEquals (input , result .get ().after ()); // Same instance since no change
216-
216+
217217 // Check that transformation was recorded but marked as no change
218218 var transformations = result .get ().transformations ();
219219 assertThat (transformations .keySet ().size (), equalTo (1 ));
@@ -225,24 +225,24 @@ public String name() {
225225 public void testParameterizedRuleWithMultipleBatches () {
226226 TestParameterizedRuleExecutor executor = new TestParameterizedRuleExecutor ("middle" );
227227 TestNode input = new TestNode ("test" );
228-
228+
229229 // First batch with parameterized rule
230230 TestParameterizedRule paramRule = new TestParameterizedRule ();
231231 RuleExecutor .Batch <TestNode > batch1 = new RuleExecutor .Batch <>("PrependBatch" , paramRule );
232-
232+
233233 // Second batch with non-parameterized rule
234234 AppendRule appendRule = new AppendRule ("_final" );
235235 RuleExecutor .Batch <TestNode > batch2 = new RuleExecutor .Batch <>("AppendBatch" , appendRule );
236-
236+
237237 executor .batches .add (batch1 );
238238 executor .batches .add (batch2 );
239-
239+
240240 AsyncResult <TestParameterizedRuleExecutor .ExecutionInfo > result = new AsyncResult <>();
241241 executor .executeWithInfo (input , result .listener ());
242-
242+
243243 result .assertSuccess ();
244244 assertEquals ("test_middle_final" , result .get ().after ().value ());
245-
245+
246246 // Should have transformations from both batches
247247 var transformations = result .get ().transformations ();
248248 assertThat (transformations .keySet ().size (), equalTo (2 ));
@@ -251,59 +251,59 @@ public void testParameterizedRuleWithMultipleBatches() {
251251 public void testParameterizedExecuteShortcut () {
252252 TestParameterizedRuleExecutor executor = new TestParameterizedRuleExecutor ("shortcut" );
253253 TestNode input = new TestNode ("test" );
254-
254+
255255 TestParameterizedRule rule = new TestParameterizedRule ();
256256 RuleExecutor .Batch <TestNode > batch = new RuleExecutor .Batch <>("TestBatch" , rule );
257257 executor .batches .add (batch );
258-
258+
259259 AsyncResult <TestNode > result = new AsyncResult <>();
260260 executor .execute (input , result .listener ());
261-
261+
262262 result .assertSuccess ();
263263 assertEquals ("test_shortcut" , result .get ().value ());
264264 }
265265
266266 public void testParameterizedAsyncRule () {
267267 TestParameterizedRuleExecutor executor = new TestParameterizedRuleExecutor ("async_param" );
268268 TestNode input = new TestNode ("test" );
269-
269+
270270 ParameterizedRule <TestNode , TestNode , String > asyncRule = new ParameterizedRule .Async <TestNode , TestNode , String >() {
271271 @ Override
272272 public void apply (TestNode node , String param , ActionListener <TestNode > listener ) {
273273 // Simulate async processing
274274 listener .onResponse (new TestNode ("async_" + node .value () + "_" + param , node .children ()));
275275 }
276-
276+
277277 @ Override
278278 public String name () {
279279 return "AsyncParameterizedRule" ;
280280 }
281281 };
282-
282+
283283 RuleExecutor .Batch <TestNode > batch = new RuleExecutor .Batch <>("AsyncBatch" , asyncRule );
284284 executor .batches .add (batch );
285-
285+
286286 AsyncResult <TestParameterizedRuleExecutor .ExecutionInfo > result = new AsyncResult <>();
287287 executor .executeWithInfo (input , result .listener ());
288-
288+
289289 result .assertSuccess ();
290290 assertEquals ("async_test_async_param" , result .get ().after ().value ());
291291 }
292292
293293 public void testParameterizedRuleContextAccess () {
294294 TestParameterizedRuleExecutor executor = new TestParameterizedRuleExecutor ("context_value" );
295295 TestNode input = new TestNode ("test" );
296-
296+
297297 // Verify that the executor's context is correctly passed to rules
298298 assertEquals ("context_value" , executor .context ());
299-
299+
300300 TestParameterizedRule rule = new TestParameterizedRule ();
301301 RuleExecutor .Batch <TestNode > batch = new RuleExecutor .Batch <>("ContextBatch" , rule );
302302 executor .batches .add (batch );
303-
303+
304304 AsyncResult <TestParameterizedRuleExecutor .ExecutionInfo > result = new AsyncResult <>();
305305 executor .executeWithInfo (input , result .listener ());
306-
306+
307307 result .assertSuccess ();
308308 assertEquals ("test_context_value" , result .get ().after ().value ());
309309 }
0 commit comments