mule4 - 我们可以在 mule 4 中为 on Error 传播创建 Munit 吗?
问题描述
On Error Propagate Munit 应该失败还是通过?场景:当我收到数据库连接错误时,它会触发带有错误通知的电子邮件。对错误电子邮件流的流引用。流参考放置在 On Error Propagate 中。我在错误选项卡中使用错误、DB CONNECTIVITY 模拟数据库,并在 Try 块中包装流 Ref。我的测试失败了。测试套件应该在 Munit 测试中失败并显示错误消息或以绿色通过?
<munit:test name="implementation-suiteTest" doc:id="804123309-0b27-4e5a-beb3-5372b91eafc3" expectedErrorType="DB:QUERY_EXECUTION">
<munit:behavior >
<munit:set-event doc:name="Set Event" doc:id="5d0290f4-9855-42ba-b434-a4322457819c">
<munit:payload value="#[output application/java --- readUrl('classpath://insertdatabaseFlowtest\mock_payload.dwl')]" />
</munit:set-event>
<munit-tools:mock-when doc:name="Mock " doc:id="d8493233-303b-4765-89b4-9ae19bdffa1f" processor="db:bulk-insert">
<munit-tools:with-attributes>
<munit-tools:with-attribute whereValue="b645fb60-7b08-4939-894d-a476ee58b325" attributeName="doc:id" />
</munit-tools:with-attributes>
<munit-tools:then-return >
<munit-tools:payload value="#[output application/java --- readUrl('classpath://insertdatatodatabaseFlowtest\mock_payload1.dwl')]" />
<munit-tools:error typeId="DB CONNECTIVITY" />
</munit-tools:then-return>
</munit-tools:mock-when>
<munit-tools:mock-when doc:name="Send Email" doc:id="c9cb74e7-9b56-4634-a272-d954d4ab8fb2" processor="email:send">
<munit-tools:with-attributes >
<munit-tools:with-attribute whereValue="3f8bda1c-2e22-43d8-8e0a-3da9a6653dd7" attributeName="doc:id" />
</munit-tools:with-attributes>
<munit-tools:then-return >
<munit-tools:payload value="#[output application/java --- readUrl('classpath://insertdatatodatabaseFlowtest\mock_payload2.dwl')]" />
</munit-tools:then-return>
</munit-tools:mock-when>
</munit:behavior>
<munit:execution>
<try doc:name="Try" doc:id="e73eae0a-25fb-46bb-b0e9-e845bb7310e0" >
<flow-ref doc:name="Flow-ref " doc:id="8582675c-3203-4f70-8988-370e82cd5249" name="insert-dataFlow" />
<error-handler >
<on-error-continue enableNotifications="true" logException="true" doc:name="On Error Continue" doc:id="7999aa4b-4959-4c64-98c4-284f883c5778" >
<logger level="INFO" doc:name="Logger" doc:id="6018dc63-a176-41aa-9ca3-be39264c9e0f" />
</on-error-continue>
</error-handler>
</try>
</munit:execution>
<munit:validation>
<munit-tools:assert-that doc:name="Assert that" doc:id="6b255b30-e43a-4001-a62d-e6374a9d16f0" expression="#[payload]" is="#[MunitTools::containsString('Error Email Sent')]"/>
</munit:validation>
</munit:test>
谢谢
解决方案
推荐阅读
- regex - 当引号中可能有引号时,是否有正则表达式模式来提取引号之间的值
- amazon-web-services - AWS Quicksight - 启用用户评论
- javascript - 是否可以通过 Webpack 覆盖“全局”变量?
- python - 如何摆脱python列表中的html标签?
- flutter - 如何在颤动中不丢失更新的变量?
- android - android设计单选按钮
- sql-server - SQL jdbc 驱动程序版本 7.4 和 8.2 在功能方面有什么区别?
- java - 读取文本文件并返回 ArrayList 类型对象的 Java 方法
- github - 标题上方的图片(Github README.rst)
- android - 无法在 Unity 中使用原生 android 模块(AAR 文件)进行广播