1
0
-1

I'm trying to write a UnitTest for a GroovyFormPrefillService, but I get an error:

groovy.lang.MissingMethodException: No signature of method: com.avoka.fc.core.service.form.GroovyFormPrefillService.invokeService() is applicable for argument types: (java.util.LinkedHashMap)

According to the documentation for the interface IGroovyService the method for invokeService is:

invokeService(Map<String,Object> parameters)

In my UnitTest I have the following code:

Map<String, Object> parameters = [:]
parameters.put("request", request)
 
def result = groovyService.invokeService(parameters)

But that creates a linkedHashMap, not a Map (Map is an interface, so you need to create a concrete instance that implements the interface).

How do I create a Map of parameters to satisfy the requirements of the invokeService() method?

Note: This is a legacy service, not a Fluent service.

Thanks

Mark

    CommentAdd your comment...

    1 answer

    1.  
      1
      0
      -1

      Hi Mark,

       

      Please try below:

       

      Map<String, Object> parameters = ["request": request] 
      def result = groovyService.invokeService(parameters)
      You can pass multiple parameters in same fashion e.g.
      param = [ key:value, key:value, key:value]
      
      1. Mark Murray

        Hi Nirmal,

        I have tried a number of variations including the one you mention. But in all cases I get the same error that the signature does not accept the type of Map that I create.

        I tried Map, Map<String, Object>, HashMap, and many other options but they all fail. The signature says you need Map, but Map is an interface and you cannot create a concrete instance of Map; you have to create a subclass.

        If I use the above syntax the error says you cannot use LinkedHashMap.

        So, I am still wondering how I can create an object that will be accepted as a Map.

         

        Thanks

      CommentAdd your comment...