Package org.mule.api

Examples of org.mule.api.MuleEvent


    @Override
    public MuleEvent process(MuleEvent event) throws MuleException
    {

        MuleEvent process = super.process(event);
        return process;


    }
View Full Code Here


    @Test
    public void testMockMp() throws Exception
    {
        whenMessageProcessor("echo-component").thenReturn(muleMessageWithPayload("expectedPayload"));

        MuleEvent eventResult = runFlow("echoFlow", testEvent("anotherString"));

        assertEquals("expectedPayload", eventResult.getMessage().getPayload());

    }
View Full Code Here

    @Test
    public void testMockWithoutChangingPayload() throws Exception
    {
        whenMessageProcessor("create-group").ofNamespace("jira").thenReturnSameEvent();

        MuleEvent eventResult = runFlow("callingJira", testEvent(" Hello world!"));

        assertEquals(" Hello world!", eventResult.getMessage().getPayload());
    }
View Full Code Here

        whenMessageProcessor("create-group")
                .ofNamespace("jira")
                .withAttributes(attributes())
                .thenReturn(muleMessageWithPayload("expectedPayload"));

        MuleEvent eventResult = runFlow("callingJira", testEvent("anotherString"));

        verifyCallOfMessageProcessor("create-group")
                .ofNamespace("jira").atLeast(1);

        verifyCallOfMessageProcessor("create-group")
                .ofNamespace("jira").times(1);

        assertEquals("expectedPayload", eventResult.getMessage().getPayload());

    }
View Full Code Here

        whenMessageProcessor("create-group")
                .ofNamespace("jira")
                .withAttributes(anyAttributes())
                .thenReturn(muleMessageWithPayload("createGroupResult"));

        MuleEvent eventResult = runFlow("main", testEvent(" Hello world!]"));

        assertEquals("createGroupResult", eventResult.getMessage().getPayload());
        assertEquals("someGroup", eventResult.getMessage().getInvocationProperty("job"));
    }
View Full Code Here

    @Test
    public void createSpyIsCorrect() throws MuleException
    {
        SpyProcess spyProcess = module().createSpy(createMessageProcessors());

        MuleEvent event = mock(MuleEvent.class);
        spyProcess.spy(event);

        verify(messageProcessor, times(1)).process(event);
    }
View Full Code Here

        MuleMessage expectedMessage = muleMessage();

        when(manager.getBetterMatchingBehavior(any(MessageProcessorCall.class))).thenReturn(returnValueBehavior());
        when(event.getMessage()).thenReturn(expectedMessage);

        MuleEvent processed = (MuleEvent) interceptor.process(new Object(), new Object[] {event}, proxy);

        verify(manager).addCall(any(MunitMessageProcessorCall.class));
        assertEquals(expectedMessage, processed.getMessage());
    }
View Full Code Here

        when(manager.getBetterMatchingBeforeSpyAssertion(any(MessageProcessorCall.class))).thenReturn(spyAssertion(createAssertions(beforeAssertionMp)));
        when(manager.getBetterMatchingAfterSpyAssertion(any(MessageProcessorCall.class))).thenReturn(spyAssertion(createAssertions(afterAssertionMp)));
        when(manager.getBetterMatchingBehavior(any(MessageProcessorCall.class))).thenReturn(returnValueBehavior());
        when(event.getMessage()).thenReturn(expectedMessage);

        MuleEvent processed = (MuleEvent) interceptor.process(new Object(), new Object[] {event}, proxy);

        verify(manager).addCall(any(MunitMessageProcessorCall.class));
        assertEquals(expectedMessage, processed.getMessage());
        assertTrue(beforeAssertionMp.called);
        assertTrue(afterAssertionMp.called);
    }
View Full Code Here

        when(manager.getBetterMatchingBeforeSpyAssertion(any(MessageProcessorCall.class))).thenReturn(spyAssertion(createAssertions(beforeAssertionMp)));
        when(manager.getBetterMatchingAfterSpyAssertion(any(MessageProcessorCall.class))).thenReturn(spyAssertion(createAssertions(afterAssertionMp)));
        when(manager.getBetterMatchingBehavior(any(MessageProcessorCall.class))).thenReturn(returnValueBehavior());
        when(event.getMessage()).thenReturn(expectedMessage);

        MuleEvent processed = (MuleEvent) interceptor.process(new Object(), new Object[] {event}, proxy);

        verify(manager).addCall(any(MunitMessageProcessorCall.class));
        assertEquals(expectedMessage, processed.getMessage());
        assertTrue(beforeAssertionMp.called);
        assertTrue(afterAssertionMp.called);
    }
View Full Code Here

    private String fileName;
    private String lineNumber;

    public Object process(Object obj, Object[] args, MethodProxy proxy) throws Throwable
    {
        MuleEvent event = (MuleEvent) args[0];

        MockedMessageProcessorManager manager = getMockedMessageProcessorManager(event.getMuleContext());

        MunitMessageProcessorCall messageProcessorCall = buildCall(event);
        runSpyAssertion(manager.getBetterMatchingBeforeSpyAssertion(messageProcessorCall), event);

        registerCall(manager, messageProcessorCall);
        MessageProcessorBehavior behavior = manager.getBetterMatchingBehavior(messageProcessorCall);
        if (behavior != null)
        {
            if (behavior.getExceptionToThrow() != null)
            {
                runSpyAssertion(manager.getBetterMatchingAfterSpyAssertion(messageProcessorCall), event);
                throw behavior.getExceptionToThrow();
            }

            if ( behavior.getMuleMessageTransformer() != null ){
                event.setMessage(behavior.getMuleMessageTransformer().transform(event.getMessage()));
            }

            runSpyAssertion(manager.getBetterMatchingAfterSpyAssertion(messageProcessorCall), event);
            return event;
        }
View Full Code Here

TOP

Related Classes of org.mule.api.MuleEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.