use of org.mule.runtime.core.api.event.CoreEvent in project mule by mulesoft.
the class TopLevelParameterObjectFactory method doGetObject.
@Override
public Object doGetObject() throws Exception {
return withContextClassLoader(classLoader, () -> {
// TODO MULE-10919 - This logic is similar to that of the resolverset object builder and should
// be generalized
DefaultObjectBuilder builder = this.builder.get();
resolveParameters(objectType, builder);
resolveParameterGroups(objectType, builder);
injectFields();
ValueResolver<Object> resolver = new ObjectBuilderValueResolver<>(builder, muleContext);
if (resolver.isDynamic()) {
return resolver;
}
CoreEvent initialiserEvent = null;
try {
initialiserEvent = getInitialiserEvent(muleContext);
staticProduct = resolver.resolve(from(initialiserEvent));
muleContext.getInjector().inject(staticProduct);
return staticProduct;
} finally {
if (initialiserEvent != null) {
((BaseEventContext) initialiserEvent.getContext()).success();
}
}
}, Exception.class, exception -> {
throw exception;
});
}
use of org.mule.runtime.core.api.event.CoreEvent in project mule by mulesoft.
the class AbstractConfigParserTestCase method getHeisenbergEvent.
protected CoreEvent getHeisenbergEvent() throws Exception {
WEAPON.setMicrogramsPerKilo(10L);
CoreEvent event = CoreEvent.builder(create(getTestFlow(muleContext), TEST_CONNECTOR_LOCATION)).message(of("")).addVariable("lidia", LIDIA).addVariable("myName", HeisenbergExtension.HEISENBERG).addVariable("age", HeisenbergExtension.AGE).addVariable("microgramsPerKilo", MICROGRAMS_PER_KILO).addVariable("steviaCoffeShop", STEVIA_COFFE_SHOP).addVariable("pollosHermanos", POLLOS_HERMANOS).addVariable("gustavoFring", GUSTAVO_FRING).addVariable("krazy8", KRAZY_8).addVariable("jesses", JESSE_S).addVariable("methylamine", METHYLAMINE_QUANTITY).addVariable("pseudoephedrine", PSEUDOEPHEDRINE_QUANTITY).addVariable("p2p", P2P_QUANTITY).addVariable("hank", HANK).addVariable("money", MONEY).addVariable("skyler", SKYLER).addVariable("saul", SAUL).addVariable("whiteAddress", WHITE_ADDRESS).addVariable("shoppingMall", SHOPPING_MALL).addVariable("initialHealth", INITIAL_HEALTH).addVariable("finalHealth", FINAL_HEALTH).addVariable("weaponType", FIRE_WEAPON).addVariable("weapon", WEAPON).build();
return event;
}
use of org.mule.runtime.core.api.event.CoreEvent in project mule by mulesoft.
the class OperationExecutionTestCase method doTestExpressionEnemy.
private void doTestExpressionEnemy(Object enemyIndex) throws Exception {
CoreEvent event = flowRunner("expressionEnemy").withPayload(EMPTY).withVariable("enemy", enemyIndex).run();
assertThat(event.getMessage().getPayload().getValue(), is(GUSTAVO_FRING));
}
use of org.mule.runtime.core.api.event.CoreEvent in project mule by mulesoft.
the class OperationExecutionTestCase method voidOperationWithoutParameters.
@Test
public void voidOperationWithoutParameters() throws Exception {
CoreEvent responseEvent = flowRunner("die").withPayload(EMPTY).run();
assertThat(responseEvent.getMessage().getPayload().getValue(), is(EMPTY));
assertThat(getConfig(HEISENBERG).getEndingHealth(), is(DEAD));
}
use of org.mule.runtime.core.api.event.CoreEvent 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));
}
Aggregations