Contact Us 1-800-596-4880

Testing a Flow with a Scheduler Source

Assume that you want to both test the following flow triggered by a Scheduler component and validate that your flow is being triggered correctly:

<flow name="schedulerFlow">
        <scheduling-strategy >
            <fixed-frequency frequency="10" timeUnit="SECONDS"/>
    <set-payload value="#['test poll']"/>
  1. Enable flow sources.
    Because MUnit does not start any of the flow sources (such as triggers or listeners), you must configure which flow sources start for your tests.

    In this example, you enable the flow that contains the Scheduler:

    <munit:test name="test-schedulerFlowTest">
            <munit:enable-flow-source value="schedulerFlow"/>
  2. Verify that flow execution is triggered by the Scheduler.
    To verify that the processors inside your flow are being triggered, use the munit-tools:verify-call processor.

    Wrap munit-tools:verify-call inside an until-successful to shorten processing time when the Scheduler is not operating when you want to test.

    The following example validates three times that the payload was executed at least once during the test.

        <until-successful maxRetries="3" millisBetweenRetries="100">
            <munit-tools:verify-call processor="set-payload" atLeast="1">
                <munit-tools:with-attributes >
                    <munit-tools:with-attribute whereValue="#['test poll']" attributeName="value" />