public abstract class MockInjectionStrategy
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
private MockInjectionStrategy |
nextStrategy |
| Constructor and Description |
|---|
MockInjectionStrategy() |
| Modifier and Type | Method and Description |
|---|---|
static MockInjectionStrategy |
nop()
NOP Strategy that will always try the next strategy.
|
boolean |
process(java.lang.reflect.Field onField,
java.lang.Object fieldOwnedBy,
java.util.Set<java.lang.Object> mockCandidates)
Actually inject mockCandidates on field.
|
protected abstract boolean |
processInjection(java.lang.reflect.Field field,
java.lang.Object fieldOwner,
java.util.Set<java.lang.Object> mockCandidates)
Process actual injection.
|
private boolean |
relayProcessToNextStrategy(java.lang.reflect.Field field,
java.lang.Object fieldOwner,
java.util.Set<java.lang.Object> mockCandidates) |
MockInjectionStrategy |
thenTry(MockInjectionStrategy strategy)
Enqueue next injection strategy.
|
private MockInjectionStrategy nextStrategy
public static MockInjectionStrategy nop()
public MockInjectionStrategy thenTry(MockInjectionStrategy strategy)
The implementation should take care of the actual calling if required.
strategy - Queued strategy.public boolean process(java.lang.reflect.Field onField,
java.lang.Object fieldOwnedBy,
java.util.Set<java.lang.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(java.lang.reflect.Field field,
java.lang.Object fieldOwner,
java.util.Set<java.lang.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 otherwiseprivate boolean relayProcessToNextStrategy(java.lang.reflect.Field field,
java.lang.Object fieldOwner,
java.util.Set<java.lang.Object> mockCandidates)