Skip to content

Conversation

@maple525866
Copy link
Contributor

@maple525866 maple525866 commented Jun 7, 2025

  • I have registered the PR changes.

Ⅰ. 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

@maple525866 maple525866 changed the title add UT for RemotingFactoryBeanParser class #7378 test: add UT for RemotingFactoryBeanParser class Jun 7, 2025
@YongGoose YongGoose requested a review from Copilot June 7, 2025 13:46
@YongGoose YongGoose added first-time contributor first-time contributor type: test test case labels Jun 7, 2025
Copy link
Contributor

Copilot AI left a 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 RemotingFactoryBeanParserTest with cases covering constructor validation, proxy handling, reference/service checks, service descriptor retrieval, and protocol retrieval.
  • Add seata-sqlparser-druid and mockito-inline dependencies 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 result is not null, consider asserting that the returned object exactly matches the expected factoryBean (e.g., using assertSame or assertEquals) to verify correct wiring.
Assertions.assertNotNull(result);

spring/src/test/java/org/apache/seata/spring/remoting/parser/RemotingFactoryBeanParserTest.java:209

  • To fully validate getProtocol(), mock defaultRemotingParser.getProtocol() to return a non-default value and assert that remotingFactoryBeanParser.getProtocol() returns that value.
Assertions.assertEquals(0, result);

spring/pom.xml:67

  • [nitpick] The seata-sqlparser-druid dependency 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>

@codecov
Copy link

codecov bot commented Jun 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 58.60%. Comparing base (cb9a279) to head (a2b7f2a).
Report is 2 commits behind head on 2.x.

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     

see 5 files with indirect coverage changes

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@YongGoose YongGoose left a 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

Comment on lines 87 to 89
TestService testService = new TestServiceImpl();
ProxyFactory proxyFactory = new ProxyFactory(testService);
TestService proxyTestService = (TestService) proxyFactory.getProxy();
Copy link
Member

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?

Copy link
Contributor Author

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);
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will try

@maple525866
Copy link
Contributor Author

Please let me know if there is anything else that needs to be changed

@funky-eyes funky-eyes added this to the 2.5.0 milestone Jun 9, 2025
Copy link
Contributor

@funky-eyes funky-eyes left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@YongGoose YongGoose left a comment

Choose a reason for hiding this comment

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

LGTM

- [[#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
Copy link
Member

Choose a reason for hiding this comment

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

Maybe #7420?

Copy link
Contributor Author

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

Copy link
Member

@slievrly slievrly left a comment

Choose a reason for hiding this comment

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

LGTM

@slievrly slievrly merged commit bd717a6 into apache:2.x Jun 10, 2025
9 checks passed
slievrly pushed a commit to slievrly/fescar that referenced this pull request Oct 21, 2025
YvCeung pushed a commit to YvCeung/incubator-seata that referenced this pull request Dec 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

first-time contributor first-time contributor type: test test case

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add UT for RemotingFactoryBeanParser class

4 participants