Skip to content

fix validation for callback state #188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ public List<ValidationError> validate() {
ValidationError.WORKFLOW_VALIDATION);
}

if (haveFunctionDefinition(
if (!haveFunctionDefinition(
callbackState.getAction().getFunctionRef().getRefName(), functions)) {
addValidationError(
"CallbackState action function ref does not reference a defined workflow function definition",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,4 +213,48 @@ public void testValidateWorkflowForOptionalIterationParam() {
1,
validationErrors.size()); // validation error raised for functionref not for iterationParam
}

@Test
public void testMissingFunctionRefForCallbackState() {
WorkflowValidator workflowValidator = new WorkflowValidatorImpl();
List<ValidationError> validationErrors =
workflowValidator
.setSource(
"{\n"
+ " \"id\": \"callbackstatemissingfuncref\",\n"
+ " \"version\": \"1.0\",\n"
+ " \"specVersion\": \"0.8\",\n"
+ " \"name\": \"Callback State Test\",\n"
+ " \"start\": \"CheckCredit\",\n"
+ " \"states\": [\n"
+ " {\n"
+ " \"name\": \"CheckCredit\",\n"
+ " \"type\": \"callback\",\n"
+ " \"action\": {\n"
+ " \"functionRef\": {\n"
+ " \"refName\": \"callCreditCheckMicroservice\",\n"
+ " \"arguments\": {\n"
+ " \"customer\": \"${ .customer }\"\n"
+ " }\n"
+ " }\n"
+ " },\n"
+ " \"eventRef\": \"CreditCheckCompletedEvent\",\n"
+ " \"timeouts\": {\n"
+ " \"stateExecTimeout\": \"PT15M\"\n"
+ " },\n"
+ " \"end\": true\n"
+ " }\n"
+ " ]\n"
+ "}")
.validate();

Assertions.assertNotNull(validationErrors);
Assertions.assertEquals(2, validationErrors.size());
Assertions.assertEquals(
"CallbackState event ref does not reference a defined workflow event definition",
validationErrors.get(0).getMessage());
Assertions.assertEquals(
"CallbackState action function ref does not reference a defined workflow function definition",
validationErrors.get(1).getMessage());
}
}