将有效负载传递到munit中的另一个流的问题

时间:2016-06-29 22:07:01

标签: mule

我正在MUnit测试用例中从.txt文件中读取JSON,将其设置为payload.I期望有效负载具有字段,并且其值在.txt文件中以map的形式定义。但是我得到的是null而不是值。 感谢您帮助隔离问题。

<!-- TESTCASE: -->
<munit:test name="test-update" description="Validate calls to sub flows are being done properly ">
     <munit:set payload="#[getResource('testData.txt').asStream()]" doc:name="Set Message">
    <munit:inbound-properties>
    <munit:inbound-property key="http.method" value="#['POST']" />
    <munit:inbound-property key="http.request" value="#['/api/service/v1/update']" />
    <munit:inbound-property key="http.request.path" value="#['/api/service/v1/update']" />
     </munit:inbound-properties>
</munit:set>

<byte-array-to-object-transformer doc:name="Byte Array to Object" /> 

<logger level="INFO" message="Payload: #[payload]" doc:name="Logger"/>
<!-- Logs {"Id":"123"} which is read from testData.txt --> 

<logger level="INFO" message="Id: #[payload.Id]" doc:name="Logger"/>
<!-- Logs "Id= null" instead of "Id: 123"--> 

...
</munit:test>

1 个答案:

答案 0 :(得分:0)

尝试使用:

<logger level="INFO" message="Id: #[payload.get('Id')]" doc:name="Logger"/>

而不是:

<logger level="INFO" message="Id: #[payload.Id]" doc:name="Logger"/>