kie-issues#1807: Test Scenario version attribute is not correctly retrieved #6254
+59
−23
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.
Closes: apache/incubator-kie-issues#1807
The problem
The Test Scenario Engine needs to retrieve the scesim version from the xml root node to apply the correct migration strategy.
The current logic that retrieves that info, uses a regex search, that is too strict: regex patterns with this exact structure
<ScenarioSimulationModel version=\"x.x\"
will be found. That means if any other attribute is present in the XML node (or just a single whitespace), the search will faileg.
<ScenarioSimulationModel version=\"x.x\"
<ScenarioSimulationModel namespace="..." version=\"x.x\"
The solution
In the same block of code, the DomParser of the xml file is already called. So, I just moved that in the first method line and took advantage of that to retrieve the version in a "safer" way.
This means, the regex search is no longer required, and the version can be safely retrieved disregarding its position in the node and avoiding collision with other possible attributes with the name.