Issue 2245, Zosprogram manager name sanitisation #470
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.
Why
This PR addresses galasa-dev/projectmanagement#2245.
The issue required enforcing two rules for @ZosProgram annotations:
The name property should always be uppercased.
The name must not exceed 8 characters; otherwise, an exception should be thrown.
What Changed
Added logic in ZosProgramManagerImpl.generateZosProgram() to:
Convert the name attribute to uppercase using toUpperCase().
Validate the length of the name and throw a ZosProgramManagerException if it exceeds 8 characters.
Testing
Created a static inner class Dummy with real @ZosProgram annotations to mimic production code and validate:
Names are correctly uppercased.
Names with valid lengths (≤ 8 chars) are accepted.
Names exactly 8 characters long are accepted.
Added a test for invalid names (> 8 chars) using Mockito to mock the annotation and verify that an exception is thrown.
Used Mockito instead of PowerMockito for simplicity and faster execution.
Implemented an @ After teardown method to reset the singleton instance of ZosProgramPropertiesSingleton between tests, preventing state leakage that caused earlier failures.