Package org.jmock.api
Class Invocation
- java.lang.Object
-
- org.jmock.api.Invocation
-
- All Implemented Interfaces:
org.hamcrest.SelfDescribing
public class Invocation extends java.lang.Object implements org.hamcrest.SelfDescribingThe static details about a method and the run-time details of its invocation.- Since:
- 1.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classInvocation.ExpectationModeSupport distinguish between building expectations and asserting against expectations.
-
Field Summary
Fields Modifier and Type Field Description private static java.util.Map<java.lang.Class<?>,java.lang.Class<?>>BOX_TYPESprivate java.lang.reflect.MethodinvokedMethodprivate java.lang.ObjectinvokedObjectprivate Invocation.ExpectationModemodestatic java.lang.Object[]NO_PARAMETERSprivate java.lang.Object[]parameterValues
-
Constructor Summary
Constructors Constructor Description Invocation(java.lang.Object invoked, java.lang.reflect.Method method, java.lang.Object... parameterValues)Invocation(Invocation.ExpectationMode mode, java.lang.Object invoked, java.lang.reflect.Method method, java.lang.Object... parameterValues)Invocation(Invocation.ExpectationMode mode, Invocation other)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.ObjectapplyTo(java.lang.Object target)voidcheckReturnTypeCompatibility(java.lang.Object value)voiddescribeTo(org.hamcrest.Description description)booleanequals(java.lang.Object other)booleanequals(Invocation other)private voidfailIfReturnTypeIsNotNull(java.lang.Object result)private voidfailIfReturnTypeIsPrimitive()java.lang.reflect.MethodgetInvokedMethod()java.lang.ObjectgetInvokedObject()java.lang.ObjectgetParameter(int i)intgetParameterCount()java.lang.Object[]getParametersAsArray()inthashCode()private booleanisBoxedType(java.lang.Class<?> primitiveType, java.lang.Class<?> referenceType)booleanisBuildingExpectation()private booleanisCompatible(java.lang.Class<?> returnType, java.lang.Class<?> valueType)private voidreportTypeError(java.lang.Class<?> returnType, java.lang.Class<?> valueType)java.lang.StringtoString()
-
-
-
Field Detail
-
NO_PARAMETERS
public static final java.lang.Object[] NO_PARAMETERS
-
invokedObject
private final java.lang.Object invokedObject
-
invokedMethod
private final java.lang.reflect.Method invokedMethod
-
parameterValues
private final java.lang.Object[] parameterValues
-
mode
private final Invocation.ExpectationMode mode
-
BOX_TYPES
private static final java.util.Map<java.lang.Class<?>,java.lang.Class<?>> BOX_TYPES
-
-
Constructor Detail
-
Invocation
public Invocation(Invocation.ExpectationMode mode, java.lang.Object invoked, java.lang.reflect.Method method, java.lang.Object... parameterValues)
-
Invocation
public Invocation(Invocation.ExpectationMode mode, Invocation other)
-
Invocation
public Invocation(java.lang.Object invoked, java.lang.reflect.Method method, java.lang.Object... parameterValues)
-
-
Method Detail
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equalsin classjava.lang.Object
-
equals
public boolean equals(Invocation other)
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
describeTo
public void describeTo(org.hamcrest.Description description)
- Specified by:
describeToin interfaceorg.hamcrest.SelfDescribing
-
getInvokedObject
public java.lang.Object getInvokedObject()
-
getInvokedMethod
public java.lang.reflect.Method getInvokedMethod()
-
getParameterCount
public int getParameterCount()
-
getParameter
public java.lang.Object getParameter(int i)
-
getParametersAsArray
public java.lang.Object[] getParametersAsArray()
-
applyTo
public java.lang.Object applyTo(java.lang.Object target) throws java.lang.Throwable- Throws:
java.lang.Throwable
-
checkReturnTypeCompatibility
public void checkReturnTypeCompatibility(java.lang.Object value)
-
isCompatible
private boolean isCompatible(java.lang.Class<?> returnType, java.lang.Class<?> valueType)
-
isBoxedType
private boolean isBoxedType(java.lang.Class<?> primitiveType, java.lang.Class<?> referenceType)
-
failIfReturnTypeIsNotNull
private void failIfReturnTypeIsNotNull(java.lang.Object result)
-
failIfReturnTypeIsPrimitive
private void failIfReturnTypeIsPrimitive()
-
reportTypeError
private void reportTypeError(java.lang.Class<?> returnType, java.lang.Class<?> valueType)
-
isBuildingExpectation
public boolean isBuildingExpectation()
-
-