Skip to content

Commit 500f475

Browse files
committed
Fixed factory-method checks
1 parent d852e51 commit 500f475

File tree

4 files changed

+26
-0
lines changed

4 files changed

+26
-0
lines changed

src/main/java/pro/akvel/spring/converter/xml/BeanSupportValidator.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ private boolean isBeanSupport(BeanDefinition beanDefinition,
7979
return false;
8080
}
8181

82+
if (beanDefinition.getFactoryMethodName() != null) {
83+
log.debug("Skipped" + name + ". Convert bean with factory method no supported");
84+
return false;
85+
}
86+
8287
for (int index = 0; index < beanDefinition.getConstructorArgumentValues().getIndexedArgumentValues().size(); index++) {
8388
if (!beanDefinition.getConstructorArgumentValues().getIndexedArgumentValues().containsKey(index)) {
8489
log.debug("Skipped" + name + ". Missed index " + index);

src/test/java/pro/akvel/spring/converter/xml/BeanSupportValidatorTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ public void beanWithMap() {
5959
Assertions.assertFalse(validator.isBeanSupport(definition, "test", mockRegistry));
6060
}
6161

62+
@Test
63+
public void BeanWithSubBeanWithFactory() {
64+
String beanName = "BeanWithSubBeanWithFactory";
65+
BeanDefinition definition = reader.getBeanFactory().get().getBeanDefinition(beanName);
66+
Assertions.assertFalse(validator.isBeanSupport(definition, "test", mockRegistry));
67+
}
68+
69+
70+
6271
@Test
6372
public void beanWithList() {
6473
String beanName = "BeanWithConstructorListArg";

src/test/resources/pro/akvel/spring/converter/xml/configs/spring-bean-configuration-full.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,4 +400,11 @@
400400
<!-- Not supported -->
401401
<bean id="BeanWithAutowire" class="org.springframework.beans.BeanWithAutowire" autowire="constructor"/>
402402

403+
404+
<!-- Not supported -->
405+
<bean id="BeanWithSubBeanWithFactory" class="org.springframework.beans.BeanWithSubBeanWithFactory" >
406+
<constructor-arg>
407+
<bean class="org.springframework.beans.ManagementServerNode" factory-method="getManagementServerId" />
408+
</constructor-arg>
409+
</bean>
403410
</beans>

src/test/resources/pro/akvel/spring/converter/xml/write/expected/spring-bean-configuration-full.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,9 @@
158158

159159
<bean id="BeanWithAutowire" class="org.springframework.beans.BeanWithAutowire" autowire="constructor" />
160160

161+
<bean id="BeanWithSubBeanWithFactory" class="org.springframework.beans.BeanWithSubBeanWithFactory" >
162+
<constructor-arg>
163+
<bean class="org.springframework.beans.ManagementServerNode" factory-method="getManagementServerId" />
164+
</constructor-arg>
165+
</bean>
161166
</beans>

0 commit comments

Comments
 (0)