public class FlowRunner extends FlowConstructRunner<FlowRunner>
This runner is not thread-safe.
eventBuilder, registry| Constructor and Description |
|---|
FlowRunner(org.mule.runtime.api.artifact.Registry registry,
String flowName)
Initializes this flow runner.
|
| Modifier and Type | Method and Description |
|---|---|
void |
dispatch()
Dispatches to the specified flow with the provided event and configuration, and performs a
FlowAssert#verify(String))
afterwards. |
void |
dispatchAsync(org.mule.runtime.api.scheduler.Scheduler scheduler)
Dispatches to the specified flow with the provided event and configuration in a new IO thread, and performs a
FlowAssert#verify(String)) afterwards. |
void |
dispose() |
protected FlowConstruct |
getFlowConstruct() |
String |
getFlowConstructName() |
FlowRunner |
keepStreamsOpen()
Makes all open
cursors to not be closed when the executed flow is finished but when the test is disposed |
CoreEvent |
run()
Runs the specified flow with the provided event and configuration, and performs a
FlowAssert#verify(String))
afterwards. |
CoreEvent |
runAndVerify(String... flowNamesToVerify)
Runs the specified flow with the provided event and configuration, and performs a
FlowAssert#verify(String)) for each
flowNamesToVerify afterwards. |
Exception |
runExpectingException()
Runs the specified flow with the provided event and configuration expecting a failure.
|
void |
runExpectingException(ErrorTypeMatcher matcher)
Runs the specified flow with the provided event and configuration expecting a failure with an error type that matches the
given
matcher. |
void |
runExpectingException(ErrorTypeMatcher matcher,
org.hamcrest.Matcher<CoreEvent> errorEventMatcher)
Runs the specified flow with the provided event and configuration expecting a failure with an
CoreEvent that matches
the given errorEventMatcher. |
void |
runExpectingException(EventMatcher errorEventMatcher)
Runs the specified flow with the provided event and configuration expecting a failure with an
CoreEvent that matches
the given errorEventMatcher. |
void |
runExpectingException(org.hamcrest.Matcher<Throwable> causeMatcher)
Runs the specified flow with the provided event and configuration expecting a failure with a cause that matches the given
matcher. |
void |
runExpectingException(org.hamcrest.Matcher<Throwable> causeMatcher,
org.hamcrest.Matcher<CoreEvent> errorEventMatcher)
Runs the specified flow with the provided event and configuration expecting a failure with an
CoreEvent that matches
the given errorEventMatcher. |
CoreEvent |
runNoVerify()
Runs the specified flow with the provided event and configuration.
|
FlowRunner |
transactionally(TransactionConfigEnum action,
TransactionFactory factory)
Configures the flow to run inside a transaction.
|
FlowRunner |
withScheduler(org.mule.runtime.api.scheduler.Scheduler scheduler)
Run
Flow as a task of a given Scheduler. |
buildEvent, getOrBuildEvent, reset, spyObjects, withAttributes, withCorrelation, withInboundAttachment, withInboundProperties, withInboundProperty, withItemSequenceInfo, withMediaType, withOutboundProperty, withPayload, withSessionProperty, withSourceCorrelationId, withVariable, withVariablepublic FlowRunner(org.mule.runtime.api.artifact.Registry registry,
String flowName)
registry - the registry for the currently running testflowName - the name of the flow to run events throughpublic FlowRunner transactionally(TransactionConfigEnum action, TransactionFactory factory)
action - The action to do at the start of the transactional block. See TransactionConfig constants.factory - See MuleTransactionConfig.setFactory(TransactionFactory).FlowRunnerpublic FlowRunner keepStreamsOpen()
cursors to not be closed when the executed flow is finished but when the test is disposedthis FlowRunnerpublic FlowRunner withScheduler(org.mule.runtime.api.scheduler.Scheduler scheduler)
Flow as a task of a given Scheduler.scheduler - the scheduler to use to run the Flow.FlowRunnerSchedulerService}public CoreEvent run() throws Exception
FlowAssert#verify(String))
afterwards.
If this is called multiple times, the same event will be sent. To force the creation of a new event, use
FlowConstructRunner.reset().
MuleEventExceptionpublic CoreEvent runNoVerify() throws Exception
If this is called multiple times, the same event will be sent. To force the creation of a new event, use
FlowConstructRunner.reset().
MuleEventExceptionpublic CoreEvent runAndVerify(String... flowNamesToVerify) throws Exception
FlowAssert#verify(String)) for each
flowNamesToVerify afterwards.
If this is called multiple times, the same event will be sent. To force the creation of a new event, use
FlowConstructRunner.reset().
flowNamesToVerify - the names of the flows to FlowAssert#verify(String)) afterwards.MuleEventExceptionpublic void dispatch()
throws Exception
FlowAssert#verify(String))
afterwards.
If this is called multiple times, the same event will be sent. To force the creation of a new event, use
FlowConstructRunner.reset().
Dispatch behaves differently to run() in that it does not propagate any exceptions to the test case or
return a result.
Exceptionpublic void dispatchAsync(org.mule.runtime.api.scheduler.Scheduler scheduler)
throws Exception
FlowAssert#verify(String)) afterwards.
If this is called multiple times, the same event will be sent. To force the creation of a new event, use
FlowConstructRunner.reset().
Dispatch behaves differently to run() in that it does not propagate any exceptions to the test case or
return a result.
Exceptionpublic Exception runExpectingException() throws Exception
Exceptionpublic void runExpectingException(ErrorTypeMatcher matcher) throws Exception
matcher.
Will fail if there's no failure running the flow.
Exceptionpublic void runExpectingException(org.hamcrest.Matcher<Throwable> causeMatcher) throws Exception
matcher.
Will fail if there's no failure running the flow.
Exceptionpublic void runExpectingException(EventMatcher errorEventMatcher) throws Exception
CoreEvent that matches
the given errorEventMatcher.
Will fail if there's no failure running the flow.
Exceptionpublic void runExpectingException(ErrorTypeMatcher matcher, org.hamcrest.Matcher<CoreEvent> errorEventMatcher) throws Exception
CoreEvent that matches
the given errorEventMatcher.
Will fail if there's no failure running the flow.
Exceptionpublic void runExpectingException(org.hamcrest.Matcher<Throwable> causeMatcher, org.hamcrest.Matcher<CoreEvent> errorEventMatcher) throws Exception
CoreEvent that matches
the given errorEventMatcher.
Will fail if there's no failure running the flow.
Exceptionpublic String getFlowConstructName()
getFlowConstructName in class FlowConstructRunner<FlowRunner>FlowConstruct to use.public void dispose()
dispose in interface org.mule.runtime.api.lifecycle.Disposabledispose in class FlowConstructRunner<FlowRunner>protected FlowConstruct getFlowConstruct()
getFlowConstruct in class FlowConstructRunner<FlowRunner>Copyright © 2003–2022 MuleSoft, Inc.. All rights reserved.