Home / Class/ OnPropertyListConditionTests Class — spring-boot Architecture

OnPropertyListConditionTests Class — spring-boot Architecture

Architecture documentation for the OnPropertyListConditionTests class in OnPropertyListConditionTests.java from the spring-boot codebase.

Entity Profile

Source Code

core/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/OnPropertyListConditionTests.java lines 33–86

class OnPropertyListConditionTests {

	private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
		.withUserConfiguration(TestConfig.class);

	@Test
	void propertyNotDefined() {
		this.contextRunner.run((context) -> assertThat(context).doesNotHaveBean("foo"));
	}

	@Test
	void propertyDefinedAsCommaSeparated() {
		this.contextRunner.withPropertyValues("spring.test.my-list=value1")
			.run((context) -> assertThat(context).hasBean("foo"));
	}

	@Test
	void propertyDefinedAsList() {
		this.contextRunner.withPropertyValues("spring.test.my-list[0]=value1")
			.run((context) -> assertThat(context).hasBean("foo"));
	}

	@Test
	void propertyDefinedAsCommaSeparatedRelaxed() {
		this.contextRunner.withPropertyValues("spring.test.myList=value1")
			.run((context) -> assertThat(context).hasBean("foo"));
	}

	@Test
	void propertyDefinedAsListRelaxed() {
		this.contextRunner.withPropertyValues("spring.test.myList[0]=value1")
			.run((context) -> assertThat(context).hasBean("foo"));
	}

	@Configuration(proxyBeanMethods = false)
	@Conditional(TestPropertyListCondition.class)
	static class TestConfig {

		@Bean
		String foo() {
			return "foo";
		}

	}

	static class TestPropertyListCondition extends OnPropertyListCondition {

		TestPropertyListCondition() {
			super("spring.test.my-list", () -> ConditionMessage.forCondition("test"));
		}

	}

}

Analyze Your Own Codebase

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

Try Supermodel Free