【问题标题】:How to set inbound properties using set message component in Munit Test case如何在 Munit 测试用例中使用 set message 组件设置入站属性
【发布时间】:2018-05-08 12:19:22
【问题描述】:

在我的一个 munit 测试用例中,我正在尝试使用“设置消息”设置 uri parmas。 键值对如下例所示:

产品代码:('11','10')

当我尝试在组件中设置它时,我遇到了 MEL 表达式的问题。 带有单引号的表达式似乎不接受。

错误: org.mule.api.MessagingException:MEL 解析失败。表达式:#[['productcode' :'( ('11','10'))']] 是无效的表达式。 (org.mule.munit.common.exception.MunitError)。

下面是我的 Munit 测试用例。

<munit:test name="gl-impl-test-suite-gl-getTransactionDataFromAgresso-Test" description="Test">
        <mock:when messageProcessor=".*:.*" doc:name="mockGetReconciliationDataFromAgresso">
            <mock:with-attributes>
                <mock:with-attribute name="doc:name" whereValue="#['getReconciliationDataFromAgresso']"/>
            </mock:with-attributes>
            <mock:then-return payload="#[getResource('scaffolder/response/emp/getEmployeeDetails.xml').asString()]" mimeType="application/xml"/>
        </mock:when>
        <munit:set payload="#[]" doc:name="Set Message">
            <munit:inbound-properties>
                <munit:inbound-property key="http.query.parmas" value="#[['productcode' :'( ('11','10'))']]"/>
            </munit:inbound-properties>
        </munit:set>
        <logger level="INFO" doc:name="Logger"/>
        <flow-ref name="gl-getTransactionDataFromAgresso" doc:name="Flow-ref to gl-getTransactionDataFromAgresso"/>
    </munit:test>

请告诉我如何设置包含单引号的 MEL 表达式。

【问题讨论】:

    标签: mule expression mel munit


    【解决方案1】:

    试试

    "#[[&quot;productcode&quot; :&quot;(('11','10'))&quot;]]"
    

    【讨论】:

      【解决方案2】:

      user3366906 的答案将正确解决单引号问题,或者您可以转义单引号。我通常更喜欢使用混合引号,但很少需要在字符串中同时使用单引号和双引号,因为转义很有用。

      value="#[['productcode' :'((\'11\',\'10\'))']]"
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2016-09-15
        • 1970-01-01
        • 2016-08-26
        • 1970-01-01
        • 2016-02-29
        • 2016-01-26
        • 2021-11-07
        相关资源
        最近更新 更多