Skip to content

HDDS-9993. Add static import for assertions and mocks in hdds-server-scm#5918

Merged
adoroszlai merged 8 commits intoapache:masterfrom
raju-balpande:raju-b-hdds-9993-4
Jan 5, 2024
Merged

HDDS-9993. Add static import for assertions and mocks in hdds-server-scm#5918
adoroszlai merged 8 commits intoapache:masterfrom
raju-balpande:raju-b-hdds-9993-4

Conversation

@raju-balpande
Copy link
Contributor

What changes were proposed in this pull request?

Add static import for assertions and mocks in hadoop-hdds/server-scm.
he goal of this task is to add import static for all assertions and interactions with mocks. Replacing:

Assertions.assert(...) -> assert(...)
Assertions.fail(...) -> fail(...)

and

Mockito.mock(...) -> mock(...)
Mockito.verify(...) -> verify(...)
Mockito.when(...) -> when(...)
...

and

ArgumentMatchers.any() -> any()
ArgumentMatchers.eq() -> eq()
ArgumentMatchers.matches() -> matches()
// also:
// Matchers.<...>()

  • makes the code more readable (shorter lines, less wrapping).
  • Corrected argument sequence at some places in assertEquals to expected, actual.
  • Modified try{ fail() ) catch to assertThrows for the suitable cases.

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-9993

How was this patch tested?

Tested the test cases in CI-CD pipeline.

@raju-balpande raju-balpande marked this pull request as ready for review January 4, 2024 12:31
Copy link
Contributor

@adoroszlai adoroszlai left a comment

Choose a reason for hiding this comment

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

Thanks a lot @raju-balpande for working on this. Mostly looks good, few minor items noted.

Comment on lines -68 to -70
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.fail;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please don't move these existing imports.

@adoroszlai adoroszlai added the test label Jan 5, 2024
@adoroszlai adoroszlai merged commit d602eec into apache:master Jan 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants