public class MockOperations extends Object
Operations to perform mocking
| Constructor and Description |
|---|
MockOperations() |
| Modifier and Type | Method and Description |
|---|---|
void |
mockWhen(String processor,
List<org.mule.munit.common.model.Attribute> withAttributes,
org.mule.munit.common.model.Event thenReturn)
Mocks the
processor that has the given withAttributes, replacing it with the given thenReturn Event. |
protected void |
setMockModule(org.mule.munit.mock.MockModule mockModule) |
protected void |
setRegistry(org.mule.runtime.api.artifact.Registry registry) |
void |
spy(String processor,
List<org.mule.munit.common.model.Attribute> withAttributes,
BeforeCall beforeCall,
AfterCall afterCall,
org.mule.runtime.extension.api.runtime.process.RouterCompletionCallback callback)
Spies the
processor that has the given withAttributes, executing logic before and after its execution. |
void |
verifyCall(String processor,
List<org.mule.munit.common.model.Attribute> withAttributes,
Integer times,
Integer atLeast,
Integer atMost)
Verifies that the
processor that has the given withAttributes has been executed. |
@Summary(value="Mock the Processor when it matches processor name and attributes")
public void mockWhen(@Example(value="http:request")
String processor,
@Optional @Expression(value=NOT_SUPPORTED)
List<org.mule.munit.common.model.Attribute> withAttributes,
@Optional @Expression(value=NOT_SUPPORTED)
org.mule.munit.common.model.Event thenReturn)
processor that has the given withAttributes, replacing it with the given thenReturn Event.
During the test execution, if any processor tries to be executed, and it matches the processor name and the
withAttributes, its execution its not performed, and instead the thenReturn Event is returned. If no
thenReturn is specified, the incoming event is returned.
processor - identifier of the processor to mockwithAttributes - additional attributes to identify the processorthenReturn - Event to be returned when mocking the processor@Summary(value="Verify that a processor is called")
public void verifyCall(@Example(value="mule:logger")
String processor,
@Optional @Expression(value=NOT_SUPPORTED)
List<org.mule.munit.common.model.Attribute> withAttributes,
@Optional
Integer times,
@Optional
Integer atLeast,
@Optional
Integer atMost)
processor that has the given withAttributes has been executed.
During the test execution, if any processor is executed, and it matches the processor name and the
withAttributes it will be counted as called.
If the processor was not called the specified number of times, it will throw an AssertionError
processor - identifier of the processor to mockwithAttributes - additional attributes to identify the processortimes - exact number of times the processor should have been executedatLeast - minimum number of times the processor should have been executedatMost - maximum number of times the processor should have been executed@Summary(value="Allows to take actions over the event before and after the execution of a processor") public void spy(String processor, @Optional @NullSafe @Expression(value=NOT_SUPPORTED) List<org.mule.munit.common.model.Attribute> withAttributes, @Optional BeforeCall beforeCall, @Optional AfterCall afterCall, org.mule.runtime.extension.api.runtime.process.RouterCompletionCallback callback)
processor that has the given withAttributes, executing logic before and after its execution.
During the test execution, if any processor tries to be executed, and it matches the processor name and the
withAttributes, the beforeCall will be executed before the processor, and the afterCall will be
executed after
processor - identifier of the processor to mockwithAttributes - additional attributes to identify the processorbeforeCall - processors to be executed before the spied processorafterCall - processors to be executed after the spied processorprotected void setRegistry(org.mule.runtime.api.artifact.Registry registry)
protected void setMockModule(org.mule.munit.mock.MockModule mockModule)
Copyright © 2018 MuleSoft, Inc.. All rights reserved.