use of org.mule.functional.api.flow.FlowRunner in project mule by mulesoft.
the class OperationExecutionTestCase method operationWithReturnValueOnTarget.
@Test
public void operationWithReturnValueOnTarget() throws Exception {
FlowRunner runner = flowRunner("sayMyNameOnTarget").withPayload(EMPTY_STRING);
CoreEvent responseEvent = runner.run();
assertThat(responseEvent.getMessage().getPayload().getValue(), is(EMPTY_STRING));
Message responseMessage = (Message) responseEvent.getVariables().get("myFace").getValue();
assertThat(responseMessage.getPayload().getValue(), is(HEISENBERG));
}
use of org.mule.functional.api.flow.FlowRunner in project mule by mulesoft.
the class DynamicConfigExpirationTestCase method invokeDynamicConfig.
private HeisenbergExtension invokeDynamicConfig(String flowName, String configName, String payload) throws Exception {
FlowRunner runner = flowRunner(flowName).withPayload(payload);
final CoreEvent event = runner.buildEvent();
String returnedName = getPayloadAsString(runner.run().getMessage());
HeisenbergExtension config = (HeisenbergExtension) muleContext.getExtensionManager().getConfiguration(configName, event).getValue();
// validate we actually hit the correct dynamic config
assertThat(returnedName, is(payload));
assertThat(config.getPersonalInfo().getName(), is(payload));
return config;
}
use of org.mule.functional.api.flow.FlowRunner in project mule by mulesoft.
the class AbstractDeploymentTestCase method executeApplicationFlow.
protected void executeApplicationFlow(String flowName) throws Exception {
ClassLoader appClassLoader = deploymentService.getApplications().get(0).getArtifactClassLoader().getClassLoader();
withContextClassLoader(appClassLoader, () -> {
final FlowRunner flowRunner = new FlowRunner(deploymentService.getApplications().get(0).getRegistry(), flowName);
CoreEvent result = flowRunner.withPayload(TEST_MESSAGE).run();
flowRunner.dispose();
assertThat(currentThread().getContextClassLoader(), sameInstance(appClassLoader));
return result;
});
}
use of org.mule.functional.api.flow.FlowRunner in project mule by mulesoft.
the class FunctionalTestCase method flowRunner.
/**
* Initializes a builder to construct an event and the running context to run it through a flow.
*
* @param flowName
* @return the {@link FlowRunner}
*/
protected FlowRunner flowRunner(String flowName) {
synchronized (runners) {
if (tearingDown) {
throw new IllegalStateException("Already tearing down.");
}
final FlowRunner flowRunner = new FlowRunner(registry, flowName);
runners.add(flowRunner);
return flowRunner;
}
}
Aggregations