Search in sources :

Example 91 with CoreEvent

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;
    });
}
Also used : BaseEventContext(org.mule.runtime.core.privileged.event.BaseEventContext) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) ObjectBuilderValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.ObjectBuilderValueResolver) DefaultObjectBuilder(org.mule.runtime.module.extension.internal.runtime.objectbuilder.DefaultObjectBuilder)

Example 92 with CoreEvent

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;
}
Also used : CoreEvent(org.mule.runtime.core.api.event.CoreEvent)

Example 93 with CoreEvent

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));
}
Also used : CoreEvent(org.mule.runtime.core.api.event.CoreEvent)

Example 94 with CoreEvent

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));
}
Also used : CoreEvent(org.mule.runtime.core.api.event.CoreEvent) Test(org.junit.Test)

Example 95 with CoreEvent

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));
}
Also used : FlowRunner(org.mule.functional.api.flow.FlowRunner) Message(org.mule.runtime.api.message.Message) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) Test(org.junit.Test)

Aggregations

CoreEvent (org.mule.runtime.core.api.event.CoreEvent)485 Test (org.junit.Test)394 Message (org.mule.runtime.api.message.Message)103 SmallTest (org.mule.tck.size.SmallTest)100 TypedValue (org.mule.runtime.api.metadata.TypedValue)44 MessagingException (org.mule.runtime.core.internal.exception.MessagingException)39 BaseEventContext (org.mule.runtime.core.privileged.event.BaseEventContext)38 Description (io.qameta.allure.Description)37 InternalMessage (org.mule.runtime.core.internal.message.InternalMessage)37 List (java.util.List)36 MuleException (org.mule.runtime.api.exception.MuleException)33 Processor (org.mule.runtime.core.api.processor.Processor)33 DataType (org.mule.runtime.api.metadata.DataType)28 InternalEvent (org.mule.runtime.core.internal.message.InternalEvent)28 ComponentLocation (org.mule.runtime.api.component.location.ComponentLocation)27 ArrayList (java.util.ArrayList)26 Map (java.util.Map)26 Optional (java.util.Optional)25 PrivilegedEvent (org.mule.runtime.core.privileged.event.PrivilegedEvent)23 InOrder (org.mockito.InOrder)22