-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Use assertThatException
#10485
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
Use assertThatException
#10485
Conversation
Signed-off-by: Tran Ngoc Nhan <ngocnhan.tran1996@gmail.com>
Signed-off-by: Tran Ngoc Nhan <ngocnhan.tran1996@gmail.com>
"</beans>"; | ||
// Load context from a String to avoid IDEs reporting the invalid configuration | ||
String badContext = | ||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + |
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.
Well, since we are already here, please, consider to use Java text block instead of concatenations.
} | ||
Resource resource = new ByteArrayResource(badContext.getBytes()); | ||
assertThatExceptionOfType(BeanDefinitionParsingException.class) | ||
.isThrownBy(() -> new GenericXmlApplicationContext(resource).close()) |
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.
We don't need close()
since we are going to fail.
} | ||
Resource resource = new ByteArrayResource(badContext.getBytes()); | ||
assertThatExceptionOfType(BeanDefinitionParsingException.class) | ||
.isThrownBy(() -> new GenericXmlApplicationContext(resource).close()) |
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.
DITTO
} | ||
Resource resource = new ByteArrayResource(badContext.getBytes()); | ||
assertThatExceptionOfType(BeanDefinitionParsingException.class) | ||
.isThrownBy(() -> new GenericXmlApplicationContext(resource).close()) |
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.
DITTO
public void testProcedureNameAndExpressionExclusivity() { | ||
|
||
assertThatExceptionOfType(BeanDefinitionParsingException.class) | ||
.isThrownBy(() -> this.bootStrap("nameAndExpressionExclusivity")) |
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.
Now we prefer to not use this.
prefix for method calls.
assertThatIllegalStateException() | ||
.isThrownBy(() -> { | ||
gateway.afterPropertiesSet(); | ||
gateway.handleRequestMessage(message); |
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.
We fail here just after gateway.afterPropertiesSet();
, therefore second call is not reachable, redundant and misleading.
Plus, this second call is not asserted anyhow.
Well, it just has to go.
Signed-off-by: Tran Ngoc Nhan <ngocnhan.tran1996@gmail.com>
Signed-off-by: Tran Ngoc Nhan <ngocnhan.tran1996@gmail.com>
No description provided.