public class MockitoPostProcessor
extends org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter
implements org.springframework.beans.factory.BeanClassLoaderAware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.config.BeanFactoryPostProcessor, org.springframework.core.Ordered
BeanFactoryPostProcessor
used to register and inject
@MockBeans
with the ApplicationContext
. An initial set of
definitions can be passed to the processor with additional definitions being
automatically created from @Configuration
classes that use
@MockBean
.Constructor and Description |
---|
MockitoPostProcessor(Set<org.springframework.boot.test.mock.mockito.Definition> definitions)
Create a new
MockitoPostProcessor instance with the given initial
definitions. |
Modifier and Type | Method and Description |
---|---|
protected Object |
createSpyIfNecessary(Object bean,
String beanName) |
int |
getOrder() |
void |
postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory) |
org.springframework.beans.PropertyValues |
postProcessPropertyValues(org.springframework.beans.PropertyValues pvs,
PropertyDescriptor[] pds,
Object bean,
String beanName) |
static void |
register(org.springframework.beans.factory.support.BeanDefinitionRegistry registry)
Register the processor with a
BeanDefinitionRegistry . |
static void |
register(org.springframework.beans.factory.support.BeanDefinitionRegistry registry,
Class<? extends MockitoPostProcessor> postProcessor,
Set<org.springframework.boot.test.mock.mockito.Definition> definitions)
Register the processor with a
BeanDefinitionRegistry . |
static void |
register(org.springframework.beans.factory.support.BeanDefinitionRegistry registry,
Set<org.springframework.boot.test.mock.mockito.Definition> definitions)
Register the processor with a
BeanDefinitionRegistry . |
void |
setBeanClassLoader(ClassLoader classLoader) |
void |
setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) |
determineCandidateConstructors, getEarlyBeanReference, postProcessAfterInitialization, postProcessAfterInstantiation, postProcessBeforeInitialization, postProcessBeforeInstantiation, postProcessProperties, predictBeanType
public MockitoPostProcessor(Set<org.springframework.boot.test.mock.mockito.Definition> definitions)
MockitoPostProcessor
instance with the given initial
definitions.definitions
- the initial definitionspublic void setBeanClassLoader(ClassLoader classLoader)
setBeanClassLoader
in interface org.springframework.beans.factory.BeanClassLoaderAware
public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) throws org.springframework.beans.BeansException
setBeanFactory
in interface org.springframework.beans.factory.BeanFactoryAware
org.springframework.beans.BeansException
public void postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory) throws org.springframework.beans.BeansException
postProcessBeanFactory
in interface org.springframework.beans.factory.config.BeanFactoryPostProcessor
org.springframework.beans.BeansException
protected final Object createSpyIfNecessary(Object bean, String beanName) throws org.springframework.beans.BeansException
org.springframework.beans.BeansException
public org.springframework.beans.PropertyValues postProcessPropertyValues(org.springframework.beans.PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName) throws org.springframework.beans.BeansException
postProcessPropertyValues
in interface org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor
postProcessPropertyValues
in class org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter
org.springframework.beans.BeansException
public int getOrder()
getOrder
in interface org.springframework.core.Ordered
public static void register(org.springframework.beans.factory.support.BeanDefinitionRegistry registry)
BeanDefinitionRegistry
. Not required when
using the SpringRunner
as registration is automatic.registry
- the bean definition registrypublic static void register(org.springframework.beans.factory.support.BeanDefinitionRegistry registry, Set<org.springframework.boot.test.mock.mockito.Definition> definitions)
BeanDefinitionRegistry
. Not required when
using the SpringRunner
as registration is automatic.registry
- the bean definition registrydefinitions
- the initial mock/spy definitionspublic static void register(org.springframework.beans.factory.support.BeanDefinitionRegistry registry, Class<? extends MockitoPostProcessor> postProcessor, Set<org.springframework.boot.test.mock.mockito.Definition> definitions)
BeanDefinitionRegistry
. Not required when
using the SpringRunner
as registration is automatic.registry
- the bean definition registrypostProcessor
- the post processor class to registerdefinitions
- the initial mock/spy definitionsCopyright © 2020 Pivotal Software, Inc.. All rights reserved.