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

Refactor the test in the package org. Apache. Dubbo. Reactive. #13175

Merged
merged 5 commits into from
Oct 10, 2023

Conversation

gzhao9
Copy link
Contributor

@gzhao9 gzhao9 commented Oct 9, 2023

Purpose of the Change

This PR is aimed at resolving the issue of duplicated creation of mock. This occurs in five test cases in ManyToManyMethodHandlerTest.java, ManyToOneMethodHandlerTest.java and OneToManyMethodHandlerTest.java, as highlighted in issue #13154.

Brief changelog

We created a reusable class creatObserverAdapter to create the mock, avoiding duplicate creation of the mock in 5 test cases.
Since in ManyToOneMethodHandlerTest.java and OneToManyMethodHandlerTest.java, the mock is both created duplicated in two test cases, we set this mock object as a class attribute and create it in @BeforeEach.
After refactoring, we removed duplicate lines of code for the following five test cases and improved readability and maintainability:

Verifying this change

Checklist

  • Make sure there is a GitHub_issue field for the change (usually before you start working on it). Trivial changes like typos do not require a GitHub issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
  • Each commit in the pull request should have a meaningful subject line and body.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Check if is necessary to patch to Dubbo 3 if you are work on Dubbo 2.7
  • Write necessary unit-test to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add sample in dubbo samples project.
  • Add some description to dubbo-website project if you are requesting to add a feature.
  • GitHub Actions works fine on your own branch.
  • If this contribution is large, please follow the Software Donation Guide.

@codecov-commenter
Copy link

codecov-commenter commented Oct 10, 2023

Codecov Report

Merging #13175 (a1e5964) into 3.2 (3ca3504) will increase coverage by 0.00%.
The diff coverage is n/a.

@@            Coverage Diff            @@
##                3.2   #13175   +/-   ##
=========================================
  Coverage     69.38%   69.39%           
  Complexity        2        2           
=========================================
  Files          1648     1648           
  Lines         68693    68693           
  Branches      10014    10014           
=========================================
+ Hits          47661    47667    +6     
- Misses        16438    16441    +3     
+ Partials       4594     4585    -9     

see 26 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.doAnswer;

public class CreatObserverAdapter {
Copy link
Member

Choose a reason for hiding this comment

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

Is Creat correct? Maybe Create?

@sonarcloud
Copy link

sonarcloud bot commented Oct 10, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@AlbumenJ AlbumenJ merged commit 5d979c1 into apache:3.2 Oct 10, 2023
12 of 14 checks passed
@gzhao9 gzhao9 deleted the Refactor-org.apache.dubbo.reactive branch October 10, 2023 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants