AllNestedConditionsTests Class — spring-boot Architecture
Architecture documentation for the AllNestedConditionsTests class in AllNestedConditionsTests.java from the spring-boot codebase.
Entity Profile
Source Code
core/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/AllNestedConditionsTests.java lines 36–114
class AllNestedConditionsTests {
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner();
@Test
void neither() {
this.contextRunner.withUserConfiguration(Config.class).run(match(false));
}
@Test
void propertyA() {
this.contextRunner.withUserConfiguration(Config.class).withPropertyValues("a:a").run(match(false));
}
@Test
void propertyB() {
this.contextRunner.withUserConfiguration(Config.class).withPropertyValues("b:b").run(match(false));
}
@Test
void both() {
this.contextRunner.withUserConfiguration(Config.class).withPropertyValues("a:a", "b:b").run(match(true));
}
private ContextConsumer<AssertableApplicationContext> match(boolean expected) {
return (context) -> {
if (expected) {
assertThat(context).hasBean("myBean");
}
else {
assertThat(context).doesNotHaveBean("myBean");
}
};
}
@Configuration(proxyBeanMethods = false)
@Conditional(OnPropertyAAndBCondition.class)
static class Config {
@Bean
String myBean() {
return "myBean";
}
}
static class OnPropertyAAndBCondition extends AllNestedConditions {
OnPropertyAAndBCondition() {
super(ConfigurationPhase.PARSE_CONFIGURATION);
}
@ConditionalOnProperty("a")
static class HasPropertyA {
}
@ConditionalOnProperty("b")
static class HasPropertyB {
}
@Conditional(NonSpringBootCondition.class)
static class SubclassC {
}
}
static class NonSpringBootCondition implements Condition {
@Override
public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
return true;
}
}
}
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free