Polish "Assert that sources does not contain null elements"
See gh-30878
This commit is contained in:
parent
ebf276c005
commit
56c3a5f0ab
|
@ -182,7 +182,9 @@ public class Binder {
|
|||
List<ConversionService> conversionServices, Consumer<PropertyEditorRegistry> propertyEditorInitializer,
|
||||
BindHandler defaultBindHandler, BindConstructorProvider constructorProvider) {
|
||||
Assert.notNull(sources, "Sources must not be null");
|
||||
sources.forEach((source) -> Assert.notNull(source, "Sources cannot contain null values"));
|
||||
for (ConfigurationPropertySource source : sources) {
|
||||
Assert.notNull(source, "Sources must not contain null elements");
|
||||
}
|
||||
this.sources = sources;
|
||||
this.placeholdersResolver = (placeholdersResolver != null) ? placeholdersResolver : PlaceholdersResolver.NONE;
|
||||
this.bindConverter = BindConverter.get(conversionServices, propertyEditorInitializer);
|
||||
|
|
|
@ -70,19 +70,27 @@ class BinderTests {
|
|||
private Binder binder = new Binder(this.sources);
|
||||
|
||||
@Test
|
||||
void createWhenSourcesIsNullShouldThrowException() {
|
||||
void createWhenSourcesIsNullArrayShouldThrowException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new Binder((ConfigurationPropertySource[]) null))
|
||||
.withMessageContaining("Sources must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void creatWhenSourcesIsNullIterableShouldThrowException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new Binder((Iterable<ConfigurationPropertySource>) null))
|
||||
.withMessageContaining("Sources must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void createWhenSourcesContainNullValuesShouldThrowException() {
|
||||
void createWhenArraySourcesContainsNullElementShouldThrowException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new Binder(new ConfigurationPropertySource[] { null }))
|
||||
.withMessageContaining("Sources cannot contain null values");
|
||||
.withMessageContaining("Sources must not contain null elements");
|
||||
}
|
||||
|
||||
@Test
|
||||
void createWhenIterableSourcesContainsNullElementShouldThrowException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new Binder(Collections.singletonList(null)))
|
||||
.withMessageContaining("Sources cannot contain null values");
|
||||
.withMessageContaining("Sources must not contain null elements");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue