0

在我的一个 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 表达式。

4

2 回答 2

0

尝试

"#[[&quot;productcode&quot; :&quot;(('11','10'))&quot;]]"
于 2018-05-09T05:23:11.407 回答
0

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

value="#[['productcode' :'((\'11\',\'10\'))']]"
于 2018-05-10T11:24:10.897 回答