-
Notifications
You must be signed in to change notification settings - Fork 8.9k
test: add UT for RemotingFactoryBeanParser class #7420
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
Conversation
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.
Pull Request Overview
Adds comprehensive unit tests for the RemotingFactoryBeanParser class and updates module dependencies.
- Introduce
RemotingFactoryBeanParserTestwith cases covering constructor validation, proxy handling, reference/service checks, service descriptor retrieval, and protocol retrieval. - Add
seata-sqlparser-druidandmockito-inlinedependencies in the Spring module’s POM for parser integration and static mocking support.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| spring/src/test/java/org/apache/seata/spring/remoting/parser/RemotingFactoryBeanParserTest.java | Add unit tests for all public behaviors of RemotingFactoryBeanParser. |
| spring/pom.xml | Add seata-sqlparser-druid and mockito-inline dependencies. |
Comments suppressed due to low confidence (3)
spring/src/test/java/org/apache/seata/spring/remoting/parser/RemotingFactoryBeanParserTest.java:112
- Instead of only asserting
resultis not null, consider asserting that the returned object exactly matches the expectedfactoryBean(e.g., usingassertSameorassertEquals) to verify correct wiring.
Assertions.assertNotNull(result);
spring/src/test/java/org/apache/seata/spring/remoting/parser/RemotingFactoryBeanParserTest.java:209
- To fully validate
getProtocol(), mockdefaultRemotingParser.getProtocol()to return a non-default value and assert thatremotingFactoryBeanParser.getProtocol()returns that value.
Assertions.assertEquals(0, result);
spring/pom.xml:67
- [nitpick] The
seata-sqlparser-druiddependency doesn’t appear to be used by these tests; consider removing it or documenting its purpose to prevent unused bloat in the module.
<artifactId>seata-sqlparser-druid</artifactId>
spring/src/test/java/org/apache/seata/spring/remoting/parser/RemotingFactoryBeanParserTest.java
Show resolved
Hide resolved
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## 2.x #7420 +/- ##
============================================
+ Coverage 58.55% 58.60% +0.04%
Complexity 571 571
============================================
Files 1269 1269
Lines 45730 45730
Branches 5548 5548
============================================
+ Hits 26778 26799 +21
+ Misses 16374 16350 -24
- Partials 2578 2581 +3 🚀 New features to boost your workflow:
|
YongGoose
left a comment
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.
Looks good.
left some comments
| TestService testService = new TestServiceImpl(); | ||
| ProxyFactory proxyFactory = new ProxyFactory(testService); | ||
| TestService proxyTestService = (TestService) proxyFactory.getProxy(); |
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.
What do you think about extracting this into a separate method?
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.
I can try it
|
|
||
| // Test | ||
| Object result = remotingFactoryBeanParser.getRemotingFactoryBean(proxyTestService, "testService"); | ||
| Assertions.assertNotNull(result); |
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.
Is there another way to do this without using notNull?
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.
I will try
|
Please let me know if there is anything else that needs to be changed |
funky-eyes
left a comment
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.
LGTM
YongGoose
left a comment
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.
LGTM
changes/en-us/2.x.md
Outdated
| - [[#7205](https://github.com/apache/incubator-seata/issues/7205)] add UT for namingserver module | ||
| - [[#7359](https://github.com/apache/incubator-seata/issues/7359)] merge submodule test reports | ||
| - [[#7377](https://github.com/apache/incubator-seata/issues/7377)] add UT for org.apache.seata.spring.annotation.scannercheckers | ||
| - [[#7378](https://github.com/apache/incubator-seata/issues/7378)] add UT for RemotingFactoryBeanParser class |
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.
Maybe #7420?
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.
Sorry, I have corrected my previous commit to 2.x md
slievrly
left a comment
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.
LGTM
Ⅰ. Describe what this PR did
Ⅱ. Does this pull request fix one issue?
fixes #7378
Ⅲ. Why don't you add test cases (unit test/integration test)?
Ⅳ. Describe how to verify it
Ⅴ. Special notes for reviews