%output application/java
%function splitEachRow(row) row splitBy p('field.delimiter')
%function convertStringToLocateDateTime(date,format) ( date as :localdatetime {format: format})
%var record = splitEachRow(payload)
%var actionDateTime=record[0]
---
{
dateTimefn: convertStringToLocateDateTime(actionDateTime ,p('action.date.time.format')),
dateTime: actionDateTime as :localdatetime {format: p('action.date.time.format')},
Action_Type__c:record[1]
}
while calling a function created within Dataweave script getting below exception.It happens when I run it as Munit test, when I deploy it in Server it works fine.
ERROR 2017-01-30 14:30:03,924 [main] org.mule.exception.DefaultMessagingExceptionStrategy:
********************************************************************************
Message : -1 (java.lang.ArrayIndexOutOfBoundsException). Message payload is of type: String
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. -1 (java.lang.ArrayIndexOutOfBoundsException)
com.mulesoft.weave.engine.ExecutionContext$InternalExecutionContext:69 (null)
2. -1 (java.lang.ArrayIndexOutOfBoundsException). Message payload is of type: String (org.mule.api.MessagingException)
org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor:32 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
java.lang.ArrayIndexOutOfBoundsException: -1
at com.mulesoft.weave.engine.ExecutionContext$InternalExecutionContext.getVariable(ExecutionContext.scala:69)
at com.mulesoft.weave.engine.ast.variables.VariableReferenceNode.value(VariableReferenceNode.scala:24)
at com.mulesoft.weave.model.values.wrappers.DelegateValue$class.valueType(DelegateValue.scala:12)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
ERROR - The test vba-prod-data-integration-test-suiteTest finished with an Error.
-1 (java.lang.ArrayIndexOutOfBoundsException). Message payload is of type: String
org.mule.api.MessagingException: -1 (java.lang.ArrayIndexOutOfBoundsException). Message payload is of type: String
at vba-prod-data-integration-test-suiteTest.dw:transform-message{doc:name=Transform Message}(vba-prod-data-integration-test-suite.xml:16)
at vba-prod-data-integration-test-suiteTest.mule:set-payload{doc:name=Set Payload, value=01/12/2017 11:03:07 AM|"Atlanta VAMC records uploaded"|0|3176342462|"Rating"|"020NEW"|0|"0609122664"|"020"|"020"|"3020486138"|||4|349|2||1||1|0.931|Ready to Work|3492328660|1|1762475691|"176247569117-JAN-1231763424622"|"A244840216033" }(vba-prod-data-integration-test-suite.xml:15)
at appleFlow.munit:test{initialState=started, description=MUnit Test, ignore=false, abstract=false, id=MunitTestFlow$$EnhancerByMUNIT$$904837f0{vba-prod-data-integration-test-suiteTest}}(vba-prod-data-integration-test-suite.xml:13)
Caused by: java.lang.ArrayIndexOutOfBoundsException: -1
at com.mulesoft.weave.engine.ExecutionContext$InternalExecutionContext.getVariable(ExecutionContext.scala:69)
at com.mulesoft.weave.engine.ast.variables.VariableReferenceNode.value(VariableReferenceNode.scala:24)
at com.mulesoft.weave.model.values.wrappers.DelegateValue$class.valueType(DelegateValue.scala:12)
答案 0 :(得分:0)
你如何从Munit调用Dataweave函数?
答案 1 :(得分:0)
我只是通过mule unit测试用例调用我的数据编织存在的子流 例如:
<munit:test name="endpoints-test-suiteTest" description="MUnit Test">
<flow-ref name="call-my-dataweave" doc:name="Flow Reference"/>
</munit:test>