【问题标题】:Is there a way to mock non-global filters in a sub-flow using MUnit?有没有办法使用 MUnit 在子流中模拟非全局过滤器?
【发布时间】:2015-04-30 02:12:10
【问题描述】:

我想知道是否有一种方法可以使用 MUnit 模拟子流中的自定义过滤器。

我正在使用 Mule 3.4.0 和 MUnit 3.4.0.M5。

示例流程如下所示。

<sub-flow name="a">
     <choice>
          <when expression="something...">
               <custom-filter doc:name="filter a">...</custom-filter>
          </when>
          <otherwise>
               ...
          </otherwise>
     </choice>
</sub-flow>

我必须围绕子流创建一个包装流,因为每当我尝试使用 runFlow 语法直接命中子流时都会收到 NullPointerException。但是,这样做时,我无法使用 whenMessageProcessor 语法模拟自定义过滤器。请在下面查看我的尝试。

whenMessageProcessor("custom-filter"
.withAttributes(attribute("name").ofNamespace("doc").withValue("filter a"))
.thenReturn(muleMessageWithPayload("some response");

这会导致消息不被模拟。

【问题讨论】:

    标签: mule munit


    【解决方案1】:

    这里混杂了一些问题。

    您必须包装子流程是一个 MUnit/Mule 问题,如下所述: How to mock a Java component within Mule Flow using MUnit

    第二个问题是过滤器模拟。简短的回答是你不能,请检查: https://github.com/mulesoft/munit/issues/108

    从概念上讲,过滤器是一种选择的简写方式(或普通语言中的 if)。通常不会模拟一个选择/如果它改变了变量中的值,或者在我们的情况下是 mule 消息有效负载中的值。这就是过滤器 MP 不能被模拟的原因。

    HTH

    【讨论】:

    • 感谢您的澄清!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-05-28
    • 2012-08-17
    • 1970-01-01
    • 2014-05-17
    • 2017-12-10
    • 2020-06-10
    • 2013-11-23
    相关资源
    最近更新 更多