public abstract class MockInjectionStrategy extends Object
Constructor and Description |
---|
MockInjectionStrategy() |
Modifier and Type | Method and Description |
---|---|
static MockInjectionStrategy |
nop()
NOP Strategy that will always try the next strategy.
|
boolean |
process(Field onField,
Object fieldOwnedBy,
Set<Object> mockCandidates)
Actually inject mockCandidates on field.
|
protected abstract boolean |
processInjection(Field field,
Object fieldOwner,
Set<Object> mockCandidates)
Process actual injection.
|
MockInjectionStrategy |
thenTry(MockInjectionStrategy strategy)
Enqueue next injection strategy.
|
public static final MockInjectionStrategy nop()
public MockInjectionStrategy thenTry(MockInjectionStrategy strategy)
The implementation should take care of the actual calling if required.
strategy
- Queued strategy.public boolean process(Field onField, Object fieldOwnedBy, Set<Object> mockCandidates)
Actual algorithm is defined in the implementations of processInjection(Field, Object, Set)
.
However if injection occurred successfully, the process should return true
,
and false
otherwise.
The code takes care of calling the next strategy if available and if of course if required
onField
- Field needing injection.fieldOwnedBy
- The owning instance of the field.mockCandidates
- A set of mock candidate, that might be injected.true
if successful, false
otherwise.protected abstract boolean processInjection(Field field, Object fieldOwner, Set<Object> mockCandidates)
Don't call this method directly, instead call process(Field, Object, Set)
field
- Field needing injectionfieldOwner
- Field owner instance.mockCandidates
- Pool of mocks to inject.true
if injection occurred, false
otherwise