Drop MockitoPostProcessor factory method

Remove factory method previously used to create the mock instance.
Since commit 0e00a49dcc, the method is not longer needed.

See gh-11077
pull/14206/merge
Phillip Webb 6 years ago
parent a32cd1965e
commit 82b27c60a4

@ -183,13 +183,11 @@ public class MockitoPostProcessor extends InstantiationAwareBeanPostProcessorAda
RootBeanDefinition beanDefinition = createBeanDefinition(definition);
String beanName = getBeanName(beanFactory, registry, definition, beanDefinition);
String transformedBeanName = BeanFactoryUtils.transformedBeanName(beanName);
beanDefinition.getConstructorArgumentValues().addIndexedArgumentValue(1,
beanName);
if (registry.containsBeanDefinition(transformedBeanName)) {
registry.removeBeanDefinition(transformedBeanName);
}
registry.registerBeanDefinition(transformedBeanName, beanDefinition);
Object mock = createMock(definition, beanName);
Object mock = definition.createMock(beanName + " bean");
beanFactory.registerSingleton(transformedBeanName, mock);
this.mockitoBeans.add(mock);
this.beanNameRegistry.put(definition, beanName);
@ -202,26 +200,12 @@ public class MockitoPostProcessor extends InstantiationAwareBeanPostProcessorAda
RootBeanDefinition definition = new RootBeanDefinition(
mockDefinition.getTypeToMock().resolve());
definition.setTargetType(mockDefinition.getTypeToMock());
definition.setFactoryBeanName(BEAN_NAME);
definition.setFactoryMethodName("createMock");
definition.getConstructorArgumentValues().addIndexedArgumentValue(0,
mockDefinition);
if (mockDefinition.getQualifier() != null) {
mockDefinition.getQualifier().applyTo(definition);
}
return definition;
}
/**
* Factory method used by defined beans to actually create the mock.
* @param mockDefinition the mock definition
* @param name the bean name
* @return the mock instance
*/
protected final Object createMock(MockDefinition mockDefinition, String name) {
return mockDefinition.createMock(name + " bean");
}
private String getBeanName(ConfigurableListableBeanFactory beanFactory,
BeanDefinitionRegistry registry, MockDefinition mockDefinition,
RootBeanDefinition beanDefinition) {

Loading…
Cancel
Save