Mule 如何在MUnit测试中省略一个消息处理器?

Mule 如何在MUnit测试中省略一个消息处理器?,mule,mule-studio,anypoint-studio,mule4,munit,Mule,Mule Studio,Anypoint Studio,Mule4,Munit,我有一个流,其中有一个删除输入文件的错误处理程序 <on-error-propagate enableNotifications="true" logException="true" doc:name="On Error Propagate" doc:id="ebacee56-e127-4338-87a7-458659983dee" type="APP:UNSUPPORTED_DOCUMENT_TYP

我有一个流,其中有一个删除输入文件的错误处理程序

<on-error-propagate enableNotifications="true" logException="true" doc:name="On Error Propagate" doc:id="ebacee56-e127-4338-87a7-458659983dee" type="APP:UNSUPPORTED_DOCUMENT_TYPE">
    <logger level="INFO" doc:name="Wrong document type" doc:id="84408377-4f4b-4115-8205-531faa8b9afd" message="#["file: " ++ attributes.fileName ++ " - skipping wrong type"]" category="correctionsImport" />
    <delete doc:name="Delete inbound file" doc:id="6dc7298f-f0bc-4905-aa5d-c8972af9b225" config-ref="XMLFile" path="#[attributes.path]" />
</on-error-propagate>

我还有一个弹药测试:

<test name="ImportCorrectionsFlowTestWithIncorrectDocumentType" doc:id="b4bd8c08-3c8d-4ac9-a4bd-a09afa43126f" description="Test" expectedErrorType="APP:UNSUPPORTED_DOCUMENT_TYPE">
    <execution>
        <read doc:name="POL249_C.INVOICE.CORRECTION-INCENTIVE-CREDIT-INCORRECT-DOCUMENT-TYPE.5921266020-test.xml" doc:id="b92e3cca-aacc-4259-a070-1967eceddc33" config-ref="XMLFileTest" path="corrections/incorrect/CORRECTION-INCENTIVE-CREDIT-INCORRECT-DOCUMENT-TYPE.xml" />
        <flow-ref doc:name="Flow-ref to ImportCorrectionsFlow" doc:id="d3409a91-7f64-47b6-a469-e0faa39696f7" name="ImportCorrectionsFlow" />
        <logger level="INFO" doc:name="Logger" doc:id="d69ee72f-ed46-4c4b-a142-7a140c0f5c64" />
    </execution>
</test>


问题是,当我运行此测试时,源文件被删除,我不希望发生这种情况。如何防止删除该文件?我是否可以模拟文件删除流组件,使其不删除文件?或者我可以以某种方式模拟文件吗?

您应该能够在以下情况下使用模拟处理器模拟删除操作:

<munit:test name="ImportCorrectionsFlowTestWithIncorrectDocumentType" doc:id="b4bd8c08-3c8d-4ac9-a4bd-a09afa43126f" description="Test" expectedErrorType="APP:UNSUPPORTED_DOCUMENT_TYPE">
  <munit:behavior>
    <munit-tools:mock-when processor="file:delete">
      <munit-tools:with-attributes>
         <munit-tools:with-attribute attributeName="doc:name" whereValue="#['Delete inbound file']"/>
      </munit-tools:with-attributes>
    </munit-tools:mock-when>
  </munit:behavior>
  <munit:execution>
  ...
  </munit:execution>
</munit:test>

...

您应该能够在以下情况下使用模拟处理器模拟删除操作:

<munit:test name="ImportCorrectionsFlowTestWithIncorrectDocumentType" doc:id="b4bd8c08-3c8d-4ac9-a4bd-a09afa43126f" description="Test" expectedErrorType="APP:UNSUPPORTED_DOCUMENT_TYPE">
  <munit:behavior>
    <munit-tools:mock-when processor="file:delete">
      <munit-tools:with-attributes>
         <munit-tools:with-attribute attributeName="doc:name" whereValue="#['Delete inbound file']"/>
      </munit-tools:with-attributes>
    </munit-tools:mock-when>
  </munit:behavior>
  <munit:execution>
  ...
  </munit:execution>
</munit:test>

...

完美!非常感谢,非常有魅力!完美的非常感谢,非常有魅力!