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());
+ }
+
+ @Test
+ void testFunctionCall() {
+ Workflow workflow =
+ new Workflow()
+ .withId("test-workflow")
+ .withVersion("1.0")
+ .withStart(new Start().withStateName("start"))
+ .withFunctions(
+ new Functions(
+ Arrays.asList(new FunctionDefinition("expression").withType(Type.EXPRESSION))))
+ .withStates(
+ Arrays.asList(
+ new OperationState()
+ .withName("start")
+ .withType(OPERATION)
+ .withActions(
+ Arrays.asList(
+ new Action().withFunctionRef(new FunctionRef("expression"))))
+ .withEnd(new End())));
+ Assertions.assertTrue(new WorkflowValidatorImpl().setWorkflow(workflow).validate().isEmpty());
+ }
+
+ @Test
+ void testEventCall() {
+ Workflow workflow =
+ new Workflow()
+ .withId("test-workflow")
+ .withVersion("1.0")
+ .withStart(new Start().withStateName("start"))
+ .withEvents(new Events(Arrays.asList(new EventDefinition().withName("event"))))
+ .withRetries(new Retries(Arrays.asList(new RetryDefinition("start", "PT1S"))))
+ .withStates(
+ Arrays.asList(
+ new OperationState()
+ .withName("start")
+ .withType(OPERATION)
+ .withActions(
+ Arrays.asList(
+ new Action()
+ .withEventRef(new EventRef().withTriggerEventRef("event"))))
+ .withEnd(new End())));
+ Assertions.assertTrue(new WorkflowValidatorImpl().setWorkflow(workflow).validate().isEmpty());
+ }
}
pFad - Phonifier reborn
Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies:
Alternative Proxy
pFad Proxy
pFad v3 Proxy
pFad v4 Proxy