我们正试图在MUNIT套件中模拟Amazon S3连接器。我们已经尝试了多种方法,但模拟似乎永远不会起作用:
主要流程:
<flow name="helios-s3-copy-file"
processingStrategy="synchronous">
<http:listener config-ref="HTTP_Listener_Configuration" path="/movefile" doc:name="HTTP"/>
<set-variable value="#['Test']" variableName="feedPathPrefix" doc:name="Set feed prefix" />
<set-variable variableName="srcPath"
value="#[feedPathPrefix + '/TestFilemule.xlsx']"
doc:name="Source" />
<set-variable variableName="destPath"
value="#[feedPathPrefix + '/dest/TestFilemule.xlsx']"
doc:name="Destination" />
<flow-ref name="copyactionflowRef" doc:name="copyactionflow"/>
<logger
level="INFO" doc:name="Logger" message="#[flowVars.copyMsg]"/>
<set-payload value="#[flowVars.copyMsg]" doc:name="Set Payload"/>
</flow>
<sub-flow name="copyactionflowRef">
<s3:copy-object config-ref="Amazon_S3__Configuration" sourceBucketName="some-bucket-name" sourceKey="#[srcPath]" destinationBucketName="some-bucket-name" destinationKey="#[destPath]" doc:name="Copy Processed File"/>
<set-variable variableName="copyMsg" value="#['Completed copy from ' + feedPathPrefix + ' to ' + destPath + ' directory']" doc:name="Variable"/>
</sub-flow>
Munit测试案例:
<munit:test name="amazons3test-test-suite-helios-s3-copy-fileTest" description="Testing mocking of copy objects" >
<mock:when messageProcessor="mule:sub-flow" doc:name="Mock2">
<mock:with-attributes>
<mock:with-attribute name="doc:name" whereValue="#['copyactionflowRef']"/>
</mock:with-attributes>
<mock:then-return payload="#['Copy completed payload']">
<mock:outbound-properties>
<mock:outbound-property key="copyMsg" value="Copy complete"/>
</mock:outbound-properties>
</mock:then-return>
</mock:when>
<!-- <mock:spy messageProcessor="mule:sub-flow" doc:name="Spy">
<mock:with-attributes>
<mock:with-attribute name="doc:name" whereValue="#['copyactionflowRef']"/>
</mock:with-attributes>
<mock:assertions-before-call>
<logger message="Must not make actual S3 call" level="INFO" doc:name="Logger"/>
</mock:assertions-before-call>
<mock:assertions-after-call>
<munit:set payload="#['mock payload']" doc:name="Set Message">
<munit:invocation-properties>
<munit:invocation-property key="copyMsg" value="Value from Spy"/>
</munit:invocation-properties>
</munit:set>
</mock:assertions-after-call>
</mock:spy> -->
<flow-ref name="helios-s3-copy-file" doc:name="Flow-ref to helios-s3-copy-file"/>
</munit:test>
我们还在Mule论坛中记录了ticket,但我们还没有任何解决方案。有谁知道我们如何在Mulesoft中记录Jira?
对于stackoverflow的其他一些问题,似乎许多其他OOB连接存在同样的问题。 MUNIT模拟似乎有很多缺陷。
答案 0 :(得分:0)
根据您提供的代码我可以看到,您的Mock组件不会嘲笑子流,因为您的子流没有属性&#34; doc:name&#34;。它只有&#34; name&#34;属性。因此,您的配置应该类似于
<mock:with-attributes>
<mock:with-attribute name="name" whereValue="#['copyactionflowRef']"/>
</mock:with-attributes>
如果此操作仍然有效,请尝试更改whereValue="#[matchContains('copyactionflowRef')]"
希望这有帮助!