public class WithStaticFinder<T> extends Object
| Constructor and Description |
|---|
WithStaticFinder(Class<T> beanType)
Construct with a given bean type.
|
WithStaticFinder(Class<T> beanType,
String fieldName)
Construct with a given bean type.
|
| Modifier and Type | Method and Description |
|---|---|
WithStaticFinder |
as(Object testDouble)
Set the test double instance to use after useTestDouble() has been called.
|
void |
restoreOriginal()
Restore the original implementation using reflection.
|
static <U> WithStaticFinder<U> |
use(Class<U> cls,
Object testFinder)
Set the given test double onto the given class returning the WithStaticFinder.
|
void |
useTestDouble()
Set the test double to the field using reflection.
|
public WithStaticFinder(Class<T> beanType)
public WithStaticFinder(Class<T> beanType, String fieldName)
public WithStaticFinder as(Object testDouble) throws FinderFieldNotFoundException
useTestDouble() is called.FinderFieldNotFoundExceptionpublic void useTestDouble()
public void restoreOriginal()
public static <U> WithStaticFinder<U> use(Class<U> cls, Object testFinder)
Use restore to put the original finder back onto the class.
// Replace the finder with TDCustFinder
WithStaticFinder with = WithStaticFinder.use(Customer.class, new TDCustFinder());
try {
// perform some test
Customer jim = Customer.find.byName("jim");
} finally {
// restore the original finder
with.restoreOriginal();
}
Copyright © 2016. All rights reserved.