Skip to content
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

Simplify assertions #3996

Merged
merged 3 commits into from
Jan 3, 2024
Merged

Simplify assertions #3996

merged 3 commits into from
Jan 3, 2024

Conversation

wborn
Copy link
Member

@wborn wborn commented Jan 2, 2024

Using the appropriate assertion methods results in less and easier to read code as well as better error messages when assertions fail.

Using the appropriate assertion methods results in less and easier to read code as well as better error messages when assertions fail.

Signed-off-by: Wouter Born <github@maindrain.net>
@wborn wborn requested a review from a team as a code owner January 2, 2024 16:42
Copy link
Member

@J-N-K J-N-K left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise LGTM

@@ -76,6 +76,6 @@ public void testTokenNotExpiredEvenWithBuffer() {
// token has a life time of 60 seconds
token.setExpiresIn(60);

assertTrue(!token.isExpired(Instant.now(), 10), "Token should have been expired due to buffer");
assertFalse(token.isExpired(Instant.now(), 10), "Token should have been expired due to buffer");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the test and the message a contradiction? We test isExpired == false and the failure message says the token should have expired?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed the text. I think it was copied from testTokenExpiredDueToBuffer to testTokenNotExpiredEvenWithBuffer

Signed-off-by: Wouter Born <github@maindrain.net>
Signed-off-by: Wouter Born <github@maindrain.net>
@J-N-K J-N-K added the enhancement An enhancement or new feature of the Core label Jan 3, 2024
@J-N-K J-N-K added this to the 4.2 milestone Jan 3, 2024
@J-N-K J-N-K merged commit 10c0cf8 into openhab:main Jan 3, 2024
3 checks passed
@wborn wborn deleted the simplify-assertions branch January 3, 2024 11:35
cipianpascu pushed a commit to cipianpascu/openhab-core that referenced this pull request Jan 17, 2024
* Simplify assertions

Using the appropriate assertion methods results in less and easier to read code as well as better error messages when assertions fail.

Signed-off-by: Wouter Born <github@maindrain.net>
Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature of the Core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants