Home / Class/ KotlinConfigurationPropertiesBeanRegistrarTests Class — spring-boot Architecture

KotlinConfigurationPropertiesBeanRegistrarTests Class — spring-boot Architecture

Architecture documentation for the KotlinConfigurationPropertiesBeanRegistrarTests class in KotlinConfigurationPropertiesBeanRegistrarTests.kt from the spring-boot codebase.

Entity Profile

Source Code

core/spring-boot/src/test/kotlin/org/springframework/boot/context/properties/KotlinConfigurationPropertiesBeanRegistrarTests.kt lines 29–69

@Suppress("unused")
class KotlinConfigurationPropertiesBeanRegistrarTests {

	private val beanFactory = DefaultListableBeanFactory()

	private val registrar = ConfigurationPropertiesBeanRegistrar(beanFactory)

	@Test
	fun `type with primary constructor and no autowired should register value object configuration properties`() {
		this.registrar.register(BarProperties::class.java)
		val beanDefinition = this.beanFactory.getBeanDefinition(
				"bar-org.springframework.boot.context.properties.KotlinConfigurationPropertiesBeanRegistrarTests\$BarProperties")
		assertThat(beanDefinition.hasAttribute(BindMethod::class.java.name)).isTrue()
		assertThat(beanDefinition.getAttribute(BindMethod::class.java.name)).isEqualTo(BindMethod.VALUE_OBJECT)
	}

	@Test
	fun `type with no primary constructor should register java bean configuration properties`() {
		this.registrar.register(BingProperties::class.java)
		val beanDefinition = this.beanFactory.getBeanDefinition(
				"bing-org.springframework.boot.context.properties.KotlinConfigurationPropertiesBeanRegistrarTests\$BingProperties")
		assertThat(beanDefinition.hasAttribute(BindMethod::class.java.name)).isTrue()
		assertThat(beanDefinition.getAttribute(BindMethod::class.java.name)).isEqualTo(BindMethod.JAVA_BEAN)
	}

	@ConfigurationProperties("foo")
	class FooProperties

	@ConfigurationProperties("bar")
	class BarProperties(val name: String?, val counter: Int = 42)

	@ConfigurationProperties("bing")
	class BingProperties {

		constructor()

		constructor(@Suppress("UNUSED_PARAMETER") foo: String)

	}

}

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free