-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CU-86b1g1mye_SRU2024_Generar-un-enum-de-FieldNames-para-validar-que-e… #194
CU-86b1g1mye_SRU2024_Generar-un-enum-de-FieldNames-para-validar-que-e… #194
Conversation
Caution Review failedThe pull request is closed. 📝 Walkthrough📝 WalkthroughWalkthroughThe recent updates introduce the Changes
Possibly related PRs
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
CHANGELOG.md
Outdated
@@ -1,5 +1,8 @@ | |||
# Prowide Core - CHANGELOG | |||
|
|||
#### 9.5.2 - SNAPSHOT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adjust the heading level for version entry.
The heading level for version 9.5.2 should be consistent with the rest of the document. Change it to level 2.
Apply this diff to fix the heading level:
-#### 9.5.2 - SNAPSHOT
+## 9.5.2 - SNAPSHOT
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
#### 9.5.2 - SNAPSHOT | |
## 9.5.2 - SNAPSHOT |
Tools
Markdownlint
3-3: Expected: h2; Actual: h4
Heading levels should only increment by one level at a time(MD001, heading-increment)
3-3: Expected: 1; Actual: 0; Below
Headings should be surrounded by blank lines(MD022, blanks-around-headings)
CHANGELOG.md
Outdated
@@ -1,5 +1,8 @@ | |||
# Prowide Core - CHANGELOG | |||
|
|||
#### 9.5.2 - SNAPSHOT | |||
* Added new SRU2023FieldEnum with all the available field names |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure proper indentation and blank lines for list items.
The bullet point should be indented correctly and surrounded by blank lines for consistency.
Apply this diff to fix the indentation and add blank lines:
## 9.5.2 - SNAPSHOT
- * Added new SRU2023FieldEnum with all the available field names
+* Added new SRU2023FieldEnum with all the available field names
#### 9.5.1 - June 2024
Committable suggestion was skipped due to low confidence.
Tools
Markdownlint
4-4: Expected: 0; Actual: 2
Unordered list indentation(MD007, ul-indent)
4-4: null
Lists should be surrounded by blank lines(MD032, blanks-around-lists)
src/generated/java/com/prowidesoftware/swift/model/field/SRU2024FieldEnum.java
Outdated
Show resolved
Hide resolved
src/generated/java/com/prowidesoftware/swift/model/field/SRU2024FieldEnum.java
Outdated
Show resolved
Hide resolved
src/generated/java/com/prowidesoftware/swift/model/field/SRU2024FieldEnum.java
Outdated
Show resolved
Hide resolved
cff5c0b
to
902cfa5
Compare
3d38ada
to
b6c99c0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 7
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
⛔ Files ignored due to path filters (1)
src/generated/java/com/prowidesoftware/swift/model/field/FieldEnum.java
is excluded by!**/generated/**
📒 Files selected for processing (2)
- CHANGELOG.md (1 hunks)
- src/test/java/com/prowidesoftware/swift/model/field/FieldEnumTest.java (1 hunks)
🧰 Additional context used
🪛 Markdownlint
CHANGELOG.md
3-3: Expected: h2; Actual: h4
Heading levels should only increment by one level at a time(MD001, heading-increment)
4-4: Expected: 0; Actual: 2
Unordered list indentation(MD007, ul-indent)
3-3: Expected: 1; Actual: 0; Below
Headings should be surrounded by blank lines(MD022, blanks-around-headings)
4-4: null
Lists should be surrounded by blank lines(MD032, blanks-around-lists)
🔇 Additional comments (1)
CHANGELOG.md (1)
4-4
: LGTM! Clear and concise changelog entry.The content of the changelog entry accurately describes the addition of the new
FieldEnum
feature. It provides sufficient information for users to understand the main change in this version.🧰 Tools
🪛 Markdownlint
4-4: Expected: 0; Actual: 2
Unordered list indentation(MD007, ul-indent)
4-4: null
Lists should be surrounded by blank lines(MD032, blanks-around-lists)
@Test | ||
void testfieldName() { | ||
// Validate that fieldName returns the correct value | ||
assertEquals("11A", FieldEnum.F11A.fieldName()); | ||
assertEquals("14P", FieldEnum.F14P.fieldName()); | ||
assertEquals("30K", FieldEnum.F30K.fieldName()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
Approve with suggestions for improvement
The testfieldName
method provides basic coverage for the fieldName()
method of FieldEnum
. However, consider the following improvements:
- Rename the method to follow Java naming conventions:
testFieldName()
. - Consider adding more test cases to cover a wider range of enum values.
- You might want to add a test case for an enum value that doesn't follow the standard pattern (if any exist) to ensure robustness.
@Test | ||
void testfromFieldNameValid() { | ||
// Validate that fromFieldName returns the correct enum when a valid code is provided | ||
assertEquals(FieldEnum.F11A, FieldEnum.fromFieldName("11A")); | ||
assertEquals(FieldEnum.F14R, FieldEnum.fromFieldName("14R")); | ||
assertEquals(FieldEnum.F30K, FieldEnum.fromFieldName("30K")); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
Approve with suggestions for improvement
The testfromFieldNameValid
method provides basic coverage for the fromFieldName()
method of FieldEnum
with valid inputs. Consider the following improvements:
- Rename the method to follow Java naming conventions:
testFromFieldNameValid()
. - Consider adding more test cases to cover a wider range of valid field names.
- You might want to add a test case for a field name at the boundary of validity (e.g., the highest valid field number) to ensure comprehensive coverage.
@Test | ||
void testfromFieldNameInvalid() { | ||
// Validate that fromFieldName returns null when an invalid code is provided | ||
assertNull(FieldEnum.fromFieldName("930K")); | ||
assertNull(FieldEnum.fromFieldName("ABC")); | ||
assertNull(FieldEnum.fromFieldName("")); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
Approve with suggestions for enhancement
The testfromFieldNameInvalid
method provides good coverage for invalid inputs to the fromFieldName()
method. Consider the following enhancements:
- Rename the method to follow Java naming conventions:
testFromFieldNameInvalid()
. - Add more test cases for invalid inputs, such as:
- A null input
- A very long string
- A string with special characters
- Consider using a parameterized test to make it easier to add more invalid input scenarios.
@Test | ||
void testfromFieldNameEdgeCases() { | ||
// Validate edge cases, such as lowercase inputs, to ensure the method is case-sensitive | ||
assertNull(FieldEnum.fromFieldName("11a")); // should return null because "11a" is lowercase | ||
assertNull(FieldEnum.fromFieldName(" 11A")); // should return null because of the leading space | ||
assertNull(FieldEnum.fromFieldName("11A ")); // should return null because of the trailing space | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
Approve with minor suggestions
The testfromFieldNameEdgeCases
method provides excellent coverage for edge cases of the fromFieldName()
method. The test cases and comments are clear and informative. Consider the following minor improvements:
- Rename the method to follow Java naming conventions:
testFromFieldNameEdgeCases()
. - Consider adding a test case for a mixed-case input (e.g., "11a") to explicitly verify case sensitivity.
@Test | ||
void testAllEnumValues() { | ||
// Validate that all enum values have the correct field name | ||
for (FieldEnum field : FieldEnum.values()) { | ||
assertEquals(field.name().substring(1), field.fieldName()); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
Approve with suggestions for robustness
The testAllEnumValues
method provides excellent comprehensive coverage for all enum values. This ensures that the relationship between enum names and field names is consistent across the entire FieldEnum
. Consider the following suggestions to enhance robustness:
- Add a check to ensure that
FieldEnum.values()
is not empty before the loop, to avoid a potential silent pass if the enum were empty. - Consider adding an explicit assertion for the number of enum values, if it's expected to be stable.
- If there's a possibility of exceptions (e.g., if
fieldName()
could throw), consider adding appropriate exception handling or usingassertDoesNotThrow
.
package com.prowidesoftware.swift.model.field; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
class FieldEnumTest { | ||
|
||
@Test | ||
void testfieldName() { | ||
// Validate that fieldName returns the correct value | ||
assertEquals("11A", FieldEnum.F11A.fieldName()); | ||
assertEquals("14P", FieldEnum.F14P.fieldName()); | ||
assertEquals("30K", FieldEnum.F30K.fieldName()); | ||
} | ||
|
||
@Test | ||
void testfromFieldNameValid() { | ||
// Validate that fromFieldName returns the correct enum when a valid code is provided | ||
assertEquals(FieldEnum.F11A, FieldEnum.fromFieldName("11A")); | ||
assertEquals(FieldEnum.F14R, FieldEnum.fromFieldName("14R")); | ||
assertEquals(FieldEnum.F30K, FieldEnum.fromFieldName("30K")); | ||
} | ||
|
||
@Test | ||
void testfromFieldNameInvalid() { | ||
// Validate that fromFieldName returns null when an invalid code is provided | ||
assertNull(FieldEnum.fromFieldName("930K")); | ||
assertNull(FieldEnum.fromFieldName("ABC")); | ||
assertNull(FieldEnum.fromFieldName("")); | ||
} | ||
|
||
@Test | ||
void testfromFieldNameEdgeCases() { | ||
// Validate edge cases, such as lowercase inputs, to ensure the method is case-sensitive | ||
assertNull(FieldEnum.fromFieldName("11a")); // should return null because "11a" is lowercase | ||
assertNull(FieldEnum.fromFieldName(" 11A")); // should return null because of the leading space | ||
assertNull(FieldEnum.fromFieldName("11A ")); // should return null because of the trailing space | ||
} | ||
|
||
@Test | ||
void testAllEnumValues() { | ||
// Validate that all enum values have the correct field name | ||
for (FieldEnum field : FieldEnum.values()) { | ||
assertEquals(field.name().substring(1), field.fieldName()); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
Overall, well-structured and comprehensive test suite
This test class provides a robust set of unit tests for the FieldEnum
class, covering the main functionalities, edge cases, and comprehensive enum value checking. The code is well-organized and easy to follow.
Some general suggestions for improvement:
- Consistently use camelCase for method names to follow Java naming conventions.
- Consider using parameterized tests for some methods to make it easier to add more test cases.
- Add comments explaining the purpose of each test method (similar to what's done in
testfromFieldNameEdgeCases
). - If not already present elsewhere, consider adding integration tests that use these enums in the context of the larger system.
Great job on creating a thorough test suite!
CHANGELOG.md
Outdated
#### 9.5.2 - SNAPSHOT | ||
* Added new FieldEnum with all the available field names |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
Adjust formatting for consistency and readability.
Please make the following changes to improve the formatting of the changelog entry:
- Change the heading level from h4 to h2 for consistency with other version entries.
- Add a blank line before the heading.
- Remove the indentation for the bullet point.
Apply this diff to fix the formatting:
+
-#### 9.5.2 - SNAPSHOT
- * Added new FieldEnum with all the available field names
+## 9.5.2 - SNAPSHOT
+* Added new FieldEnum with all the available field names
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
#### 9.5.2 - SNAPSHOT | |
* Added new FieldEnum with all the available field names | |
## 9.5.2 - SNAPSHOT | |
* Added new FieldEnum with all the available field names |
🧰 Tools
🪛 Markdownlint
3-3: Expected: h2; Actual: h4
Heading levels should only increment by one level at a time(MD001, heading-increment)
4-4: Expected: 0; Actual: 2
Unordered list indentation(MD007, ul-indent)
3-3: Expected: 1; Actual: 0; Below
Headings should be surrounded by blank lines(MD022, blanks-around-headings)
4-4: null
Lists should be surrounded by blank lines(MD032, blanks-around-lists)
…ieldNames-para-validar-que-el-Field-exista
* SRU2024: Updated MT messages and fields with SRU2024 definition * yearly deprecation iteration * fix 33Z components and javadoc typo * added isPercentage helper method in field 37K + javadoc typo * Restore deprecated method in MT210 class * CU-86b1g1mye_SRU2024_Generar-un-enum-de-FieldNames-para-validar-que-e… (#194) * CU-86b1g1mye_SRU2024_Generar-un-enum-de-FieldNames-para-validar-que-el-Field-exista * CU-86b1g1mye_SRU2024_Generar-un-enum-de-FieldNames-para-validar-que-el-Field-exista * CU-86b14j4e0_SRU2024_check-code-security-reports-at-GitHub-for-all-repos * Fixed `getMUR` and `setMUR` in `SwiftMessage` to prioritize field 108 in block 4 over block 3 for system messages (category 0) (#211) * CU-86b1uerqp_Generar-un-enum-de-MTs-para-validar-sus-secuencias-y-paths_SRU2024 (#209) --------- Co-authored-by: zubri <[email protected]> Co-authored-by: ecancrini <[email protected]> Co-authored-by: ptorres-prowide <[email protected]>
…l-Field-exista
Summary by CodeRabbit
New Features
FieldEnum
, providing a centralized reference for field names in the SWIFT messaging standard.SRU2024FieldEnum
, encompassing a comprehensive list of field identifiers relevant to the 2024 SWIFT messaging standard.fieldName()
for retrieving human-readable field names andfromFieldName(String fieldName)
for converting string representations to enum types.Tests
FieldEnum
to validate functionality and ensure robust handling of valid, invalid, and edge case inputs.