Skip to content

Comments

HDDS-9975. Add static import for assertions and mocks in hdds-server-framework#5849

Merged
adoroszlai merged 4 commits intoapache:masterfrom
wzhallright:HDDS-9975
Dec 22, 2023
Merged

HDDS-9975. Add static import for assertions and mocks in hdds-server-framework#5849
adoroszlai merged 4 commits intoapache:masterfrom
wzhallright:HDDS-9975

Conversation

@wzhallright
Copy link
Contributor

@wzhallright wzhallright commented Dec 21, 2023

What changes were proposed in this pull request?

The goal of this task is to add import static for all assertions and interactions with mocks. Replacing:

Assertions.assert<X>(...) -> assert<X>(...)
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).

What is the link to the Apache JIRA

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

CI

https://github.com/wzhallright/ozone/actions/runs/7286857379

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 @wzhallright for the patch.

Can you please also include:
hadoop-hdds/framework/src/test/java/org/apache/hadoop/hdds/utils/db/TestTypedRDBTableStore.java?

Otherwise LGTM.

@wzhallright
Copy link
Contributor Author

Can you please also include: hadoop-hdds/framework/src/test/java/org/apache/hadoop/hdds/utils/db/TestTypedRDBTableStore.java?

Thanks for you detailed review @adoroszlai .I missed it, it was my fault, and include it now. Thanks again.

@adoroszlai
Copy link
Contributor

Just two more items here:

RDBTable rdbTable = Mockito.mock(RDBTable.class);
Mockito.when(rdbTable.iterator((CodecBuffer) null))

@wzhallright
Copy link
Contributor Author

Just two more items here:

RDBTable rdbTable = Mockito.mock(RDBTable.class);
Mockito.when(rdbTable.iterator((CodecBuffer) null))

@adoroszlai fixed comments,thanks for review.

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 @wzhallright for the patch. Let's not import Arguments.of, otherwise LGTM.

@adoroszlai adoroszlai merged commit f9167a3 into apache:master Dec 22, 2023
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