Search in sources :

Example 6 with ResponseMessageProcessorAdapter

use of org.mule.runtime.core.internal.processor.ResponseMessageProcessorAdapter in project mule by mulesoft.

the class DefaultMessageProcessorChainTestCase method testNestedResponseProcessorEndOfChain.

@Test
public void testNestedResponseProcessorEndOfChain() throws Exception {
    DefaultMessageProcessorChainBuilder builder = new DefaultMessageProcessorChainBuilder();
    final MessageProcessorChain chain = newChain(empty(), singletonList(getAppendingMP("1")));
    final ResponseMessageProcessorAdapter responseMessageProcessorAdapter = new ResponseMessageProcessorAdapter(chain);
    responseMessageProcessorAdapter.setMuleContext(muleContext);
    builder.chain(responseMessageProcessorAdapter);
    process(builder.build(), getTestEventUsingFlow("0"));
    assertThat(process(builder.build(), getTestEventUsingFlow("0")).getMessage().getPayload().getValue(), equalTo("01"));
}
Also used : ResponseMessageProcessorAdapter(org.mule.runtime.core.internal.processor.ResponseMessageProcessorAdapter) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 7 with ResponseMessageProcessorAdapter

use of org.mule.runtime.core.internal.processor.ResponseMessageProcessorAdapter in project mule by mulesoft.

the class ResponseMessageProcessorsFactoryBean method doGetObject.

@Override
public ResponseMessageProcessorAdapter doGetObject() throws Exception {
    DefaultMessageProcessorChainBuilder builder = new DefaultMessageProcessorChainBuilder();
    builder.setName("'response' child processor chain");
    for (Object processor : messageProcessors) {
        if (processor instanceof Processor) {
            builder.chain((Processor) processor);
        } else if (processor instanceof MessageProcessorBuilder) {
            builder.chain((MessageProcessorBuilder) processor);
        } else {
            throw new IllegalArgumentException("MessageProcessorBuilder should only have MessageProcessor's or MessageProcessorBuilder's configured");
        }
    }
    ResponseMessageProcessorAdapter responseAdapter = new ResponseMessageProcessorAdapter();
    responseAdapter.setProcessor(newLazyProcessorChainBuilder(builder, muleContext, () -> getProcessingStrategy(locator, getRootContainerLocation()).orElse(null)));
    responseAdapter.setMuleContext(muleContext);
    return responseAdapter;
}
Also used : DefaultMessageProcessorChainBuilder(org.mule.runtime.core.privileged.processor.chain.DefaultMessageProcessorChainBuilder) ResponseMessageProcessorAdapter(org.mule.runtime.core.internal.processor.ResponseMessageProcessorAdapter) Processor(org.mule.runtime.core.api.processor.Processor) MessageProcessorBuilder(org.mule.runtime.core.privileged.processor.MessageProcessorBuilder)

Aggregations

ResponseMessageProcessorAdapter (org.mule.runtime.core.internal.processor.ResponseMessageProcessorAdapter)7 Test (org.junit.Test)5 SmallTest (org.mule.tck.size.SmallTest)5 Processor (org.mule.runtime.core.api.processor.Processor)2 ArrayList (java.util.ArrayList)1 ReactiveProcessor (org.mule.runtime.core.api.processor.ReactiveProcessor)1 StringAppendTransformer (org.mule.runtime.core.internal.transformer.simple.StringAppendTransformer)1 MessageProcessorBuilder (org.mule.runtime.core.privileged.processor.MessageProcessorBuilder)1 DefaultMessageProcessorChainBuilder (org.mule.runtime.core.privileged.processor.chain.DefaultMessageProcessorChainBuilder)1 SensingNullMessageProcessor (org.mule.tck.SensingNullMessageProcessor)1 LifecycleTrackerProcessor (org.mule.tck.core.lifecycle.LifecycleTrackerProcessor)1