parent
d485708f68
commit
547fc30ead
|
@ -67,6 +67,7 @@ import org.springframework.util.StringUtils;
|
||||||
* @author Jakub Kubrynski
|
* @author Jakub Kubrynski
|
||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
* @author Andy Wilkinson
|
* @author Andy Wilkinson
|
||||||
|
* @author Jorge Cordoba
|
||||||
* @see ConditionalOnBean
|
* @see ConditionalOnBean
|
||||||
* @see ConditionalOnMissingBean
|
* @see ConditionalOnMissingBean
|
||||||
* @see ConditionalOnSingleCandidate
|
* @see ConditionalOnSingleCandidate
|
||||||
|
@ -387,7 +388,7 @@ class OnBeanCondition extends FilteringSpringBootCondition implements Configurat
|
||||||
|
|
||||||
private final ClassLoader classLoader;
|
private final ClassLoader classLoader;
|
||||||
|
|
||||||
private final Class<?> annotationType;
|
private final Class<? extends Annotation> annotationType;
|
||||||
|
|
||||||
private final Set<String> names;
|
private final Set<String> names;
|
||||||
|
|
||||||
|
@ -581,11 +582,11 @@ class OnBeanCondition extends FilteringSpringBootCondition implements Configurat
|
||||||
}
|
}
|
||||||
|
|
||||||
ConditionMessage.Builder message() {
|
ConditionMessage.Builder message() {
|
||||||
return ConditionMessage.forCondition(ConditionalOnBean.class, this);
|
return ConditionMessage.forCondition(this.annotationType, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
ConditionMessage.Builder message(ConditionMessage message) {
|
ConditionMessage.Builder message(ConditionMessage message) {
|
||||||
return message.andCondition(ConditionalOnBean.class, this);
|
return message.andCondition(this.annotationType, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -21,6 +21,7 @@ import java.lang.annotation.ElementType;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
@ -57,6 +58,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
* @author Jakub Kubrynski
|
* @author Jakub Kubrynski
|
||||||
* @author Andy Wilkinson
|
* @author Andy Wilkinson
|
||||||
|
* @author Jorge Cordoba
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("resource")
|
@SuppressWarnings("resource")
|
||||||
public class ConditionalOnMissingBeanTests {
|
public class ConditionalOnMissingBeanTests {
|
||||||
|
@ -135,6 +137,16 @@ public class ConditionalOnMissingBeanTests {
|
||||||
assertThat(context.getBean("foo")).isEqualTo("foo");
|
assertThat(context.getBean("foo")).isEqualTo("foo");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@Test
|
||||||
|
void testOnMissingBeanConditionOutputShouldNotContainConditionalOnBeanClassInMessage() {
|
||||||
|
this.contextRunner.withUserConfiguration(ConditionalOnMissingBeanTests.OnBeanNameConfiguration.class).run((context) -> {
|
||||||
|
Collection<ConditionEvaluationReport.ConditionAndOutcomes> conditionAndOutcomes = ConditionEvaluationReport
|
||||||
|
.get(context.getSourceApplicationContext().getBeanFactory()).getConditionAndOutcomesBySource()
|
||||||
|
.values();
|
||||||
|
String message = conditionAndOutcomes.iterator().next().iterator().next().getOutcome().getMessage();
|
||||||
|
assertThat(message).doesNotContain("@ConditionalOnBean (names: foo; SearchStrategy: all) did not find any beans");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testOnMissingBeanConditionWithFactoryBean() {
|
void testOnMissingBeanConditionWithFactoryBean() {
|
||||||
|
|
Loading…
Reference in New Issue