com.hammingweight.hammock
Class MethodInvocation

java.lang.Object
  extended by com.hammingweight.hammock.MethodInvocation
All Implemented Interfaces:
IHammockExceptionErrors

public class MethodInvocation
extends java.lang.Object
implements IHammockExceptionErrors

The MethodInvocation class describes a method invocation. A method invocation is described by the invoked method, the arguments passed in the method and the object on which the method was invoked.

Since:
Hammock 1.0
Author:
C.A. Meijer

Field Summary
 
Fields inherited from interface com.hammingweight.hammock.IHammockExceptionErrors
ARGUMENT_MATCHER_ALREADY_SET, CANT_SET_VOID_RETURN_VALUE, CLASS_IS_NOT_THROWABLE, DOES_NOT_SUBCLASS_MOCK_OBJECT, HANDLER_NOT_SET, INCORRECT_MOCK_OBJECT, INCORRECT_RETURN_CLASS, INCORRECT_THROWABLE_CLASS, METHOD_CANNOT_BE_EVALUATED, METHOD_INVOKED_OUT_OF_SEQUENCE, METHOD_INVOKED_TOO_MANY_TIMES, METHOD_INVOKED_UNEXPECTED_NUMBER_OF_TIMES, NO_RETURN_VALUE, NO_RETURN_VALUE_SET, NUM_INVOCATIONS_ALREADY_SET, RETURN_VALUE_ALREADY_SET, WRONG_ARGUMENT_CLASS, WRONG_NUMBER_OF_ARGS
 
Constructor Summary
MethodInvocation(MockMethod method, IMockObject mockObject, java.lang.Object[] args)
          Constructor.
 
Method Summary
 MockMethod getMethod()
          Returns the method of the invocation.
 java.lang.Object[] getMethodArguments()
          The arguments passed to the method.
 IMockObject getMockObject()
          Returns the Object on which the method was invoked.
 java.lang.Object getReturnValue()
          Returns the value or throws an error or exception associated with the method invocation.
 boolean isEvaluated()
          This method indicates whether the method has been evaluated; i.e.
 void setReturnValue(java.lang.Object retVal)
          Sets the value that will be returned by the method.
 void setThrowable(java.lang.Throwable throwable)
          Sets an exception or error thrown by the method.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MethodInvocation

public MethodInvocation(MockMethod method,
                        IMockObject mockObject,
                        java.lang.Object[] args)
Constructor.

Parameters:
method - The invoked method.
mockObject - The mock object on which the method was invoked.
args - The arguments passed in the method invocation.
Method Detail

getMethod

public MockMethod getMethod()
Returns the method of the invocation.

Returns:
the method.

getMockObject

public IMockObject getMockObject()
Returns the Object on which the method was invoked.

Returns:
The Object on which the method was invoked.

getMethodArguments

public java.lang.Object[] getMethodArguments()
The arguments passed to the method.

Returns:
The arguments.

setReturnValue

public void setReturnValue(java.lang.Object retVal)
Sets the value that will be returned by the method.

Parameters:
retVal - The value returned by the method.

setThrowable

public void setThrowable(java.lang.Throwable throwable)
Sets an exception or error thrown by the method.

Parameters:
throwable - The exception or error thrown by the method.

getReturnValue

public java.lang.Object getReturnValue()
                                throws java.lang.Throwable
Returns the value or throws an error or exception associated with the method invocation.

Returns:
The value returned by the method.
Throws:
The - error or exception that the method is expected to throw.
java.lang.Throwable

isEvaluated

public boolean isEvaluated()
This method indicates whether the method has been evaluated; i.e. whether a value to return from the method invocation has been set.

Returns:
true if a return value has been set for the method invocation.