@@ -380,61 +380,61 @@ void testActionDefForEach() {
380380 public void testValidateRetry () {
381381 WorkflowValidator workflowValidator = new WorkflowValidatorImpl ();
382382 List <ValidationError > validationErrors =
383- workflowValidator
384- .setSource (
385- "{\n "
386- + " \" id\" : \" workflow_1\" ,\n "
387- + " \" name\" : \" workflow_1\" ,\n "
388- + " \" description\" : \" workflow_1\" ,\n "
389- + " \" version\" : \" 1.0\" ,\n "
390- + " \" specVersion\" : \" 0.8\" ,\n "
391- + " \" start\" : \" Task1\" ,\n "
392- + " \" functions\" : [\n "
393- + " {\n "
394- + " \" name\" : \" increment\" ,\n "
395- + " \" type\" : \" custom\" ,\n "
396- + " \" operation\" : \" worker\" \n "
397- + " }\n "
398- + " ],\n "
399- + " \" retries\" : [\n "
400- + " {\n "
401- + " \" maxAttempts\" : 3\n "
402- + " },\n "
403- + " {\n "
404- + " \" name\" : \" testRetry\" \n "
405- + " }\n "
406- + " ],\n "
407- + " \" states\" : [\n "
408- + " {\n "
409- + " \" name\" : \" Task1\" ,\n "
410- + " \" type\" : \" operation\" ,\n "
411- + " \" actionMode\" : \" sequential\" ,\n "
412- + " \" actions\" : [\n "
413- + " {\n "
414- + " \" functionRef\" : {\n "
415- + " \" refName\" : \" increment\" ,\n "
416- + " \" arguments\" : {\n "
417- + " \" input\" : \" some text\" \n "
418- + " }\n "
419- + " },\n "
420- + " \" retryRef\" : \" const\" ,\n "
421- + " \" actionDataFilter\" : {\n "
422- + " \" toStateData\" : \" ${ .result }\" \n "
423- + " }\n "
424- + " }\n "
425- + " ],\n "
426- + " \" end\" : true\n "
427- + " }\n "
428- + " ]\n "
429- + "}" )
430- .validate ();
383+ workflowValidator
384+ .setSource (
385+ "{\n "
386+ + " \" id\" : \" workflow_1\" ,\n "
387+ + " \" name\" : \" workflow_1\" ,\n "
388+ + " \" description\" : \" workflow_1\" ,\n "
389+ + " \" version\" : \" 1.0\" ,\n "
390+ + " \" specVersion\" : \" 0.8\" ,\n "
391+ + " \" start\" : \" Task1\" ,\n "
392+ + " \" functions\" : [\n "
393+ + " {\n "
394+ + " \" name\" : \" increment\" ,\n "
395+ + " \" type\" : \" custom\" ,\n "
396+ + " \" operation\" : \" worker\" \n "
397+ + " }\n "
398+ + " ],\n "
399+ + " \" retries\" : [\n "
400+ + " {\n "
401+ + " \" maxAttempts\" : 3\n "
402+ + " },\n "
403+ + " {\n "
404+ + " \" name\" : \" testRetry\" \n "
405+ + " }\n "
406+ + " ],\n "
407+ + " \" states\" : [\n "
408+ + " {\n "
409+ + " \" name\" : \" Task1\" ,\n "
410+ + " \" type\" : \" operation\" ,\n "
411+ + " \" actionMode\" : \" sequential\" ,\n "
412+ + " \" actions\" : [\n "
413+ + " {\n "
414+ + " \" functionRef\" : {\n "
415+ + " \" refName\" : \" increment\" ,\n "
416+ + " \" arguments\" : {\n "
417+ + " \" input\" : \" some text\" \n "
418+ + " }\n "
419+ + " },\n "
420+ + " \" retryRef\" : \" const\" ,\n "
421+ + " \" actionDataFilter\" : {\n "
422+ + " \" toStateData\" : \" ${ .result }\" \n "
423+ + " }\n "
424+ + " }\n "
425+ + " ],\n "
426+ + " \" end\" : true\n "
427+ + " }\n "
428+ + " ]\n "
429+ + "}" )
430+ .validate ();
431431
432432 Assertions .assertNotNull (validationErrors );
433433 Assertions .assertEquals (2 , validationErrors .size ());
434434 Assertions .assertEquals ("Retry name should not be empty" , validationErrors .get (0 ).getMessage ());
435435 Assertions .assertEquals (
436- "Operation State action 'null' retryRef does not reference an existing workflow retry definition" ,
437- validationErrors .get (1 ).getMessage ());
436+ "Operation State action 'null' retryRef does not reference an existing workflow retry definition" ,
437+ validationErrors .get (1 ).getMessage ());
438438 }
439439
440440 /**
@@ -459,4 +459,66 @@ void testErrorsArrayParsing() {
459459 Assertions .assertTrue (
460460 new WorkflowValidatorImpl ().setSource (Workflow .toJson (workflow )).isValid ());
461461 }
462+
463+ /**
464+ * @see <a href="https://github.com/serverlessworkflow/sdk-java/issues/357">Error parsing Oauth
465+ * properties in cncf spec using java sdk</a>
466+ */
467+ @ Test
468+ void testOAuthPropertiesDefinition () {
469+ final Workflow workflow =
470+ Workflow .fromSource (
471+ "{\n "
472+ + " \" version\" : \" 1.0.0\" ,\n "
473+ + " \" id\" : \" greeting-workflow\" , \n "
474+ + " \" specVersion\" : \" 0.8\" ,\n "
475+ + " \" name\" : \" greeting-workflow\" ,\n "
476+ + " \" description\" : \" Greet Someone\" ,\n "
477+ + " \" start\" : \" greet\" ,\n "
478+ + " \" auth\" : [\n "
479+ + " {\n "
480+ + " \" name\" : \" serviceCloud\" ,\n "
481+ + " \" scheme\" : \" oauth2\" ,\n "
482+ + " \" properties\" : {\n "
483+ + " \" scopes\" : [\" $$$$XXXMMMMM\" ],\n "
484+ + " \" audiences\" : [\" %%%XXXXXXX\" ],\n "
485+ + " \" clientId\" : \" whatever\" ,\n "
486+ + " \" grantType\" : \" password\" \n "
487+ + " }\n "
488+ + " }\n "
489+ + " ],\n "
490+ + " \" functions\" : [\n "
491+ + " {\n "
492+ + " \" name\" : \" greeting-function\" ,\n "
493+ + " \" type\" : \" rest\" ,\n "
494+ + " \" operation\" : \" file://myapis/greetingapis.json#greeting\" \n "
495+ + " }\n "
496+ + " ],\n "
497+ + " \" states\" : [\n "
498+ + " {\n "
499+ + " \" name\" : \" greet\" ,\n "
500+ + " \" type\" : \" operation\" ,\n "
501+ + " \" actions\" : [\n "
502+ + " {\n "
503+ + " \" name\" : \" greet-action\" ,\n "
504+ + " \" functionRef\" : {\n "
505+ + " \" refName\" : \" greeting-function\" ,\n "
506+ + " \" arguments\" : {\n "
507+ + " \" name\" : \" ${ .person.name }\" \n "
508+ + " }\n "
509+ + " },\n "
510+ + " \" actionDataFilter\" : {\n "
511+ + " \" results\" : \" ${ {greeting: .greeting} }\" \n "
512+ + " }\n "
513+ + " }\n "
514+ + " ],\n "
515+ + " \" end\" : true\n "
516+ + " }\n "
517+ + " ]\n "
518+ + "}\n " );
519+ final List <ValidationError > validationErrors =
520+ new WorkflowValidatorImpl ().setWorkflow (workflow ).validate ();
521+
522+ Assertions .assertTrue (validationErrors .isEmpty ());
523+ }
462524}
0 commit comments