Home › Forums › Development › Unit test error in ActionItem'testEmails post-Jade upgrade
- This topic has 4 replies, 3 voices, and was last updated 8 years, 5 months ago by samuel.martey.
-
AuthorPosts
-
-
May 26, 2016 at 1:49 am #6812Tommy ButtParticipant
Hi there,
We have applied NexJ Finance 7.2.0.2 721.1305.146.46_jade upgrade followed by nexj_contact_jade_ga_sp1_7.2.1.1. Since the Jade upgrade the unit test ActionItem’testEmails have been failing with the following error:
1234567891011; 15:33:42,599 ERROR [UnitTestLogger] (Thread-0) Unexpected error in test case "testEmails"nexj.core.scripting.ScriptingException: Invalid list passed to "assoc". (err.scripting.badList)at nexj.core.scripting.Intrinsic$7.match(Intrinsic.java:509)at nexj.core.scripting.Intrinsic$ListMemberIntrinsicFunction.invoke(Intrinsic.java:13994)at clientServer.assoc-value-for-key(library:clientServer:28)at OrchestratorCommandMessage.invoke(object,method,args)$main(class:OrchestratorCommandMessage.invoke(object,method,args)$main:3)at rules.lambda(library:rules:450)at EmailActItemCommand.emailActItem()$main(class:EmailActItemCommand.emailActItem()$main:48)at EmailActItemCommand.emailActItem()(class:EmailActItemCommand.emailActItem():1)at ActionItem.testEmails(unittest:ActionItem.testEmails:91)at ActionItem.testEmails(unittest:ActionItem.testEmails:80)The error occurs when the test case executes the following line:
– (emailActItemCommand’emailActItem)
The test case testEmails has not been changed by Jade.
emailActItemCommand is a non-customized class in our implementation. This has been modified by Jade.
EmailActItem has a line to send email using SysMail’send
After the Jade upgrade, the SysMail’send call is wrapped around by “orchestrator-dispatch” with a list of arguments passed into the dispatch. Downstream operations by orchestrator-dispatch attempts to retrieve a queue from the list of arguments. The ‘Invalid list passed to “assoc”‘ error happens when an assoc call was used to look for “queue”. Queue does not appear to be among the arguments passed by emailActItemCommand to orchestrator-dispatch.
How could this error within the base modules be resolved?
Thanks
Tommy
ANZ
0 -
July 14, 2016 at 11:57 am #7079samuel.marteyParticipant
You would have to do 2 things to ensure this works properly.
1. Change the arguments passed to ‘orchestrator-dispatch’ to use an assoc list.
ie: for something like:
(orchestrator-dispatch this (lambda(this arg1 arg2 arg3…) (SysMail’send ….)) arg1Value arg2Value arg3Value…)
You would need to convert that to use an assoc-list.
(orchestrator-dispatch this (lambda(this . args) (SysMail’send ….)) (: arg1 arg1Value) (: arg2 arg2Value) (: arg3 arg3Value)…)
2. The function executed by the ‘orchestrator-dispatch’ (ie: (lambda(this arg1 arg2 arg3…))) would have to be changed to (lambda(this . args)) and the appropriate assoc-value-for-keys would have to be used to retrieve the values of the arguments.
The final call would look like (as also shown above)
(orchestrator-dispatch this (lambda(this . args) (SysMail’send ….)) (: arg1 arg1Value) (: arg2 arg2Value) (: arg3 arg3Value)…)
The Orchestrator code could also be changed to accommodate this. But it might be a slightly more involved change although simple as well.
0-
July 15, 2016 at 3:23 am #7113Aleksandar.CosoParticipant
Hi Samuel,
Thanks for the suggestion. A member of our dev team tried it with following observations. I attached the modified file. It is part of Jade release and not customised by us.
in EmailActItemCommand class emailActItem event main action
…
(orchestrator-dispatch this
(lambda (this .args)
(SysMail’send
;to:
emailToEdited
;from:
123456789(,userEmail . ,userName);subject:(this'emailSubject);body(
,(cons
(if (null? (this’emailBody))
“”
;else
(list (this’emailBody) (: Content-type “text/html”))
)
attachments
)
)
;properties:
emailCCEdited
)
)
(: emailToEdited emailToEdited)
(: userEmail userEmail)
(: userName userName)
(: emailCCEdited emailCCEdited)
(: attachments attachments)
)
…
The exception message box does not pop up now. But get the errors below in server console output:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899; 15:03:07,144 ERROR [ObjectQueueMessage] (NexJ-Worker-15) Message 10AAA1806C075749288A84FA90C8B90A8D : failednexj.core.rpc.queueing.MessageProcessingException: Too many arguments when calling "nexj.core.scripting.PCodeFunction@14300117" (expected no more than 2, received 6). (err.scripting.maxArgCount)at nexj.core.rpc.queueing.ObjectQueueDispatcher.receiveRun(ObjectQueueDispatcher.java:1067)at nexj.core.rpc.queueing.ObjectQueueDispatcher$5.run(ObjectQueueDispatcher.java:1446)at nexj.core.integration.ContextReceiver.run(ContextReceiver.java:125)at nexj.core.rpc.queueing.ObjectQueueDispatcher.receive(ObjectQueueDispatcher.java:1396)at nexj.core.rpc.queueing.ObjectQueueDispatcher.onMessage(ObjectQueueDispatcher.java:560)at nexj.core.rpc.queueing.ObjectQueueDispatcher.onMessage(ObjectQueueDispatcher.java:486)at nexj.core.rpc.queueing.ObjectReceiver.onMessage(ObjectReceiver.java:108)at nexj.core.rpc.queueing.ObjectQueueServerMDB.onMessage(ObjectQueueServerMDB.java:77)at sun.reflect.GeneratedMethodAccessor183.invoke(Unknown Source)at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)at java.lang.reflect.Method.invoke(Unknown Source)at nexj.core.container.platform.teee.ejb.GenericMDBContainer.invoke(GenericMDBContainer.java:112)at nexj.core.container.platform.teee.ejb.MDBMessageEndpointFactory$ProxyHandler.invoke(MDBMessageEndpointFactory.java:286)at com.sun.proxy.$Proxy3.onMessage(Unknown Source)at nexj.core.rpc.queueing.ra.ObjectConsumer.deliver(ObjectConsumer.java:325)at nexj.core.rpc.ra.GenericConsumer.consume(GenericConsumer.java:273)at nexj.core.rpc.queueing.ra.ObjectConsumer.consume(ObjectConsumer.java:308)at nexj.core.rpc.ra.GenericConsumer.run(GenericConsumer.java:130)at nexj.core.rpc.queueing.ra.ObjectConsumer.run(ObjectConsumer.java:262)at nexj.core.container.platform.teee.ra.RAWorkManager$CheckedWork.run(RAWorkManager.java:154)at nexj.core.container.platform.teee.work.GenericWorkerPool$Worker.run(GenericWorkerPool.java:326)Caused by: nexj.core.scripting.ScriptingException: Too many arguments when calling "nexj.core.scripting.PCodeFunction@14300117" (expected no more than 2, received 6). (err.scripting.maxArgCount)at EmailActItemCommand.emailActItem()$main(class:EmailActItemCommand.emailActItem()$main:49); 15:03:07,144 ERROR [ObjectQueueMessage] (NexJ-Worker-15) Message 10AAA1806C075749288A84FA90C8B90A8D : droppednexj.core.rpc.queueing.MessageProcessingException: Too many arguments when calling "nexj.core.scripting.PCodeFunction@14300117" (expected no more than 2, received 6). (err.scripting.maxArgCount)at nexj.core.rpc.queueing.ObjectQueueDispatcher.receiveRun(ObjectQueueDispatcher.java:1067)at nexj.core.rpc.queueing.ObjectQueueDispatcher$5.run(ObjectQueueDispatcher.java:1446)at nexj.core.integration.ContextReceiver.run(ContextReceiver.java:125)at nexj.core.rpc.queueing.ObjectQueueDispatcher.receive(ObjectQueueDispatcher.java:1396)at nexj.core.rpc.queueing.ObjectQueueDispatcher.onMessage(ObjectQueueDispatcher.java:560)at nexj.core.rpc.queueing.ObjectQueueDispatcher.onMessage(ObjectQueueDispatcher.java:486)at nexj.core.rpc.queueing.ObjectReceiver.onMessage(ObjectReceiver.java:108)at nexj.core.rpc.queueing.ObjectQueueServerMDB.onMessage(ObjectQueueServerMDB.java:77)at sun.reflect.GeneratedMethodAccessor183.invoke(Unknown Source)at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)at java.lang.reflect.Method.invoke(Unknown Source)at nexj.core.container.platform.teee.ejb.GenericMDBContainer.invoke(GenericMDBContainer.java:112)at nexj.core.container.platform.teee.ejb.MDBMessageEndpointFactory$ProxyHandler.invoke(MDBMessageEndpointFactory.java:286)at com.sun.proxy.$Proxy3.onMessage(Unknown Source)at nexj.core.rpc.queueing.ra.ObjectConsumer.deliver(ObjectConsumer.java:325)at nexj.core.rpc.ra.GenericConsumer.consume(GenericConsumer.java:273)at nexj.core.rpc.queueing.ra.ObjectConsumer.consume(ObjectConsumer.java:308)at nexj.core.rpc.ra.GenericConsumer.run(GenericConsumer.java:130)at nexj.core.rpc.queueing.ra.ObjectConsumer.run(ObjectConsumer.java:262)at nexj.core.container.platform.teee.ra.RAWorkManager$CheckedWork.run(RAWorkManager.java:154)at nexj.core.container.platform.teee.work.GenericWorkerPool$Worker.run(GenericWorkerPool.java:326)Caused by: nexj.core.scripting.ScriptingException: Too many arguments when calling "nexj.core.scripting.PCodeFunction@14300117" (expected no more than 2, received 6). (err.scripting.maxArgCount)at EmailActItemCommand.emailActItem()$main(class:EmailActItemCommand.emailActItem()$main:49)0Attachments:
You must be logged in to view attached files.
-
-
July 15, 2016 at 3:05 pm #7128samuel.marteyParticipant
Hello Aleksander,
I am not able to download the attached files. However, it would be nice to see a snippet of the line that calls ‘orchestrator-dispatch’ pasted here.
It seems to be that whichever function you are calling does not support variable args/varargs.
For your idea above to work, you need to use a function (anonymous/named) that takes in at least 2 arguments, ‘this’ and ‘. args’)
Here is a way to do this with your current problem.
(orchestrator-dispatch this
(lambda (this . args)
(let
(
(emailToEdited (assoc-value-for-key ’emailToEdited args))
(userEmail (assoc-value-for-key ‘userEmail args))
(userName (assoc-value-for-key ‘userName args))
(emailCCEdited (assoc-value-for-key ’emailCCEdited args))
(attachments (assoc-value-for-key ‘attachments args))
)
(SysMail’send
;to:
emailToEdited
;from:
(,userEmail . ,userName)
;subject:
(this’emailSubject)
;body
`
(
,(cons
(if (null? (this’emailBody))
“”
;else
(list (this’emailBody) (: Content-type “text/html”))
)
attachments
)
)
;properties:
emailCCEdited
)
)
)
emailToEdited userEmail userName emailCCEdited attachments
)
0 -
July 15, 2016 at 3:59 pm #7136samuel.marteyParticipant
Further analysis show that you could probably fix this by changing code in the OrchestratorCommandMessage.meta to avoid the problem completely and keep the rest of the code the same. This should be tested thoroughly.
in the invoke(object, method, args[]), change the variable to:
(queueName (ifnull (when (every pair? args) (assoc-value-for-key 'queue args)) (@ DEFAULT_QUEUE_NAME)))
Rather than:
(queueName (ifnull (assoc-value-for-key 'queue args) (@ DEFAULT_QUEUE_NAME)))
0
-
-
AuthorPosts
- You must be logged in to reply to this topic.