Daniil Shevelev
Daniil Shevelev

Reputation: 12027

Spock spy causes "MethodMissingException"

I am trying to do a partial mock using Spock Spy. Here is code that works:

setup:
Bulk bulk = new Bulk()
bulk.setApi(stub)           
when:
bulk.updateHeldBounsedSubscribers(subscribers, bounceEvents)

and here is the code that does not work:

setup:
Bulk bulk = Spy(Bulk)
bulk.getSubscribersByKeys(_) >> subs
bulk.setApi(stub)           
when:
bulk.updateHeldBounsedSubscribers(subscribers, bounceEvents)

It produces following exception:

groovy.lang.MissingMethodException: No signature of method: com.otpp.email.BulkEmailDownloader$$EnhancerByCGLIB$$8227f19f.updateHeldBounsedSubscribers() is applicable for argument types: (java.util.ArrayList, java.util.LinkedHashMap) values: [[com.exacttarget.wsdl.partnerapi.Subscriber@57a41eae], ...]
at com.otpp.email.DownloaderUnitTests.updateHeldBounsedSubscribers test with mocked API objects(DownloaderUnitTests.groovy:223)

Upvotes: 1

Views: 805

Answers (1)

Daniil Shevelev
Daniil Shevelev

Reputation: 12027

The method was private. I changed it to protected and it works.

Upvotes: 1

Related Questions