Home Forums Business Model Unit Tests Error: java.util.ArrayList cannot be cast to nexj.core.scripting.Pair

Viewing 1 reply thread
  • Author
    Posts
    • #419
      ashutoshashutosh
      Participant

      Hi Team,

      Can you please let me know why we get below error.

      Error: java.util.ArrayList cannot be cast to nexj.core.scripting.Pair

      I am have written a method which takes 5 parameters and inserts these parameters in a database table. All the columns in the database are string. I am passing all the 5 parameters as string.

      Appreciate any pointers on this error.

      Below is the test method:

      I am calling the method like this

      (rbccwm-populate-report “123” “1111222233334444” “Field” “Test” “Test”)

      Error:

      Regards,
      Ashutosh

      0
    • #421
      Ed ShawEd Shaw
      Keymaster

      Ashutosh,

      Looks like you have an extra “collection” and “message” in your new statement. When creating a new ReconReport class it should look something like…

      Yours looked like

      The new event was looking for a pair of an attribute name and a value i.e. (: myAttrib “Hello”) but you were providing it with a “(collection ” which is an ArrayList.

      Tip: When looking for documentation on any event, type the event then use CTRL+SPACE
      i.e. Type “(RBCReconReport’new ” then CTRL+SPACE. This will give you a list of appropriate class attributes and also help you with the proper syntax. Works great when working with “(message ” as well.

      Here is the documentation for the Object’new event. You can get this by hovering over it in your code then pressing F2 if you want to scroll through it or copy it.

      Object’new
      Creates and initializes an instance of this class. The main action is implemented by the framework.

      @arg values list The list of attribute value pairs to use in creating the new object.
      Returns
      Object A new instance of the class.

      Detail
      This is a static method and is used to create new objects by specifying their initial values – think of it as the constructor. The ‘create’ method is called by the new method when an instance of the requested object is created

      e.g. ‘(firstName . “Joe”) ‘(lastName . “Test”)

      e.g. (: firstName firstNameParam) (: lastName “Test”)

      Example

      Another scheme example of “new” which demonstrates creating a subcollection follows:

      (telcoms . , (instance-collection (Telcom’new ‘(name . “home”) ‘(address . “416-555-1212”))))
      ); `

      an alternative – and preferred – syntax to using pairs is the (: operator.

      1
      • This reply was modified 8 years, 9 months ago by Drew PenleyAndrew Penley.
Viewing 1 reply thread
  • You must be logged in to reply to this topic.