-
Notifications
You must be signed in to change notification settings - Fork 41.4k
Polish tests #42725
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Polish tests #42725
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -197,6 +197,7 @@ void getWhenHasFactoryMethodAndBeanAnnotationFavorsFactoryMethod() throws Throwa | |
void getWhenHasValidatedBeanBindsWithBeanAnnotation() throws Throwable { | ||
get(ValidatedBeanConfiguration.class, "validatedBean", (propertiesBean) -> { | ||
Validated validated = propertiesBean.asBindTarget().getAnnotation(Validated.class); | ||
assertThat(validated).isNotNull(); | ||
assertThat(validated.value()).containsExactly(BeanGroup.class); | ||
}); | ||
} | ||
|
@@ -205,6 +206,7 @@ void getWhenHasValidatedBeanBindsWithBeanAnnotation() throws Throwable { | |
void getWhenHasValidatedFactoryMethodBindsWithFactoryMethodAnnotation() throws Throwable { | ||
get(ValidatedMethodConfiguration.class, "annotatedBean", (propertiesBean) -> { | ||
Validated validated = propertiesBean.asBindTarget().getAnnotation(Validated.class); | ||
assertThat(validated).isNotNull(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As above. Please revert. |
||
assertThat(validated.value()).containsExactly(FactoryMethodGroup.class); | ||
}); | ||
} | ||
|
@@ -213,6 +215,7 @@ void getWhenHasValidatedFactoryMethodBindsWithFactoryMethodAnnotation() throws T | |
void getWhenHasValidatedBeanAndFactoryMethodBindsWithFactoryMethodAnnotation() throws Throwable { | ||
get(ValidatedMethodAndBeanConfiguration.class, "validatedBean", (propertiesBean) -> { | ||
Validated validated = propertiesBean.asBindTarget().getAnnotation(Validated.class); | ||
assertThat(validated).isNotNull(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As above. Please revert. |
||
assertThat(validated.value()).containsExactly(FactoryMethodGroup.class); | ||
}); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,7 @@ void createFromBeanHasDetails() { | |
ApplicationContext applicationContext = new AnnotationConfigApplicationContext(Example.class); | ||
ConfigurationPropertiesBean bean = ConfigurationPropertiesBean.get(applicationContext, | ||
applicationContext.getBean(Example.class), "example"); | ||
assertThat(bean).isNotNull(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As above. Please revert. Additionally, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I misread the diff. Regardless, the same reasoning as above still applies. I don't think null checks such as this in tests are beneficial. |
||
ConfigurationPropertiesBindException exception = new ConfigurationPropertiesBindException(bean, | ||
new IllegalStateException()); | ||
assertThat(exception.getMessage()).isEqualTo("Error creating bean with name 'example': " | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1197,6 +1197,7 @@ void loadWhenBoundToRandomPropertyPlaceholder() { | |
void boundPropertiesShouldBeRecorded() { | ||
load(NestedConfiguration.class, "name=foo", "nested.name=bar"); | ||
BoundConfigurationProperties bound = BoundConfigurationProperties.get(this.context); | ||
assertThat(bound).isNotNull(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As above. Please revert. |
||
Set<ConfigurationPropertyName> keys = bound.getAll().keySet(); | ||
assertThat(keys.stream().map(ConfigurationPropertyName::toString)).contains("name", "nested.name"); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is an improvement. It makes the test more verbose and I think the benefit is negligible. Should
validated
benull
, the NPE that would occur on the next line when callingvalidated.value()
will make that clear.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It makes IDEA and code analysis tools happy, is it worthy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I don't think so.