public class MockitoPostProcessor extends Object implements InstantiationAwareBeanPostProcessor, 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 |
postProcessProperties(PropertyValues pvs,
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) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitpostProcessAfterInstantiation, postProcessBeforeInstantiation, postProcessPropertyValuespostProcessAfterInitialization, postProcessBeforeInitializationpublic 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 BeanClassLoaderAwarepublic void setBeanFactory(BeanFactory beanFactory) throws BeansException
setBeanFactory in interface BeanFactoryAwareBeansExceptionpublic void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException
postProcessBeanFactory in interface BeanFactoryPostProcessorBeansExceptionprotected final Object createSpyIfNecessary(Object bean, String beanName) throws BeansException
BeansExceptionpublic PropertyValues postProcessProperties(PropertyValues pvs, Object bean, String beanName) throws BeansException
postProcessProperties in interface InstantiationAwareBeanPostProcessorBeansExceptionpublic 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 definitions