BeanDefinitionParserUtils { public static void addConstructorArgReference(BeanDefinitionBuilder builder, String beanReference) { if (StringUtils.hasText(beanReference)) { builder.addConstructorArgReference(beanReference); } } private  BeanDefinitionParserUtils(); static void setPropertyValue(BeanDefinitionBuilder builder, String propertyValue, String propertyName); static void setConstructorArgValue(BeanDefinitionBuilder builder, String propertyValue); static void setPropertyReference(BeanDefinitionBuilder builder, String beanReference, String propertyName); static void addConstructorArgReference(BeanDefinitionBuilder builder, String beanReference); static void setPropertyReference(BeanDefinitionBuilder builder, String beanReference, String propertyName, String defaultValue); static BeanDefinitionHolder registerBean(String beanId, Class<?> beanClass, ParserContext parserContext, boolean shouldFireEvents); static BeanDefinitionHolder registerBean(String beanId, BeanDefinition beanDefinition, ParserContext parserContext, boolean shouldFireEvents);  }
@Test public void testAddConstructorArgReference() { BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(); BeanDefinitionParserUtils.addConstructorArgReference(builder, "beanref"); Assert.assertEquals(builder.getBeanDefinition().getConstructorArgumentValues().getArgumentCount(), 1); Assert.assertEquals(builder.getBeanDefinition().getConstructorArgumentValues().getArgumentValue(0, String.class).getValue().getClass(), RuntimeBeanReference.class); Assert.assertEquals(((RuntimeBeanReference)builder.getBeanDefinition().getConstructorArgumentValues().getArgumentValue(0, String.class).getValue()).getBeanName(), "beanref"); }
@Test public void testAddConstructorArgNullReference() { BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(); BeanDefinitionParserUtils.addConstructorArgReference(builder, null); Assert.assertEquals(builder.getBeanDefinition().getConstructorArgumentValues().getArgumentCount(), 0); }