JavalibCore icon indicating copy to clipboard operation
JavalibCore copied to clipboard

Single object of type map passed keyword as argument give emtpy map as result after argument collection

Open shan-96 opened this issue 6 years ago • 5 comments

Coming from https://github.com/robotframework/JavalibCore/issues/19 and robotframework documentation as java has no support for explicit kwarg variable, a single map passed on to robot keyword without ** must also be considered as kwarg.

In KeywordInvoker.java and ArgumentCollector.java while collecting arguments args is not null with one non empty map but kwargs are null. But after keyword argument collection we receive one empty map which is wrong

shan-96 avatar Feb 03 '20 11:02 shan-96

I think there's still some confusion of kwargs in general, because RF own documentation states (implicitly) that single map can't be treated as kwarg from caller side

If a Java keyword accepts kwargs, Robot Framework will automatically pack all arguments in name=value syntax at the end of the keyword call into a Map and pass it to the keyword

According your use case you just want to use argument as type of map, not kwargs.

Hi-Fi avatar Feb 03 '20 11:02 Hi-Fi

I think there's still some confusion of kwargs in general, because RF own documentation states (implicitly) that single map can't be treated as kwarg from caller side

If a Java keyword accepts kwargs, Robot Framework will automatically pack all arguments in name=value syntax at the end of the keyword call into a Map and pass it to the keyword

According your use case you just want to use argument as type of map, not kwargs.

Correct! I want to use the Map as normal arg but somehow it doesnt get parsed!

shan-96 avatar Feb 03 '20 11:02 shan-96

OK, I think now I started to see the issue. Not sure if I have time to check it within this week, but I'll try. Probably it requires new version from both JavalibCore and jrobotremoteserver, but let see.

Hi-Fi avatar Feb 03 '20 11:02 Hi-Fi

Ok. If you need, you can go through my PR I will be adding few more test cases in it

shan-96 avatar Feb 04 '20 07:02 shan-96

Just remembered this, and noticed that there's a test that should check for that (https://github.com/robotframework/JavalibCore/blob/c649b8d629fc2afbc7da00b39bffdc3ced6a8754/src/test/java/org/robotframework/javalib/library/AnnotationLibraryIntegrationTest.java#L127).

So I'm still a bit puzzled of the issue.

Note that this needs annotations to work. With Classpathlibrary approach map is always varargs, and I don't think there's any reason to try to make any logic to try to determine if user wants to use arg or varargs.

Hi-Fi avatar Feb 29 '20 15:02 Hi-Fi