public class

MockModule

extends Object
implements MuleContextAware BeanFactoryPostProcessor
java.lang.Object
   ↳ org.mule.munit.MockModule
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

Module for Mocking devkit Modules.

With this module you can mock using mockito framework all the modules that are written with Mule Devkit.

In order to be able to mock a module it has to be declare with a reference name. For example:

Otherwise the module/connector will not be accessible by a reference name and will not be able to be mocked.

Summary

Fields
private Class<? extends Object> connectionKeyClass
private ConnectionManager connectionManagerMock
private Object mock
private MuleContext muleContext
private String of

Component that we want to mock.

Public Constructors
MockModule()
Public Methods
void expect(String when, List<Object> parameters, Object mustReturn, String mustReturnResponseFrom)

Define what the mock must return on a message processor call.

void expectFail(String when, String throwA)

Expect to throw an exception when message processor is called.

void failOnConnect()
Throw an Exception when a connector tries to connect.
void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
void reset()
Reset mock behaviour
void setMuleContext(MuleContext muleContext)
void setOf(String of)

Set The name of the bean to be mocked.

void verifyCall(String messageProcessor, List<Object> parameters, Integer times, Integer atLeast, Integer atMost)
Check that the message processor was called with some specified parameters
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.mule.api.context.MuleContextAware
From interface org.springframework.beans.factory.config.BeanFactoryPostProcessor

Fields

private Class<? extends Object> connectionKeyClass

private ConnectionManager connectionManagerMock

private Object mock

private MuleContext muleContext

private String of

Component that we want to mock.

Public Constructors

public MockModule ()

Public Methods

public void expect (String when, List<Object> parameters, Object mustReturn, String mustReturnResponseFrom)

Define what the mock must return on a message processor call.

If the message processor doesn't return any value then there is no need to define an expect.

You can define the message processor parameters in the same order they appear in the API documentation. In order to define the behaviour on that particular case.

Parameters
when Message processor name.
parameters Message processor parameters.
mustReturn Expected return value.
mustReturnResponseFrom The flow name that creates the expected result

public void expectFail (String when, String throwA)

Expect to throw an exception when message processor is called.

Parameters
when Message processor name.
throwA Java Exception full qualified name.

public void failOnConnect ()

Throw an Exception when a connector tries to connect.

public void postProcessBeanFactory (ConfigurableListableBeanFactory beanFactory)

Parameters
beanFactory
Throws
BeansException

public void reset ()

Reset mock behaviour

public void setMuleContext (MuleContext muleContext)

Parameters
muleContext

public void setOf (String of)

Set The name of the bean to be mocked.

Parameters
of The name of the bean to be mocked

public void verifyCall (String messageProcessor, List<Object> parameters, Integer times, Integer atLeast, Integer atMost)

Check that the message processor was called with some specified parameters

Parameters
messageProcessor Message processor Id
parameters Message processor parameters.
times Number of times the message processor has to be called
atLeast Number of time the message processor has to be called at least.
atMost Number of times the message processor has to be called at most.