[prev in list] [next in list] [prev in thread] [next in thread] 

List:       groovy-user
Subject:    [groovy-user] Re: Spock mocking class with annotated methods
From:       Peter Niederwieser <pniederw () gmail ! com>
Date:       2014-08-28 7:18:35
Message-ID: 1409210315504-5721060.post () n5 ! nabble ! com
[Download RAW message or body]

The method declaration of the generated mock implementation won't have a
parameter annotation, and such annotations aren't inherited. So unless you
reflect on the interface method, you won't find the annotation. Would be
interesting to know if other mocking frameworks handle this differently.

Cheers,
Peter

PS: Best place for Spock questions is http://forum.spockframework.org


Tomas Salazar wrote
> Hi,
> I am trying to create a Mock on an interface that have annotated methods,
> but when getParameterAnnotations() is invoked over the Mock it's returning
> and empty nested array of length zero.
> 
> interface SongsService {
> String get(@ApiQueryParam("query") String query)
> }
> 
> class RamlApiHandlerTest extends Specification {
> def "Handle with service"() {
> setup:
> SongsService songsService = Mock(SongsService)
> songsService.get(_) >> { args -> "hola ${args}" }
> def annotations = methods.first().getParameterAnnotations()
> then:
> annotations.[0].size() == 1
> }
> 
> 
> Regards





--
View this message in context: \
http://groovy.329449.n5.nabble.com/Spock-mocking-class-with-annotated-methods-tp5721003p5721060.html
 Sent from the groovy - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic