|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.hammingweight.hammock.MockMethod
public class MockMethod
The MockMethod
class models a method associated with a mock
object (or another test double such as a spy or stub). The method is defined
in some interface or class. Important attributes of the method are whether
the method is abstract, how many arguments it takes, the return type, etc.
Field Summary |
---|
Fields inherited from interface com.hammingweight.hammock.IClassDefinitions |
---|
BOOLEAN_CLASS, BYTE_CLASS, CHARACTER_CLASS, DOUBLE_CLASS, FLOAT_CLASS, IMOCKOBJECT_CLASS, INTEGER_CLASS, LONG_CLASS, OBJECT_CLASS, SHORT_CLASS, THROWABLE_CLASS |
Constructor Summary | |
---|---|
MockMethod(java.lang.Class clazz,
java.lang.String id,
java.lang.Class[] argClasses,
java.lang.Class[] throwableClasses,
java.lang.Class retClass,
boolean isAbstract)
Constructor. |
|
MockMethod(java.lang.String id,
int numArgs,
java.lang.Class retClass,
boolean isAbstract)
Constructor. |
Method Summary | |
---|---|
protected java.lang.Class[] |
getArgumentClasses()
Returns the classes of the method's arguments. |
java.lang.String |
getId()
Gets the identifier for a method. |
java.lang.Class |
getMethodClass()
Gets the Class associated with a method. |
int |
getNumberOfArguments()
This method returns the number of arguments for the encapsulated method. |
protected java.lang.Class |
getReturnClass()
Returns the Class of Object returned by this method. |
protected java.lang.Class[] |
getThrowableClasses()
Returns the classes that the method throws. |
boolean |
isAbstract()
Returns whether the method being modelled is an abstract method. |
void |
validateArguments(java.lang.Object[] args)
This method checks that a list of arguments matches the signature of the method; i.e. |
void |
validateThrowable(java.lang.Throwable t)
This method checks that an exception can be thrown by this method. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MockMethod(java.lang.String id, int numArgs, java.lang.Class retClass, boolean isAbstract)
id
- An identifier for the method.numArgs
- The number of arguments that the method takes.retClass
- The class of the value to be returned by the method (null if
the method is void).isAbstract
- True if the method is abstract.public MockMethod(java.lang.Class clazz, java.lang.String id, java.lang.Class[] argClasses, java.lang.Class[] throwableClasses, java.lang.Class retClass, boolean isAbstract)
clazz
- The class that the method belongs to.id
- An identifier for the method.argClasses
- The classes of the arguments of the method.throwableClasses
- The classes of the exceptions that the method might throw.retClass
- The class of the value to be returned by the method (null if
the method is void).isAbstract
- True if the method is abstract.Method Detail |
---|
public java.lang.Class getMethodClass()
public java.lang.String getId()
protected java.lang.Class[] getArgumentClasses()
protected java.lang.Class[] getThrowableClasses()
protected java.lang.Class getReturnClass()
public boolean isAbstract()
public void validateArguments(java.lang.Object[] args)
args
- A list of arguments.
HammockException
- if the arguments are inconsistent with the method's
signature.public void validateThrowable(java.lang.Throwable t)
t
- The exception or error to throw.
HammockException
- if the exception is inconsistent with the method's signature.public int getNumberOfArguments()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |