public class MockitoPostProcessor extends InstantiationAwareBeanPostProcessorAdapter implements BeanClassLoaderAware, BeanFactoryAware, BeanFactoryPostProcessor, 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
.HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
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(ConfigurableListableBeanFactory beanFactory) |
PropertyValues |
postProcessPropertyValues(PropertyValues pvs,
PropertyDescriptor[] pds,
Object bean,
String beanName) |
static void |
register(BeanDefinitionRegistry registry)
Register the processor with a
BeanDefinitionRegistry . |
static void |
register(BeanDefinitionRegistry registry,
Class<? extends MockitoPostProcessor> postProcessor,
Set<org.springframework.boot.test.mock.mockito.Definition> definitions)
Register the processor with a
BeanDefinitionRegistry . |
static void |
register(BeanDefinitionRegistry registry,
Set<org.springframework.boot.test.mock.mockito.Definition> definitions)
Register the processor with a
BeanDefinitionRegistry . |
void |
setBeanClassLoader(ClassLoader classLoader) |
void |
setBeanFactory(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 BeanClassLoaderAware
public void setBeanFactory(BeanFactory beanFactory) throws BeansException
setBeanFactory
in interface BeanFactoryAware
BeansException
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException
postProcessBeanFactory
in interface BeanFactoryPostProcessor
BeansException
protected final Object createSpyIfNecessary(Object bean, String beanName) throws BeansException
BeansException
public PropertyValues postProcessPropertyValues(PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName) throws BeansException
postProcessPropertyValues
in interface InstantiationAwareBeanPostProcessor
postProcessPropertyValues
in class InstantiationAwareBeanPostProcessorAdapter
BeansException
public static void register(BeanDefinitionRegistry registry)
BeanDefinitionRegistry
. Not required when
using the SpringRunner
as registration is automatic.registry
- the bean definition registrypublic static void register(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(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 © 2018 Pivotal Software, Inc.. All rights reserved.