public class MockRepository extends Object
Constructor and Description |
---|
MockRepository() |
Modifier and Type | Method and Description |
---|---|
static void |
addAfterMethodRunner(Runnable runnable)
Add a
Runnable that will be executed after each test |
static void |
addConstructorToSuppress(Constructor<?> constructor)
Add a constructor to suppress.
|
static void |
addFieldToSuppress(Field field)
Add a field to suppress.
|
static void |
addFieldTypeToSuppress(String fieldType)
Add a field type to suppress.
|
static void |
addMethodToSuppress(Method method)
Add a method to suppress.
|
static void |
addObjectsToAutomaticallyReplayAndVerify(Object... objects)
Add classes that should be automatically replayed or verified.
|
static void |
addSuppressStaticInitializer(String className)
Add a fully qualified class name for a class that should have its static
initializers suppressed.
|
static void |
clear()
Clear all state of the mock repository except for static initializers.
|
static <T> T |
getAdditionalState(String key)
Retrieve state based on the supplied key.
|
static MethodInvocationControl |
getInstanceMethodInvocationControl(Object instance) |
static InvocationHandler |
getMethodProxy(Method method) |
static Object |
getMethodToStub(Method method) |
static NewInvocationControl<?> |
getNewInstanceControl(Class<?> type) |
static Set<Object> |
getObjectsToAutomaticallyReplayAndVerify() |
static MethodInvocationControl |
getStaticMethodInvocationControl(Class<?> type) |
static boolean |
hasMethodProxy(Method method) |
static Object |
putAdditionalState(String key,
Object value)
When a mock framework API needs to store additional state not applicable
for the other methods, it may use this method to do so.
|
static MethodInvocationControl |
putInstanceMethodInvocationControl(Object instance,
MethodInvocationControl invocationControl) |
static InvocationHandler |
putMethodProxy(Method method,
InvocationHandler invocationHandler)
Set a proxy for a method.
|
static Object |
putMethodToStub(Method method,
Object value)
Set a substitute return value for a method.
|
static NewInvocationControl<?> |
putNewInstanceControl(Class<?> type,
NewInvocationControl<?> control) |
static MethodInvocationControl |
putStaticMethodInvocationControl(Class<?> type,
MethodInvocationControl invocationControl) |
static void |
remove(Object mock)
Removes an object from the MockRepository if it exists.
|
static Object |
removeAdditionalState(String key) |
static MethodInvocationControl |
removeClassMethodInvocationControl(Class<?> type) |
static MethodInvocationControl |
removeInstanceMethodInvocationControl(Class<?> type) |
static InvocationHandler |
removeMethodProxy(Method method) |
static void |
removeSuppressStaticInitializer(String className)
Remove a fully qualified class name for a class that should no longer
have its static initializers suppressed.
|
static boolean |
shouldStubMethod(Method method) |
static boolean |
shouldSuppressConstructor(Constructor<?> constructor) |
static boolean |
shouldSuppressField(Field field) |
static boolean |
shouldSuppressMethod(Method method,
Class<?> objectType) |
static boolean |
shouldSuppressStaticInitializerFor(String className)
Check whether or not a class with the fully qualified name should have
its static initializers suppressed.
|
public static void clear()
public static void remove(Object mock)
public static MethodInvocationControl getStaticMethodInvocationControl(Class<?> type)
public static MethodInvocationControl putStaticMethodInvocationControl(Class<?> type, MethodInvocationControl invocationControl)
public static MethodInvocationControl removeClassMethodInvocationControl(Class<?> type)
public static MethodInvocationControl getInstanceMethodInvocationControl(Object instance)
public static MethodInvocationControl putInstanceMethodInvocationControl(Object instance, MethodInvocationControl invocationControl)
public static MethodInvocationControl removeInstanceMethodInvocationControl(Class<?> type)
public static NewInvocationControl<?> getNewInstanceControl(Class<?> type)
public static NewInvocationControl<?> putNewInstanceControl(Class<?> type, NewInvocationControl<?> control)
public static void addSuppressStaticInitializer(String className)
className
- The fully qualified class name for a class that should have
its static initializers suppressed.public static void removeSuppressStaticInitializer(String className)
className
- The fully qualified class name for a class that should no
longer have its static initializers suppressed.public static boolean shouldSuppressStaticInitializerFor(String className)
className
- true
if class with the fully qualified name
className
should have its static initializers
suppressed, false
otherwise.public static Set<Object> getObjectsToAutomaticallyReplayAndVerify()
public static void addObjectsToAutomaticallyReplayAndVerify(Object... objects)
public static Object putAdditionalState(String key, Object value)
key
- The key under which the value is stored.value
- The value to store under the specified key.null
.public static InvocationHandler removeMethodProxy(Method method)
public static <T> T getAdditionalState(String key)
public static void addMethodToSuppress(Method method)
method
- The method to suppress.public static void addFieldToSuppress(Field field)
field
- The field to suppress.public static void addFieldTypeToSuppress(String fieldType)
fieldType
- The fully-qualified name to a type. All fields of this type
will be suppressed.public static void addConstructorToSuppress(Constructor<?> constructor)
constructor
- The constructor to suppress.public static boolean hasMethodProxy(Method method)
true
if the method should be proxied.public static boolean shouldSuppressMethod(Method method, Class<?> objectType) throws ClassNotFoundException
true
if the method should be suppressed.ClassNotFoundException
public static boolean shouldSuppressField(Field field)
true
if the field should be suppressed.public static boolean shouldSuppressConstructor(Constructor<?> constructor)
true
if the constructor should be
suppressed.public static boolean shouldStubMethod(Method method)
true
if the method has a substitute return
value.public static Object getMethodToStub(Method method)
null
.public static Object putMethodToStub(Method method, Object value)
value
will be returned instead.public static InvocationHandler getMethodProxy(Method method)
null
.public static InvocationHandler putMethodProxy(Method method, InvocationHandler invocationHandler)
Copyright © 2019. All rights reserved.