Class InterceptedInvocation

    • Field Detail

      • arguments

        private final java.lang.Object[] arguments
      • rawArguments

        private final java.lang.Object[] rawArguments
      • sequenceNumber

        private final int sequenceNumber
      • location

        private final Location location
      • verified

        private boolean verified
      • isIgnoredForVerification

        private boolean isIgnoredForVerification
    • Constructor Detail

      • InterceptedInvocation

        public InterceptedInvocation​(MockReference<java.lang.Object> mockRef,
                                     MockitoMethod mockitoMethod,
                                     java.lang.Object[] arguments,
                                     RealMethod realMethod,
                                     Location location,
                                     int sequenceNumber)
    • Method Detail

      • getSequenceNumber

        public int getSequenceNumber()
        Specified by:
        getSequenceNumber in interface Invocation
        Returns:
        the sequence number of the Invocation. Useful to determine the order of invocations. Used by verification in order.
      • getRawArguments

        public java.lang.Object[] getRawArguments()
        Description copied from interface: Invocation
        Returns unprocessed arguments whereas InvocationOnMock.getArguments() returns arguments already processed (e.g. varargs expended, etc.).
        Specified by:
        getRawArguments in interface Invocation
        Returns:
        unprocessed arguments, exactly as provided to this invocation.
      • getRawReturnType

        public java.lang.Class<?> getRawReturnType()
        Description copied from interface: Invocation
        Returns unprocessed arguments whereas InvocationOnMock.getArguments() returns arguments already processed (e.g. varargs expended, etc.).
        Specified by:
        getRawReturnType in interface Invocation
        Returns:
        unprocessed arguments, exactly as provided to this invocation.
      • stubInfo

        public StubInfo stubInfo()
        Specified by:
        stubInfo in interface Invocation
        Returns:
        the stubbing information for this invocation. May return null - this means the invocation was not stubbed.
      • markStubbed

        public void markStubbed​(StubInfo stubInfo)
        Description copied from interface: Invocation
        Marks this invocation as stubbed.
        Specified by:
        markStubbed in interface Invocation
        Parameters:
        stubInfo - the information about stubbing.
      • isIgnoredForVerification

        public boolean isIgnoredForVerification()
        Description copied from interface: Invocation
        Informs if the invocation participates in verify-no-more-invocations or verification in order.
        Specified by:
        isIgnoredForVerification in interface Invocation
        Returns:
        whether this invocation should be ignored for the purposes of verify-no-more-invocations or verification in order.
      • getMock

        public java.lang.Object getMock()
        Description copied from interface: InvocationOnMock
        returns the mock object
        Specified by:
        getMock in interface InvocationOnMock
        Returns:
        mock object
      • getArguments

        public java.lang.Object[] getArguments()
        Description copied from interface: InvocationOnMock
        Returns arguments passed to the method. Vararg are expanded in this array.
        Specified by:
        getArguments in interface InvocationOnMock
        Returns:
        arguments
      • getArgument

        public <T> T getArgument​(int index,
                                 java.lang.Class<T> clazz)
        Description copied from interface: InvocationOnMock
        Returns casted argument at the given index. This method is analogous to InvocationOnMock.getArgument(int), but is necessary to circumvent issues when dealing with generics. In general, InvocationOnMock.getArgument(int) is the appropriate function to use. This particular function is only necessary if you are doing one of the following things:
        1. You want to directly invoke a method on the result of InvocationOnMock.getArgument(int).
        2. You want to directly pass the result of the invocation into a function that accepts a generic parameter.
        If you prefer to use InvocationOnMock.getArgument(int) instead, you can circumvent the compilation issues by storing the intermediate result into a local variable with the correct type.
        Specified by:
        getArgument in interface InvocationOnMock
        Parameters:
        index - argument index
        clazz - class to cast the argument to
        Returns:
        casted argument at the given index
      • callRealMethod

        public java.lang.Object callRealMethod()
                                        throws java.lang.Throwable
        Description copied from interface: InvocationOnMock
        calls real method

        Warning: depending on the real implementation it might throw exceptions

        Specified by:
        callRealMethod in interface InvocationOnMock
        Returns:
        whatever the real method returns / throws
        Throws:
        java.lang.Throwable - in case real method throws
      • getMockRef

        @Deprecated
        public MockReference<java.lang.Object> getMockRef()
        Deprecated.
        Not used by Mockito but by mockito-scala
      • getMockitoMethod

        @Deprecated
        public MockitoMethod getMockitoMethod()
        Deprecated.
        Not used by Mockito but by mockito-scala
      • getRealMethod

        @Deprecated
        public RealMethod getRealMethod()
        Deprecated.
        Not used by Mockito but by mockito-scala
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • equalArguments

        private boolean equalArguments​(java.lang.Object[] arguments)
      • toString

        public java.lang.String toString()
        Description copied from interface: DescribedInvocation
        Describes the invocation in the human friendly way.
        Specified by:
        toString in interface DescribedInvocation
        Overrides:
        toString in class java.lang.Object
        Returns:
        the description of this invocation.