@@ -144,40 +144,7 @@ public List<ValidationError> validate() {
144
144
145
145
if (s instanceof OperationState ) {
146
146
OperationState operationState = (OperationState ) s ;
147
-
148
- List <Action > actions = operationState .getActions ();
149
- for (Action action : actions ) {
150
- if (action .getFunctionRef () != null ) {
151
- if (action .getFunctionRef ().getRefName ().isEmpty ()) {
152
- addValidationError (
153
- "Operation State action functionRef should not be null or empty" ,
154
- ValidationError .WORKFLOW_VALIDATION );
155
- }
156
-
157
- if (!haveFunctionDefinition (
158
- action .getFunctionRef ().getRefName (), functions )) {
159
- addValidationError (
160
- "Operation State action functionRef does not reference an existing workflow function definition" ,
161
- ValidationError .WORKFLOW_VALIDATION );
162
- }
163
- }
164
-
165
- if (action .getEventRef () != null ) {
166
-
167
- if (!haveEventsDefinition (
168
- action .getEventRef ().getTriggerEventRef (), events )) {
169
- addValidationError (
170
- "Operation State action trigger event def does not reference an existing workflow event definition" ,
171
- ValidationError .WORKFLOW_VALIDATION );
172
- }
173
-
174
- if (!haveEventsDefinition (action .getEventRef ().getResultEventRef (), events )) {
175
- addValidationError (
176
- "Operation State action results event def does not reference an existing workflow event definition" ,
177
- ValidationError .WORKFLOW_VALIDATION );
178
- }
179
- }
180
- }
147
+ checkActionsDefinition (operationState .getActions (), functions , events );
181
148
}
182
149
183
150
if (s instanceof EventState ) {
@@ -281,6 +248,7 @@ public List<ValidationError> validate() {
281
248
282
249
if (s instanceof ForEachState ) {
283
250
ForEachState forEachState = (ForEachState ) s ;
251
+ checkActionsDefinition (forEachState .getActions (), functions , events );
284
252
if (forEachState .getInputCollection () == null
285
253
|| forEachState .getInputCollection ().isEmpty ()) {
286
254
addValidationError (
@@ -334,6 +302,50 @@ public WorkflowValidator reset() {
334
302
return this ;
335
303
}
336
304
305
+ private void checkActionsDefinition (
306
+ List <Action > actions , List <FunctionDefinition > functions , List <EventDefinition > events ) {
307
+ if (actions == null ) {
308
+ return ;
309
+ }
310
+ for (Action action : actions ) {
311
+ if (action .getFunctionRef () != null ) {
312
+ if (action .getFunctionRef ().getRefName ().isEmpty ()) {
313
+ addValidationError (
314
+ String .format (
315
+ "State action '%s' functionRef should not be null or empty" , action .getName ()),
316
+ ValidationError .WORKFLOW_VALIDATION );
317
+ }
318
+
319
+ if (!haveFunctionDefinition (action .getFunctionRef ().getRefName (), functions )) {
320
+ addValidationError (
321
+ String .format (
322
+ "State action '%s' functionRef does not reference an existing workflow function definition" ,
323
+ action .getName ()),
324
+ ValidationError .WORKFLOW_VALIDATION );
325
+ }
326
+ }
327
+
328
+ if (action .getEventRef () != null ) {
329
+
330
+ if (!haveEventsDefinition (action .getEventRef ().getTriggerEventRef (), events )) {
331
+ addValidationError (
332
+ String .format (
333
+ "State action '%s' trigger event def does not reference an existing workflow event definition" ,
334
+ action .getName ()),
335
+ ValidationError .WORKFLOW_VALIDATION );
336
+ }
337
+
338
+ if (!haveEventsDefinition (action .getEventRef ().getResultEventRef (), events )) {
339
+ addValidationError (
340
+ String .format (
341
+ "State action '%s' results event def does not reference an existing workflow event definition" ,
342
+ action .getName ()),
343
+ ValidationError .WORKFLOW_VALIDATION );
344
+ }
345
+ }
346
+ }
347
+ }
348
+
337
349
private boolean haveFunctionDefinition (String functionName , List <FunctionDefinition > functions ) {
338
350
if (functions != null ) {
339
351
FunctionDefinition fun =
0 commit comments