fix: extensions in patient doesn't ensure orders #6544
+6
−6
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.
Issues
The methods testValidateWithExtensionsJson and testValidateWithExtensionsXml in ResourceValidatorDstu2_1Test and ResourceValidatorDstu3Test may encounter potential issues due to the usage of assertThat(messageString).containsSubsequence(). This assertion could fail in certain environments.
Reason
The fields "Organization/2.25.79433498044103547197447759549862032393", "furry-grey", and "furry-white" are extension fields in PatientProfileDstu2_1. These fields do not have an explicit order annotation in PatientProfileDstu2_1. (like order=9)
In this context, BaseRuntimeElementCompositeDefinition relies on the default field order provided by getDeclaredFields. However, the order of fields returned by getDeclaredFields is not guaranteed and can vary between different JVM implementations.
Due to this, the test assertion using containsSubsequence is unable to reliably ensure the order of the fields, leading to potential inconsistencies.
Change
instead of introducing explicit order annotations for these fields, I have updated the test to use contains instead of containsSubsequence. Please let me know if further adjustments are needed. Thank you!