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.Answer answer,
org.mule.runtime.extension.api.runtime.streaming.StreamingHelper streamingHelper)
Mocks the
processor that has the given withAttributes, replacing it with the given answer. |
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,
@ParameterGroup(name="Answer")
org.mule.munit.common.model.Answer answer,
org.mule.runtime.extension.api.runtime.streaming.StreamingHelper streamingHelper)
processor that has the given withAttributes, replacing it with the given answer.
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 answer is used. If
thenReturn is specified, then that event is returned, or if thenCall is specified, the given flow is invoked, and the resulting event is returned. If no Answer is specified,
the incoming event is returned.
processor - identifier of the processor to mockwithAttributes - additional attributes to identify the processoranswer - Answer to be used 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 © 2023 MuleSoft, Inc.. All rights reserved.