Spock Structure: Matching Arguments

I am trying to write a Spock specification where I want to test a method that is called with three arguments. I don't care about the first two, any instance of argument types. I am trying to use Spock wildcard arguments, but keep running into problems. My confirmation looks like this:

    when:
    packageUploadController.handleUpload(httpRequest)

    then: "the value of the 'dest' parameter is passed on to saveservice"
    saveService.saveImportPackage(_ as UploadedPackage, _ as PackageImportResponse.Builder)

Here saveServiceis mock, and UploadedPackage and PackageImportResponse.Builder are the expected arguments; First, I try to run a working test before changing the code that calls saveService.

As far as I can tell, I am doing this as documented, however, as a result of the test, the following message does not work out:

org.codehaus.groovy.runtime.typehandling.GroovyCastException: 
Cannot cast object '_' with class 'org.spockframework.lang.Wildcard' to 
class 'UploadedPackage' due to:
groovy.lang.GroovyRuntimeException: Could not find matching constructor for: 
UploadedPackage(org.spockframework.lang.SpreadWildcard)

, , , SpreadWildCard . ?

(_, _), :

org.codehaus.groovy.runtime.metaclass.MissingMethodExceptionNoStack: No signature of method: 
SaveService$$EnhancerByCGLIB$$67b7324.saveImportPackage() is applicable for argument types: (org.spockframework.lang.Wildcard, org.spockframework.lang.Wildcard) values: [[*_], [*_]]

, , , ( , ).

+4
1

1 *, saveService.saveImportPackage(_ as UploadedPackage, _ as PackageImportResponse.Builder), , . ,

 then: "the value of the 'dest' parameter is passed on to saveservice"
 1 * saveService.saveImportPackage(_ as UploadedPackage, _ as PackageImportResponse.Builder)
+4

All Articles