Fix: Duplicate File Parts Generated in MockMvc using MockPart #954
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR for Issue #953
Solution:
File
andPart
contain the same content. If they do, remove one of them (assuming they are paired, so once removed, it will not be compared again).part
to theparts
list.MockPart
implementation itself callssetContentDispositionFormData
, which is only added toPart
. Therefore, when comparing,setContentDispositionFormData
is also included in the comparison.Reference Code (MockPart):
Additional Information:
I initially wrote a test code to compare the
MediaType
content type, but due to compatibility checks, I could not use theMockPart
constructor that allows definingcontentType
(introduced in@since 6.1.2
). As a result, I removed it from the test.