NoneNestedConditionsTests Class — spring-boot Architecture
Architecture documentation for the NoneNestedConditionsTests class in NoneNestedConditionsTests.java from the spring-boot codebase.
Entity Profile
Source Code
core/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/NoneNestedConditionsTests.java lines 35–116
class NoneNestedConditionsTests {
@Test
void neither() {
AnnotationConfigApplicationContext context = load(Config.class);
assertThat(context.containsBean("myBean")).isTrue();
context.close();
}
@Test
void propertyA() {
AnnotationConfigApplicationContext context = load(Config.class, "a:a");
assertThat(context.containsBean("myBean")).isFalse();
context.close();
}
@Test
void propertyB() {
AnnotationConfigApplicationContext context = load(Config.class, "b:b");
assertThat(context.containsBean("myBean")).isFalse();
context.close();
}
@Test
void both() {
AnnotationConfigApplicationContext context = load(Config.class, "a:a", "b:b");
assertThat(context.containsBean("myBean")).isFalse();
context.close();
}
private AnnotationConfigApplicationContext load(Class<?> config, String... env) {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
TestPropertyValues.of(env).applyTo(context);
context.register(config);
context.refresh();
return context;
}
@Configuration(proxyBeanMethods = false)
@Conditional(NeitherPropertyANorPropertyBCondition.class)
static class Config {
@Bean
String myBean() {
return "myBean";
}
}
static class NeitherPropertyANorPropertyBCondition extends NoneNestedConditions {
NeitherPropertyANorPropertyBCondition() {
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 false;
}
}
}
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free