public class MockitoPostProcessor
extends java.lang.Object
implements org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor, 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(java.util.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 java.lang.Object |
createSpyIfNecessary(java.lang.Object bean,
java.lang.String beanName) |
int |
getOrder() |
void |
postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory) |
org.springframework.beans.PropertyValues |
postProcessProperties(org.springframework.beans.PropertyValues pvs,
java.lang.Object bean,
java.lang.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,
java.lang.Class<? extends MockitoPostProcessor> postProcessor,
java.util.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,
java.util.Set<org.springframework.boot.test.mock.mockito.Definition> definitions)
Register the processor with a
BeanDefinitionRegistry. |
void |
setBeanClassLoader(java.lang.ClassLoader classLoader) |
void |
setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitpublic MockitoPostProcessor(java.util.Set<org.springframework.boot.test.mock.mockito.Definition> definitions)
MockitoPostProcessor instance with the given initial
definitions.definitions - the initial definitionspublic void setBeanClassLoader(java.lang.ClassLoader classLoader)
setBeanClassLoader in interface org.springframework.beans.factory.BeanClassLoaderAwarepublic void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
throws org.springframework.beans.BeansException
setBeanFactory in interface org.springframework.beans.factory.BeanFactoryAwareorg.springframework.beans.BeansExceptionpublic void postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)
throws org.springframework.beans.BeansException
postProcessBeanFactory in interface org.springframework.beans.factory.config.BeanFactoryPostProcessororg.springframework.beans.BeansExceptionprotected final java.lang.Object createSpyIfNecessary(java.lang.Object bean,
java.lang.String beanName)
throws org.springframework.beans.BeansException
org.springframework.beans.BeansExceptionpublic org.springframework.beans.PropertyValues postProcessProperties(org.springframework.beans.PropertyValues pvs,
java.lang.Object bean,
java.lang.String beanName)
throws org.springframework.beans.BeansException
postProcessProperties in interface org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessororg.springframework.beans.BeansExceptionpublic int getOrder()
getOrder in interface org.springframework.core.Orderedpublic 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,
java.util.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,
java.lang.Class<? extends MockitoPostProcessor> postProcessor,
java.util.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