Forum Discussion

tom_13's avatar
tom_13
Contributor
15 years ago

[SOLVED]Problem with HashMap in groovy

I need get HashMap from one script to another. I save it to the context in the first script :


def map = new HashMap()
map [...] = ...
context.mapTestData = map


Then get it in second script

def curMap = new HashMap()
curMap =  context.mapTestData


My map has three levels and it is a problem, becouse if I show all map ( log.info curMap ) I receive
Fri Oct 02 16:56:25 EEST 2009:INFO:{1={extra_parameter=null, ..., expexted=[{line_name=Line_Main, exp_charging=14}, {line_name=Common_Main, exp_charging=34}], ..., loc_area_ident=null}}


But if I write
log.info curMap[1]

or
log.info curMap['1']


I get NULL, I don't understend why it working so
Can anybody help me, I need to get map from second level


P.S I'm using soapUI 2.5.1

3 Replies

  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hello,

    Could you post the full content of your scripts? I think it would be helpful in diagnosing the problem. Thank you.

    Regards,
    Dain
    eviware.com
  • ply's avatar
    ply
    Occasional Contributor
    Hello,

      I use : context.setProperty("MyOwnJavacomplexObject",object) ;

      and this works perfectly. My object is the right one.

    So what are the diffrences between :
    - context.setProperty("MyOwnJavacomplexObject",object)
    - context.MyOwnJavacomplexObject = object

    PHL.
  • I have changed map to array on the first level and now it's working