Mock the sftp-list operation especially the attributes with file name and its path. These attributes are used in a for each loop are not available.
1 Answer
Correct way to mock sftp-list operation where attributes can be available inside foreach loop:
<flow doc:name="Flow" >
<file:list doc:name="List" config-ref="File_Config" directoryPath="/tmp/"/>
</flow>
<munit-tools:mock-when processor="file:list">
<munit-tools:with-attributes>
<munit-tools:with-attribute attributeName="doc:name" whereValue="List"/>
</munit-tools:with-attributes>
<munit-tools:then-return>
<munit-tools:payload value="#[[MunitTools::createMessage( "ITEM-1", "text/plain", { name : 'file1.txt'}, null) , MunitTools::createMessage( "ITEM-2", "text/plain", { name : 'file2.txt'}, null)]]" />
</munit-tools:then-return>
</munit-tools:mock-when>