1
0
-1

2 answers

  1.  
    1
    0
    -1

    Yes, the Fluent SDK development environment creates a sample Fluent Job Action Service and a test case.

    Service code is:

    class FluentJobActionService {

        /*
         * Perform a job action service invocation
         *
         * return: the job action result
         */
        ActionResult invoke(SvcDef svcDef, Job job, JobAction jobAction, HttpServletRequest request, User user) {

            // TODO: perform your logic

            String xml = Jobs.getStartTxnXml(job)

            Path path = new Path(xml)

            String email = path.val('//Contact/Email')

            return new ActionResultBuilder()
                .setStatus('Completed')
                .setMessage('Action completed for: ' + email)
                .build()
        }
    }

    And the sample test case is:

    class JobActionTest {

        /*
         * Perform service unit test
         *
         * throws exception if unit test fails
         */
        void invoke(SvcDef svcDef, Map testParams) throws Exception {

            String formXml = testParams['Test XML Data']
            Job job = new MockVoBuilder().createJobInProgressWithXml(formXml)
            JobAction jobAction = job.jobSteps[0].jobActions[0]
            MockRequest request = new MockRequest()

            Map params = [
                "svcDef": svcDef,
                "job": job,
                "jobAction": jobAction,
                "request": request,
                "user": null
            ]

            ActionResult result = (ActionResult) new ServiceInvoker(svcDef).invoke(params)

            logger.info 'result: ' + result

            assert result != null

            assert result.message == 'Action completed for: john.smith@avoka.com'
        }
    }

     

      CommentAdd your comment...
    1.  
      1
      0
      -1

      Fluent Job Actions have automated using testing support in TM 5.0. Please see the unit test harness provided with the Fluent Job Action templates and associated documentation.

      A Job typically has a start step with a Form Start action which holds the initial submission. This can be mocked in Fluent Job Actions in TM 5.0. 

      • An example is a unit test a job action that sends an email confirmation to the start or previous submitter.
      • A job Action that runs after any task submission can also be mocked using this method as long as the groovy code refers to the previous submission.

      Jobs may have several review steps which have Task Assign and Task Wait actions. The Task Assign actions have linked submissions which need to be filled out and submitted. As the job progresses through the steps and actions creates a complex job graph of objects. The creation of these complex job graphs is not currently supported by the unit test mocking service in TM 5.0. This is an area for potential improvements in the product.

      For instance, is not currently possible to create a unit test if your job action's processing refers to more than 1 submissions in the job graph or multiple steps / actions.

      TM 5.0 became GA in December 2016, I believe now that it is being used in anger we will develop and refine out techniques for unit testing Fluent Jobs Actions. We may find creative ways to test Job Actions that require a complex Job graph.

      Lastly TM 4.x does not provide support for testing the older Groovy Job Action services.

       

      Cheers

      Larry Bunton

        CommentAdd your comment...