@Service public class MockitoService extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private ServiceLocator |
locator |
private MemberCache |
memberCache |
private ObjectFactory |
objectFactory |
private ParentCache |
parentCache |
private IterableProvider<InjectionResolver> |
resolvers |
private java.lang.Class |
sut |
private InjectionResolver<javax.inject.Inject> |
systemResolver |
Constructor and Description |
---|
MockitoService(MemberCache memberCache,
ParentCache parentCache,
ObjectFactory objectFactory,
ServiceLocator locator,
IterableProvider<InjectionResolver> resolvers,
InjectionResolver systemResolver) |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
createOrFindService(Injectee injectee,
ServiceHandle<?> root)
Given an injectee create and cache or resolve the service associated with
it.
|
java.lang.Object |
findOrCreateCollaborator(int position,
java.lang.String fieldName,
Injectee injectee,
ServiceHandle<?> root)
Given metadata about collborator an an injectee create or resolve the
collaborating service.
|
java.lang.Object |
findOrCreateSUT(SUT sut,
Injectee injectee,
ServiceHandle<?> root)
Given an SUT annotation and an injectee resolve the service associated
with the injectee and use the metadata in the SUT annotation to possibly
create a mockito spy.
|
private java.lang.String |
getFieldName(java.lang.String fieldName,
java.lang.String defaultName) |
private java.util.Map<MockitoCacheKey,java.lang.Object> |
primeCache(java.lang.Class type)
Given a class analyze its fields, create services, create mock/spy
proxies of found services, and them to the cache.
|
java.lang.Object |
resolve(Injectee injectee,
ServiceHandle<?> root)
Given an injectee find the service by iterating through all the resolvers
in the system to resolve it.
|
private final MemberCache memberCache
private final ParentCache parentCache
private final ObjectFactory objectFactory
private final IterableProvider<InjectionResolver> resolvers
private final InjectionResolver<javax.inject.Inject> systemResolver
private final ServiceLocator locator
private java.lang.Class sut
@Inject MockitoService(MemberCache memberCache, ParentCache parentCache, ObjectFactory objectFactory, ServiceLocator locator, IterableProvider<InjectionResolver> resolvers, @Named(value="SystemInjectResolver") InjectionResolver systemResolver)
public java.lang.Object resolve(Injectee injectee, ServiceHandle<?> root)
injectee
- The injection point this value is being injected intoroot
- The service handle of the root class being created, which
should be used in order to ensure proper destruction of associated
&64;PerLookup scoped objects. This can be null in the case that this is
being used for an object not managed by HK2. This will only happen if
this object is being created with the create method of ServiceLocator.public java.lang.Object findOrCreateSUT(SUT sut, Injectee injectee, ServiceHandle<?> root)
sut
- annotation containing sut config meta-datainjectee
- The injection point this value is being injected intoroot
- The service handle of the root class being createdpublic java.lang.Object createOrFindService(Injectee injectee, ServiceHandle<?> root)
injectee
- The injection point this value is being injected intoroot
- The service handle of the root class being createdpublic java.lang.Object findOrCreateCollaborator(int position, java.lang.String fieldName, Injectee injectee, ServiceHandle<?> root)
position
- method or constructor the parameter position metadatafieldName
- field name metadatainjectee
- The injection point this value is being injected intoroot
- The service handle of the root class being createdprivate java.util.Map<MockitoCacheKey,java.lang.Object> primeCache(java.lang.Class type)
type
- the class that will be analyzedprivate java.lang.String getFieldName(java.lang.String fieldName, java.lang.String defaultName)