Revise contribution

See gh-34006
This commit is contained in:
Sam Brannen
2025-02-10 11:42:24 +01:00
parent cf46f391d7
commit d59991fcc9
5 changed files with 64 additions and 40 deletions

View File

@@ -85,9 +85,11 @@ class BeanOverrideBeanFactoryPostProcessorTests {
assertThatIllegalStateException()
.isThrownBy(context::refresh)
.withMessageStartingWith("""
.withMessage("""
Unable to replace bean: there is no bean with name 'descriptionBean' \
and type java.lang.String (as required by field 'ByNameTestCase.description').""");
and type java.lang.String (as required by field 'ByNameTestCase.description'). \
If the bean is defined in a @Bean method, make sure the return type is the most \
specific type possible (for example, the concrete implementation type).""");
}
@Test
@@ -97,9 +99,11 @@ class BeanOverrideBeanFactoryPostProcessorTests {
assertThatIllegalStateException()
.isThrownBy(context::refresh)
.withMessageStartingWith("""
.withMessage("""
Unable to replace bean: there is no bean with name 'descriptionBean' \
and type java.lang.String (as required by field 'ByNameTestCase.description').""");
and type java.lang.String (as required by field 'ByNameTestCase.description'). \
If the bean is defined in a @Bean method, make sure the return type is the most \
specific type possible (for example, the concrete implementation type).""");
}
@Test
@@ -144,9 +148,11 @@ class BeanOverrideBeanFactoryPostProcessorTests {
assertThatIllegalStateException()
.isThrownBy(context::refresh)
.withMessageStartingWith("""
.withMessage("""
Unable to override bean: there are no beans of type java.lang.Integer \
(as required by field 'ByTypeTestCase.counter').""");
(as required by field 'ByTypeTestCase.counter'). \
If the bean is defined in a @Bean method, make sure the return type is the most \
specific type possible (for example, the concrete implementation type).""");
}
@Test

View File

@@ -40,9 +40,11 @@ public class TestBeanTests {
BeanOverrideContextCustomizerTestUtils.customizeApplicationContext(FailureByNameLookup.class, context);
assertThatIllegalStateException()
.isThrownBy(context::refresh)
.withMessageStartingWith("""
.withMessage("""
Unable to replace bean: there is no bean with name 'beanToOverride' \
and type java.lang.String (as required by field 'FailureByNameLookup.example').""");
and type java.lang.String (as required by field 'FailureByNameLookup.example'). \
If the bean is defined in a @Bean method, make sure the return type is the most \
specific type possible (for example, the concrete implementation type).""");
}
@Test
@@ -52,9 +54,11 @@ public class TestBeanTests {
BeanOverrideContextCustomizerTestUtils.customizeApplicationContext(FailureByNameLookup.class, context);
assertThatIllegalStateException()
.isThrownBy(context::refresh)
.withMessageStartingWith("""
.withMessage("""
Unable to replace bean: there is no bean with name 'beanToOverride' \
and type java.lang.String (as required by field 'FailureByNameLookup.example').""");
and type java.lang.String (as required by field 'FailureByNameLookup.example'). \
If the bean is defined in a @Bean method, make sure the return type is the most \
specific type possible (for example, the concrete implementation type).""");
}
@Test
@@ -63,9 +67,10 @@ public class TestBeanTests {
BeanOverrideContextCustomizerTestUtils.customizeApplicationContext(FailureByTypeLookup.class, context);
assertThatIllegalStateException()
.isThrownBy(context::refresh)
.withMessageStartingWith("""
Unable to override bean: there are no beans of \
type %s (as required by field '%s.example').""",
.withMessage("""
Unable to override bean: there are no beans of type %s (as required by field '%s.example'). \
If the bean is defined in a @Bean method, make sure the return type is the most \
specific type possible (for example, the concrete implementation type).""",
String.class.getName(), FailureByTypeLookup.class.getSimpleName());
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -40,9 +40,11 @@ class MockitoBeanConfigurationErrorTests {
BeanOverrideContextCustomizerTestUtils.customizeApplicationContext(FailureByNameLookup.class, context);
assertThatIllegalStateException()
.isThrownBy(context::refresh)
.withMessageStartingWith("""
.withMessage("""
Unable to replace bean: there is no bean with name 'beanToOverride' \
and type java.lang.String (as required by field 'FailureByNameLookup.example').""");
and type java.lang.String (as required by field 'FailureByNameLookup.example'). \
If the bean is defined in a @Bean method, make sure the return type is the most \
specific type possible (for example, the concrete implementation type).""");
}
@Test
@@ -52,9 +54,11 @@ class MockitoBeanConfigurationErrorTests {
BeanOverrideContextCustomizerTestUtils.customizeApplicationContext(FailureByNameLookup.class, context);
assertThatIllegalStateException()
.isThrownBy(context::refresh)
.withMessageStartingWith("""
.withMessage("""
Unable to replace bean: there is no bean with name 'beanToOverride' \
and type java.lang.String (as required by field 'FailureByNameLookup.example').""");
and type java.lang.String (as required by field 'FailureByNameLookup.example'). \
If the bean is defined in a @Bean method, make sure the return type is the most \
specific type possible (for example, the concrete implementation type).""");
}
@Test
@@ -63,9 +67,11 @@ class MockitoBeanConfigurationErrorTests {
BeanOverrideContextCustomizerTestUtils.customizeApplicationContext(FailureByTypeLookup.class, context);
assertThatIllegalStateException()
.isThrownBy(context::refresh)
.withMessageStartingWith("""
.withMessage("""
Unable to override bean: there are no beans of \
type java.lang.String (as required by field 'FailureByTypeLookup.example').""");
type java.lang.String (as required by field 'FailureByTypeLookup.example'). \
If the bean is defined in a @Bean method, make sure the return type is the most \
specific type possible (for example, the concrete implementation type).""");
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -41,7 +41,9 @@ class MockitoSpyBeanConfigurationErrorTests {
.isThrownBy(context::refresh)
.withMessage("""
Unable to wrap bean: there is no bean with name 'beanToSpy' and \
type java.lang.String (as required by field 'ByNameSingleLookup.example').""");
type java.lang.String (as required by field 'ByNameSingleLookup.example'). \
If the bean is defined in a @Bean method, make sure the return type is the most \
specific type possible (for example, the concrete implementation type).""");
}
@Test
@@ -50,9 +52,11 @@ class MockitoSpyBeanConfigurationErrorTests {
BeanOverrideContextCustomizerTestUtils.customizeApplicationContext(ByTypeSingleLookup.class, context);
assertThatIllegalStateException()
.isThrownBy(context::refresh)
.withMessageStartingWith("""
.withMessage("""
Unable to select a bean to wrap: there are no beans of type java.lang.String \
(as required by field 'ByTypeSingleLookup.example').""");
(as required by field 'ByTypeSingleLookup.example'). \
If the bean is defined in a @Bean method, make sure the return type is the most \
specific type possible (for example, the concrete implementation type).""");
}
@Test