Closed gzhao9 closed 3 weeks ago
Hi @gzhao9 Thanks for bringing this up and starting a PR! Please submit a pull request over here whenever things are ready.
Hi @gzhao9 Thanks for bringing this up and starting a PR! Please submit a pull request over here whenever things are ready.
Hello, I have submitted the PR #1375
Hi there!
While working with the
RequestInformationTest
class. I've noticed that there are 2 mock variables repeatedly created across various tests. To simplify the code, I propose a small refactor to eliminate these redundancies, which could reduce the code by 20 lines.RequestAdapter
Creation: Repeated 5 times.SerializationWriterFactory
Creation: Repeated 5 times.For instance, the mock creation logic is as follows:
To eliminate redundancy, We can create two methods that can be called repeatedly,
createMockSerializationWriterFactory
andcreateMockRequestAdapter
:Using these methods, the refactored code becomes much cleaner:
And for further improvement, we can overload
createMockRequestAdapter
for a more streamlined approach:With this refactoring, mock creation and configuration can be done in a single line:
I’ve created a draft PR in my forked project where you can see the detailed changes here. The refactor reduced the test cases by 20 lines of code, and I believe these changes will improve code readability.