File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed
spring-boot-project/spring-boot-autoconfigure/src
main/java/org/springframework/boot/autoconfigure/condition
test/java/org/springframework/boot/autoconfigure/condition Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change 67
67
* @author Jakub Kubrynski
68
68
* @author Stephane Nicoll
69
69
* @author Andy Wilkinson
70
+ * @author Jorge Cordoba
70
71
* @see ConditionalOnBean
71
72
* @see ConditionalOnMissingBean
72
73
* @see ConditionalOnSingleCandidate
@@ -387,7 +388,7 @@ private static class Spec<A extends Annotation> {
387
388
388
389
private final ClassLoader classLoader ;
389
390
390
- private final Class <?> annotationType ;
391
+ private final Class <? extends Annotation > annotationType ;
391
392
392
393
private final Set <String > names ;
393
394
@@ -581,11 +582,11 @@ Set<Class<?>> getParameterizedContainers() {
581
582
}
582
583
583
584
ConditionMessage .Builder message () {
584
- return ConditionMessage .forCondition (ConditionalOnBean . class , this );
585
+ return ConditionMessage .forCondition (this . annotationType , this );
585
586
}
586
587
587
588
ConditionMessage .Builder message (ConditionMessage message ) {
588
- return message .andCondition (ConditionalOnBean . class , this );
589
+ return message .andCondition (this . annotationType , this );
589
590
}
590
591
591
592
@ Override
Original file line number Diff line number Diff line change 21
21
import java .lang .annotation .Retention ;
22
22
import java .lang .annotation .RetentionPolicy ;
23
23
import java .lang .annotation .Target ;
24
+ import java .util .Collection ;
24
25
import java .util .Date ;
25
26
import java .util .function .Consumer ;
26
27
57
58
* @author Phillip Webb
58
59
* @author Jakub Kubrynski
59
60
* @author Andy Wilkinson
61
+ * @author Jorge Cordoba
60
62
*/
61
63
@ SuppressWarnings ("resource" )
62
64
public class ConditionalOnMissingBeanTests {
@@ -135,6 +137,16 @@ void testAnnotationOnMissingBeanConditionWithEagerFactoryBean() {
135
137
assertThat (context .getBean ("foo" )).isEqualTo ("foo" );
136
138
});
137
139
}
140
+ @ Test
141
+ void testOnMissingBeanConditionOutputShouldNotContainConditionalOnBeanClassInMessage () {
142
+ this .contextRunner .withUserConfiguration (ConditionalOnMissingBeanTests .OnBeanNameConfiguration .class ).run ((context ) -> {
143
+ Collection <ConditionEvaluationReport .ConditionAndOutcomes > conditionAndOutcomes = ConditionEvaluationReport
144
+ .get (context .getSourceApplicationContext ().getBeanFactory ()).getConditionAndOutcomesBySource ()
145
+ .values ();
146
+ String message = conditionAndOutcomes .iterator ().next ().iterator ().next ().getOutcome ().getMessage ();
147
+ assertThat (message ).doesNotContain ("@ConditionalOnBean (names: foo; SearchStrategy: all) did not find any beans" );
148
+ });
149
+ }
138
150
139
151
@ Test
140
152
void testOnMissingBeanConditionWithFactoryBean () {
You can’t perform that action at this time.
0 commit comments