2671 - Ensure default media type order is preserved using LinkedHashSet in mergeArrays
Description
This PR addresses issue #2671 by ensuring that the order of media types is preserved in the mergeArrays method of the MethodAttributes class. Previously, HashSet was used, which did not guarantee the order of media types, causing the default media type not to be prioritized. This has been fixed by using LinkedHashSet to maintain the insertion order.
Changes
MethodAttributes.java:
Modified mergeArrays method to use LinkedHashSet instead of HashSet to preserve the order of media types.
MethodAttributesTest.java:
Added unit tests to verify that the mergeArrays method preserves the order of media types and that the default media type is prioritized.
Tests include scenarios with both non-null and null arrays.
Testing
Added the following tests to MethodAttributesTest to ensure the functionality:
testMergeArrays: Verifies that the order of media types is preserved when merging two arrays.
testMergeArraysWithNullArray1: Verifies that the method handles null as the first array correctly.
testDefaultProducesMediaType: Verifies that the default produces media type is correctly set.
testDefaultConsumesMediaType: Verifies that the default consumes media type is correctly set.
Please review the changes and let me know if any further adjustments are needed.
2671 - Ensure default media type order is preserved using LinkedHashSet in mergeArrays
Description
This PR addresses issue #2671 by ensuring that the order of media types is preserved in the
mergeArrays
method of theMethodAttributes
class. Previously,HashSet
was used, which did not guarantee the order of media types, causing the default media type not to be prioritized. This has been fixed by usingLinkedHashSet
to maintain the insertion order.Changes
MethodAttributes.java:
mergeArrays
method to useLinkedHashSet
instead ofHashSet
to preserve the order of media types.MethodAttributesTest.java:
mergeArrays
method preserves the order of media types and that the default media type is prioritized.Testing
Added the following tests to
MethodAttributesTest
to ensure the functionality:testMergeArrays
: Verifies that the order of media types is preserved when merging two arrays.testMergeArraysWithNullArray1
: Verifies that the method handlesnull
as the first array correctly.testDefaultProducesMediaType
: Verifies that the defaultproduces
media type is correctly set.testDefaultConsumesMediaType
: Verifies that the defaultconsumes
media type is correctly set.Please review the changes and let me know if any further adjustments are needed.
Thank you!