I am trying to writing a Spock specification that test an AspectJ advice class. Therefore I need a mock instance of org.aspectj.lang.ProceedingJoinPoint
class.
void "Verify client capability mechanism"() {
given:
def pointCut = Mock(ProceedingJoinPoint)
and: 'the method calls would have the following arguments'
pointCut.getArgs() >> ['xxx', 1L, 44] as Object[] // this is where the error happens
when: 'the advice gets called'
def retVal = new ClientCapabilitySecurityAdvice().verifyUserCanPerformActionOnCurrentClient(pointCut)
then: 'the call may proceed'
1 * pointCut.getArgs()
1 * pointCut.proceed() >> 'Hello'
retVal == 'Hello'
}
For some reason I am not able to define a return value on getArgs()
on my mock instance. I get this error message.
java.lang.NullPointerException: Cannot invoke method rightShift() on null object
What is the proper way to mock the ProceedingJointPoint
interface? Can someone help me on this?
PS: Merry christmas to you :)
Aucun commentaire:
Enregistrer un commentaire