1

I am passing multiple dates to my request, from groovy I returning something like this (dates vary): [2018-06-11, 2018-06-13, 2018-06-11, 2018-06-14, 2018-06-11, 2018-06-14]

Before version 2.3.0 I was using the script below to access each element (this one gives 2018-06-11):

${Groovy-CheckIn-CheckOut#result#$[0]}

However in latest version it returns empty, also GetData no longer recognizes this as an array.

Is there other way to access array from request, is it related to JSON version update although I am not using one?

P.S: I am not sure whether there is a bug that I should wait out or obsolete feature I cannot use anymore, and do not know how to retrieve data in the current state...

  • 1
    Hope you contacted ReadyAPI customer support. Don't you? – Rao Mar 14 '18 at 04:42
  • Sent them same question, problem is that I don't know whether it's a bug or they deemed this way of data passing obsolete, if so I need to find another solution before people using my code get new version... – Michael Babich Mar 14 '18 at 08:09
  • After a bit of correspondence with smartbear support it seems no longer to be supported, in fact they never did, officially, although passing something like [123, 4] still works, so it is bear vs dates. In the end, after a bit of browsing I used conversion with JsonOutput library, as it was the fix with least amount of changes, and no changes at all on receiving side in request: return new groovy.json.JsonOutput().toJson( [...] ) – Michael Babich Mar 09 '20 at 09:50

2 Answers2

1

Instead of your script returning the list, try having it add it to the test run context:

context['array'] = myarray

Then use an inline Groovy script rather than property expansion. i.e., use ${=a.getB()} rather than ${a#b}. In our case:

${=context['array'][0]}

I usually prefer inline scripts over property expansions, because I can write any Groovy I want, but there's a catch, in that SoapUI fails to escape braces properly. So don't try something like:

${=context['array'].find {it > new Date()} }

If you find that you really want to do it, you can preload the context with any Closures you want to use inline:

context['array'] = myarray
context['isFuture'] = { it > new Date() }

Then inline:

${=context['array'].find context['isFuture'] }
Jeremy Hunt
  • 701
  • 3
  • 10
0

After a bit of correspondence with smartbear support it seems no longer to be supported, in fact they never did, officially, although passing something like [123, 4] still works, so it is bear vs dates.
In the end, after a bit of browsing I used conversion with JsonOutput library, as it was the fix with least amount of changes, and no changes at all on receiving side in request:
return new groovy.json.JsonOutput().toJson( [...] )