Skip to content

Commit fea2703

Browse files
committed
Rebase with latest changes
Signed-off-by: Ricardo Zanini <[email protected]>
1 parent 044ceb7 commit fea2703

File tree

2 files changed

+59
-59
lines changed

2 files changed

+59
-59
lines changed

validation/src/main/java/io/serverlessworkflow/validation/WorkflowValidatorImpl.java

+7-8
Original file line numberDiff line numberDiff line change
@@ -359,13 +359,12 @@ private void checkActionsDefinition(
359359
}
360360

361361
if (action.getRetryRef() != null
362-
&& isMissingRetryDefinition(
363-
action.getRetryRef(), workflow.getRetries().getRetryDefs())) {
362+
&& isMissingRetryDefinition(action.getRetryRef(), workflow.getRetries().getRetryDefs())) {
364363
addValidationError(
365-
String.format(
366-
"Operation State action '%s' retryRef does not reference an existing workflow retry definition",
367-
action.getName()),
368-
ValidationError.WORKFLOW_VALIDATION);
364+
String.format(
365+
"Operation State action '%s' retryRef does not reference an existing workflow retry definition",
366+
action.getName()),
367+
ValidationError.WORKFLOW_VALIDATION);
369368
}
370369
}
371370
}
@@ -391,8 +390,8 @@ private boolean isMissingEventsDefinition(String eventName, List<EventDefinition
391390
}
392391

393392
private boolean isMissingRetryDefinition(String retryName, List<RetryDefinition> retries) {
394-
return retries == null || ! retries.stream()
395-
.anyMatch(f -> f.getName() != null && f.getName().equals(retryName));
393+
return retries == null
394+
|| !retries.stream().anyMatch(f -> f.getName() != null && f.getName().equals(retryName));
396395
}
397396

398397
private static final Set<String> skipMessages =

validation/src/test/java/io/serverlessworkflow/validation/test/WorkflowValidationTest.java

+52-51
Original file line numberDiff line numberDiff line change
@@ -369,66 +369,67 @@ void testActionDefForEach() {
369369
}
370370

371371
/**
372-
* @see <a href="https://github.com/serverlessworkflow/sdk-java/issues/213">Retry definition validation doesn't work</a>
372+
* @see <a href="https://github.com/serverlessworkflow/sdk-java/issues/213">Retry definition
373+
* validation doesn't work</a>
373374
*/
374375
@Test
375376
public void testValidateRetry() {
376377
WorkflowValidator workflowValidator = new WorkflowValidatorImpl();
377378
List<ValidationError> validationErrors =
378-
workflowValidator
379-
.setSource(
380-
"{\n"
381-
+ " \"id\": \"workflow_1\",\n"
382-
+ " \"name\": \"workflow_1\",\n"
383-
+ " \"description\": \"workflow_1\",\n"
384-
+ " \"version\": \"1.0\",\n"
385-
+ " \"specVersion\": \"0.8\",\n"
386-
+ " \"start\": \"Task1\",\n"
387-
+ " \"functions\": [\n"
388-
+ " {\n"
389-
+ " \"name\": \"increment\",\n"
390-
+ " \"type\": \"custom\",\n"
391-
+ " \"operation\": \"worker\"\n"
392-
+ " }\n"
393-
+ " ],\n"
394-
+ " \"retries\": [\n"
395-
+ " {\n"
396-
+ " \"maxAttempts\": 3\n"
397-
+ " },\n"
398-
+ " {\n"
399-
+ " \"name\": \"testRetry\" \n"
400-
+ " }\n"
401-
+ " ],\n"
402-
+ " \"states\": [\n"
403-
+ " {\n"
404-
+ " \"name\": \"Task1\",\n"
405-
+ " \"type\": \"operation\",\n"
406-
+ " \"actionMode\": \"sequential\",\n"
407-
+ " \"actions\": [\n"
408-
+ " {\n"
409-
+ " \"functionRef\": {\n"
410-
+ " \"refName\": \"increment\",\n"
411-
+ " \"arguments\": {\n"
412-
+ " \"input\": \"some text\"\n"
413-
+ " }\n"
414-
+ " },\n"
415-
+ " \"retryRef\": \"const\",\n"
416-
+ " \"actionDataFilter\": {\n"
417-
+ " \"toStateData\": \"${ .result }\"\n"
418-
+ " }\n"
419-
+ " }\n"
420-
+ " ],\n"
421-
+ " \"end\": true\n"
422-
+ " }\n"
423-
+ " ]\n"
424-
+ "}")
425-
.validate();
379+
workflowValidator
380+
.setSource(
381+
"{\n"
382+
+ " \"id\": \"workflow_1\",\n"
383+
+ " \"name\": \"workflow_1\",\n"
384+
+ " \"description\": \"workflow_1\",\n"
385+
+ " \"version\": \"1.0\",\n"
386+
+ " \"specVersion\": \"0.8\",\n"
387+
+ " \"start\": \"Task1\",\n"
388+
+ " \"functions\": [\n"
389+
+ " {\n"
390+
+ " \"name\": \"increment\",\n"
391+
+ " \"type\": \"custom\",\n"
392+
+ " \"operation\": \"worker\"\n"
393+
+ " }\n"
394+
+ " ],\n"
395+
+ " \"retries\": [\n"
396+
+ " {\n"
397+
+ " \"maxAttempts\": 3\n"
398+
+ " },\n"
399+
+ " {\n"
400+
+ " \"name\": \"testRetry\" \n"
401+
+ " }\n"
402+
+ " ],\n"
403+
+ " \"states\": [\n"
404+
+ " {\n"
405+
+ " \"name\": \"Task1\",\n"
406+
+ " \"type\": \"operation\",\n"
407+
+ " \"actionMode\": \"sequential\",\n"
408+
+ " \"actions\": [\n"
409+
+ " {\n"
410+
+ " \"functionRef\": {\n"
411+
+ " \"refName\": \"increment\",\n"
412+
+ " \"arguments\": {\n"
413+
+ " \"input\": \"some text\"\n"
414+
+ " }\n"
415+
+ " },\n"
416+
+ " \"retryRef\": \"const\",\n"
417+
+ " \"actionDataFilter\": {\n"
418+
+ " \"toStateData\": \"${ .result }\"\n"
419+
+ " }\n"
420+
+ " }\n"
421+
+ " ],\n"
422+
+ " \"end\": true\n"
423+
+ " }\n"
424+
+ " ]\n"
425+
+ "}")
426+
.validate();
426427

427428
Assertions.assertNotNull(validationErrors);
428429
Assertions.assertEquals(2, validationErrors.size());
429430
Assertions.assertEquals("Retry name should not be empty", validationErrors.get(0).getMessage());
430431
Assertions.assertEquals(
431-
"Operation State action 'null' retryRef does not reference an existing workflow retry definition",
432-
validationErrors.get(1).getMessage());
432+
"Operation State action 'null' retryRef does not reference an existing workflow retry definition",
433+
validationErrors.get(1).getMessage());
433434
}
434435
}

0 commit comments

Comments
 (0)