Tag: munit

如何使用MUnit在Mule Flow中模拟Java组件

我正在尝试使用MUnit对我的一个子流进行unit testing,我需要模拟一个自定义Java组件,但我无法这样做。 我的子流程如下所示 <!– –> 这是我失败的unit testing @Test public void givenAValidPayload_whenFlowIsInvoked_itShouldSendPayloadToDestinationSFTPOnlyOnce() throws Exception { destinationSFTP.thenReturnSameEvent(); sourceArchiveSFTP.thenReturnSameEvent(); deleteProcessedFileComponent.thenReturnSameEvent(); successEmail.thenReturnSameEvent(); MuleEvent testEvent = PropertyEnricher.enrich(testEvent(IOUtils.toInputStream(“hello,dummy,payload”))).get(); runFlow(PROCESS_CSV_FLOW, testEvent); verifyCallOfMessageProcessor(“outbound-endpoint”) .ofNamespace(“sftp”) .withAttributes(attribute(“name”).ofNamespace(“doc”).withValue(“DestinationSFTP”)) .times(1); } 我试图嘲笑组件 deleteProcessedFileComponent = whenMessageProcessor(“component”) .withAttributes(attribute(“name”).ofNamespace(“doc”).withValue(“Delete Read File”)); 我尝试了一些变化,没有一个工作,我猜一个组件不是MessageProcessor 我得到的例外情况如下 org.mule.api.lifecycle.InitialisationException: Component has not been initialized properly, no flow constuct. at org.mule.component.AbstractComponent.initialise(AbstractComponent.java:218) at org.mule.processor.chain.AbstractMessageProcessorChain.initialise(AbstractMessageProcessorChain.java:80) at org.mule.processor.chain.AbstractMessageProcessorChain$$FastClassByCGLIB$$38c17d88.invoke() at […]