org.mockito.internal.configuration.injection
Class PropertyAndSetterInjection

java.lang.Object
  extended by org.mockito.internal.configuration.injection.MockInjectionStrategy
      extended by org.mockito.internal.configuration.injection.PropertyAndSetterInjection

public class PropertyAndSetterInjection
extends MockInjectionStrategy

Inject mocks using first setters then fields, if no setters available.

Algorithm :
for each field annotated by @InjectMocks

Note: If the field needing injection is not initialized, the strategy tries to create one using a no-arg constructor of the field type.


Constructor Summary
PropertyAndSetterInjection()
           
 
Method Summary
 boolean processInjection(java.lang.reflect.Field injectMocksField, java.lang.Object injectMocksFieldOwner, java.util.Set<java.lang.Object> mockCandidates)
          Process actual injection.
 
Methods inherited from class org.mockito.internal.configuration.injection.MockInjectionStrategy
nop, process, thenTry
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertyAndSetterInjection

public PropertyAndSetterInjection()
Method Detail

processInjection

public boolean processInjection(java.lang.reflect.Field injectMocksField,
                                java.lang.Object injectMocksFieldOwner,
                                java.util.Set<java.lang.Object> mockCandidates)
Description copied from class: MockInjectionStrategy
Process actual injection.

Don't call this method directly, instead call MockInjectionStrategy.process(Field, Object, Set)

Specified by:
processInjection in class MockInjectionStrategy
Parameters:
injectMocksField - Field needing injection
injectMocksFieldOwner - Field owner instance.
mockCandidates - Pool of mocks to inject.
Returns:
true if injection occurred, false otherwise