Skip to content
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-86b1uerqp: Add enum with all possible MT sequence paths SRU2024 #209

Conversation

ptorres-prowide
Copy link
Contributor

@ptorres-prowide ptorres-prowide commented Nov 8, 2024

Summary by CodeRabbit

  • New Features

    • Updated BBAN validation data to align with the upcoming IBAN REGISTRY release.
    • Introduced a new method to verify system message categorization.
    • Added a new enumeration for available inner sequences of specific MT schemas.
  • Bug Fixes

    • Fixed prioritization of message fields in system messages.
  • Documentation

    • Updated CHANGELOG.md for version 9.5.3 with key changes and enhancements.
  • Tests

    • Streamlined test structure by replacing parameterized tests with explicit test cases for specific enum values.

@ptorres-prowide ptorres-prowide changed the base branch from main to SRU2024 November 8, 2024 21:25
@ptorres-prowide ptorres-prowide requested a review from zubri November 8, 2024 21:25
Copy link
Contributor

coderabbitai bot commented Nov 8, 2024

📝 Walkthrough

Walkthrough

The pull request introduces updates to the CHANGELOG.md for version 9.5.3 - SNAPSHOT, detailing changes in the SwiftMessage class, including the addition of a new method isSystemMessage() and updates to the getMUR and setMUR methods. A new enumeration, MtSequenceEnum, is also introduced. Additionally, the FieldEnumTest class is modified to replace parameterized tests with individual test methods for specific enum values, and the class name is corrected.

Changes

File Path Change Summary
CHANGELOG.md Updated for version 9.5.3 - SNAPSHOT; added isSystemMessage(), updated getMUR and setMUR, added MtSequenceEnum and FieldEnum.
src/test/java/com/prowidesoftware/swift/model/field/FieldEnumTest.java Class renamed from FieldEnu5mTest to FieldEnumTest; replaced parameterized tests with individual tests for F29Q, F30K, and added new tests for F11A.

Possibly related PRs

Suggested reviewers

  • zubri

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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments.

Actionable comments posted: 4

🛑 Comments failed to post (4)
build.gradle (2)

37-37: 🧹 Nitpick (assertive)

Remove commented version override.

The commented version override //project.version = "${SRU}-9.5.0" should be removed to maintain clean code. If this is intended for future use, consider tracking it in a separate issue or documentation.


65-69: 🧹 Nitpick (assertive)

Align xmlunit dependency versions.

While the test dependency updates look good, there's an inconsistency in xmlunit versions:

  • xmlunit-core: 2.10.0
  • xmlunit-matchers and xmlunit-assertj: 2.9.0

Consider aligning all xmlunit dependencies to version 2.10.0 for consistency.

 testImplementation 'org.xmlunit:xmlunit-core:2.10.0'
-testImplementation 'org.xmlunit:xmlunit-matchers:2.9.0'
-testImplementation 'org.xmlunit:xmlunit-assertj:2.9.0'
+testImplementation 'org.xmlunit:xmlunit-matchers:2.10.0'
+testImplementation 'org.xmlunit:xmlunit-assertj:2.10.0'
📝 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.

    testImplementation 'org.junit.jupiter:junit-jupiter:5.10.2'
    testImplementation 'org.assertj:assertj-core:3.25.3'
    testImplementation 'org.xmlunit:xmlunit-core:2.10.0'
    testImplementation 'org.xmlunit:xmlunit-matchers:2.10.0'
    testImplementation 'org.xmlunit:xmlunit-assertj:2.10.0'
CHANGELOG.md (2)

4-4: 🧹 Nitpick (assertive)

Document the purpose and benefits of the new enum.

The changelog entry for MtSequenceInfoEnum could be more descriptive. Consider adding:

  • Why this enum was added
  • What problem it solves
  • How it helps developers

Consider expanding the description:

-  * Added new `MtSequenceInfoEnum` with all the available inner sequences of specific MT schemas
+  * Added new `MtSequenceInfoEnum` to provide type-safe access to all available inner sequences of specific MT schemas, improving validation and reducing runtime errors when working with MT sequence paths
📝 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.

  * Added new `MtSequenceInfoEnum` to provide type-safe access to all available inner sequences of specific MT schemas, improving validation and reducing runtime errors when working with MT sequence paths
🧰 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)


14-18: 💡 Codebase verification

SRU2024 implementation verification requires attention

The verification has revealed mixed results:

  1. ✅ Dependency updates are correctly implemented in build.gradle:

    • commons-lang3 -> 3.14.0
    • gson -> 2.11.0
  2. ❌ The deprecation phase documentation link is not accessible (404 error):

Please ensure the deprecation phase documentation is published and accessible before the SRU2024 release. The documentation is critical for users to understand the impact of deprecated features.

🔗 Analysis chain

Verify SRU2024 implementation details.

The changelog mentions SWIFT Standard Release Update 2024 going live on November 16, 2025. This is a significant update that requires careful review:

  1. The deprecation phase link should be verified
  2. The dependency updates to commons-lang3 and gson should be validated

Let me verify the dependency versions in the build files and check for any potential issues.

The search results confirm:

  1. The dependency versions in build.gradle match exactly with what's mentioned in the changelog:
build.gradle:    implementation 'org.apache.commons:commons-lang3:3.14.0'
build.gradle:    implementation 'com.google.code.gson:gson:2.11.0'
  1. The extensive use of gson throughout the codebase (as shown by the numerous imports) indicates this is a critical dependency that needs careful validation.

Let me verify the deprecation phase link next.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the dependency versions in build files
# Test: Check build files for updated dependency versions
rg -A 2 "commons-lang3|gson" 

Length of output: 276987


Script:

#!/bin/bash
# Check if the deprecation phase documentation exists
curl -s -I https://dev.prowidesoftware.com/SRU2024/getting-started/deprecation/

Length of output: 698

🧰 Tools
🪛 Markdownlint

15-15: Expected: 0; Actual: 2
Unordered list indentation

(MD007, ul-indent)


16-16: Expected: 0; Actual: 2
Unordered list indentation

(MD007, ul-indent)


17-17: Expected: 0; Actual: 2
Unordered list indentation

(MD007, ul-indent)


18-18: Expected: 0; Actual: 2
Unordered list indentation

(MD007, ul-indent)


14-14: Expected: 1; Actual: 0; Below
Headings should be surrounded by blank lines

(MD022, blanks-around-headings)


15-15: null
Lists should be surrounded by blank lines

(MD032, blanks-around-lists)


16-16: null
Bare URL used

(MD034, no-bare-urls)

@ptorres-prowide ptorres-prowide force-pushed the CU-86b1uerqp_Generar-un-enum-de-MTs-para-validar-sus-secuencias-y-paths_SRU2024 branch from b59b20d to afab311 Compare November 13, 2024 16:50
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🧹 Outside diff range comments (1)
CHANGELOG.md (1)

Line range hint 1-24: Consider improving the markdown formatting.

The markdown structure could be enhanced for better readability and compliance with markdown best practices:

Apply these changes:

-# Prowide Core - CHANGELOG
+# Prowide Core - CHANGELOG
+
+## 9.5.3 - SNAPSHOT 
+* Added new `MtSequenceInfoEnum` with all the available inner sequences of specific MT schemas
 
-#### 9.5.2 - October 2024
+## 9.5.2 - October 2024
 * Added new `FieldEnum` with all the available field names
 * Code security improvements as per CodeQL recommendations

The changes will:

  1. Add proper spacing around headings
  2. Use consistent heading levels (h2 instead of h4)
  3. Fix list indentation
🧰 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)


7-7: Expected: 0; Actual: 2
Unordered list indentation

(MD007, ul-indent)


8-8: Expected: 0; Actual: 2
Unordered list indentation

(MD007, ul-indent)


3-3: Expected: 0 or 2; Actual: 1
Trailing spaces

(MD009, no-trailing-spaces)


3-3: Expected: 1; Actual: 0; Below
Headings should be surrounded by blank lines

(MD022, blanks-around-headings)


6-6: 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)


7-7: null
Lists should be surrounded by blank lines

(MD032, blanks-around-lists)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Reviewing files that changed from the base of the PR and between b59b20d and afab311.

⛔ Files ignored due to path filters (1)
  • src/generated/java/com/prowidesoftware/swift/model/mt/MtSequenceInfoEnum.java is excluded by !**/generated/**
📒 Files selected for processing (2)
  • CHANGELOG.md (1 hunks)
  • src/test/java/com/prowidesoftware/swift/model/mt/MtSequenceInfoTest.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: 0 or 2; Actual: 1
Trailing spaces

(MD009, no-trailing-spaces)


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)

3-5: LGTM! The changelog entry follows the established format.

The new version 9.5.3 (SNAPSHOT) is properly documented with the addition of the MtSequenceInfoEnum enumeration.

🧰 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: 0 or 2; Actual: 1
Trailing spaces

(MD009, no-trailing-spaces)


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)

Comment on lines 35 to 54
@Test
void testFromFieldNameInvalid() {
assertThrows(IllegalArgumentException.class, () -> MtSequenceInfoEnum.valueOf("INVALID"));
assertThrows(IllegalArgumentException.class, () -> MtSequenceInfoEnum.valueOf(""));
assertThrows(IllegalArgumentException.class, () -> MtSequenceInfoEnum.valueOf("MT"));
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Enhance invalid field name test coverage

Consider adding tests for:

  1. Null input
  2. Field names with invalid formats but correct prefix
     @Test
     void testFromFieldNameInvalid() {
+        assertThrows(IllegalArgumentException.class, () -> MtSequenceInfoEnum.valueOf(null));
         assertThrows(IllegalArgumentException.class, () -> MtSequenceInfoEnum.valueOf("INVALID"));
         assertThrows(IllegalArgumentException.class, () -> MtSequenceInfoEnum.valueOf(""));
         assertThrows(IllegalArgumentException.class, () -> MtSequenceInfoEnum.valueOf("MT"));
+        assertThrows(IllegalArgumentException.class, () -> MtSequenceInfoEnum.valueOf("MT999999"));
+        assertThrows(IllegalArgumentException.class, () -> MtSequenceInfoEnum.valueOf("MTxxx"));
     }
📝 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.

Suggested change
@Test
void testFromFieldNameInvalid() {
assertThrows(IllegalArgumentException.class, () -> MtSequenceInfoEnum.valueOf("INVALID"));
assertThrows(IllegalArgumentException.class, () -> MtSequenceInfoEnum.valueOf(""));
assertThrows(IllegalArgumentException.class, () -> MtSequenceInfoEnum.valueOf("MT"));
}
@Test
void testFromFieldNameInvalid() {
assertThrows(IllegalArgumentException.class, () -> MtSequenceInfoEnum.valueOf(null));
assertThrows(IllegalArgumentException.class, () -> MtSequenceInfoEnum.valueOf("INVALID"));
assertThrows(IllegalArgumentException.class, () -> MtSequenceInfoEnum.valueOf(""));
assertThrows(IllegalArgumentException.class, () -> MtSequenceInfoEnum.valueOf("MT"));
assertThrows(IllegalArgumentException.class, () -> MtSequenceInfoEnum.valueOf("MT999999"));
assertThrows(IllegalArgumentException.class, () -> MtSequenceInfoEnum.valueOf("MTxxx"));
}

Comment on lines 12 to 83
class MtSequenceInfoEnumTest {

@ParameterizedTest
@CsvSource({
"MT101, 'A,B'",
"MT102, 'A,B,C'",
"MT300, 'A,B,B/B1,B/B2,C,D,D/D1,E,E/E1,E/E1/E1a,E/E1/E1a/E1a1,F'",
"MT508, 'A,A/A1,B,B/B1,C'"
})
void testGetSequencesInfo(MtSequenceInfoEnum sequenceInfo, String expectedSequences) {
assertEquals(toSet(expectedSequences), sequenceInfo.sequencesInfo());
}

private Set<String> toSet(String input) {
return Arrays.stream(input.split(",")).collect(Collectors.toSet());
}

@ParameterizedTest
@CsvSource({"MT101, MT101", "MT102, MT102", "MT508, MT508"})
void testFromFieldNameValid(String fieldName, MtSequenceInfoEnum expectedEnum) {
assertEquals(expectedEnum, MtSequenceInfoEnum.valueOf(fieldName));
}

@Test
void testFromFieldNameInvalid() {
assertThrows(IllegalArgumentException.class, () -> MtSequenceInfoEnum.valueOf("INVALID"));
assertThrows(IllegalArgumentException.class, () -> MtSequenceInfoEnum.valueOf(""));
assertThrows(IllegalArgumentException.class, () -> MtSequenceInfoEnum.valueOf("MT"));
}

@Test
void testAllEnumValuesHaveSequences() {
for (MtSequenceInfoEnum sequenceInfo : MtSequenceInfoEnum.values()) {
assertNotNull(sequenceInfo.sequencesInfo(), "Sequence info should not be null");
assertFalse(sequenceInfo.sequencesInfo().isEmpty(), "Sequence info should not be empty");
// Validate sequence format
Set<String> sequences = sequenceInfo.sequencesInfo();
for (String sequence : sequences) {
assertTrue(
sequence.matches("^[A-Z](?:/[A-Z][0-9]?(?:[a-z][0-9]?[A-Za-z0-9]*)?)*$"),
"Sequence " + sequence + " should match expected format");
}
// Check for duplicates
assertEquals(
sequences.size(),
Arrays.stream(sequences.toArray()).distinct().count(),
"Sequences should not contain duplicates");
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Consider introducing a test fixture for common test data

To improve maintainability and reduce duplication, consider extracting common test data into a test fixture class. This would make it easier to maintain the expected sequences and add new message types.

+    /**
+     * Test fixture containing expected sequence information for different MT types.
+     */
+    private static class MtSequenceTestData {
+        static final class SequenceInfo {
+            final String mtType;
+            final Set<String> sequences;
+            
+            SequenceInfo(String mtType, String... sequences) {
+                this.mtType = mtType;
+                this.sequences = Set.of(sequences);
+            }
+        }
+        
+        static final List<SequenceInfo> TEST_CASES = List.of(
+            new SequenceInfo("MT101", "A", "B"),
+            new SequenceInfo("MT102", "A", "B", "C"),
+            // Add more test cases here
+        );
+    }

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines 25 to 38
private Set<String> toSet(String input) {
return Arrays.stream(input.split(",")).collect(Collectors.toSet());
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add input validation and whitespace handling to helper method

The utility method should handle edge cases and ensure consistent results.

     private Set<String> toSet(String input) {
-        return Arrays.stream(input.split(",")).collect(Collectors.toSet());
+        if (input == null || input.trim().isEmpty()) {
+            return Collections.emptySet();
+        }
+        return Arrays.stream(input.split(","))
+            .map(String::trim)
+            .filter(s -> !s.isEmpty())
+            .collect(Collectors.toSet());
     }
📝 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.

Suggested change
private Set<String> toSet(String input) {
return Arrays.stream(input.split(",")).collect(Collectors.toSet());
}
private Set<String> toSet(String input) {
if (input == null || input.trim().isEmpty()) {
return Collections.emptySet();
}
return Arrays.stream(input.split(","))
.map(String::trim)
.filter(s -> !s.isEmpty())
.collect(Collectors.toSet());
}

Comment on lines 14 to 27
@ParameterizedTest
@CsvSource({
"MT101, 'A,B'",
"MT102, 'A,B,C'",
"MT300, 'A,B,B/B1,B/B2,C,D,D/D1,E,E/E1,E/E1/E1a,E/E1/E1a/E1a1,F'",
"MT508, 'A,A/A1,B,B/B1,C'"
})
void testGetSequencesInfo(MtSequenceInfoEnum sequenceInfo, String expectedSequences) {
assertEquals(toSet(expectedSequences), sequenceInfo.sequencesInfo());
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Consider enhancing test coverage and documentation

While the parameterized test effectively validates basic sequence information, consider:

  1. Adding Javadoc to explain the expected sequence format and test purpose
  2. Including edge cases such as messages with single sequences or complex nested structures
+    /**
+     * Validates that the sequence information returned by MtSequenceInfoEnum matches
+     * the expected sequences for different MT message types.
+     * Format: A = main sequence, B/B1 = nested sequence
+     *
+     * @param sequenceInfo The enum value to test
+     * @param expectedSequences Comma-separated list of expected sequences
+     */
     @ParameterizedTest
     @CsvSource({
         "MT101, 'A,B'",
         "MT102, 'A,B,C'",
         "MT300, 'A,B,B/B1,B/B2,C,D,D/D1,E,E/E1,E/E1/E1a,E/E1/E1a/E1a1,F'",
-        "MT508, 'A,A/A1,B,B/B1,C'"
+        "MT508, 'A,A/A1,B,B/B1,C'",
+        // Add edge cases
+        "MT999, 'A'",  // Single sequence
+        "MT199, 'A/A1/A1a/A1a1'"  // Deeply nested
     })
📝 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.

Suggested change
@ParameterizedTest
@CsvSource({
"MT101, 'A,B'",
"MT102, 'A,B,C'",
"MT300, 'A,B,B/B1,B/B2,C,D,D/D1,E,E/E1,E/E1/E1a,E/E1/E1a/E1a1,F'",
"MT508, 'A,A/A1,B,B/B1,C'"
})
void testGetSequencesInfo(MtSequenceInfoEnum sequenceInfo, String expectedSequences) {
assertEquals(toSet(expectedSequences), sequenceInfo.sequencesInfo());
}
/**
* Validates that the sequence information returned by MtSequenceInfoEnum matches
* the expected sequences for different MT message types.
* Format: A = main sequence, B/B1 = nested sequence
*
* @param sequenceInfo The enum value to test
* @param expectedSequences Comma-separated list of expected sequences
*/
@ParameterizedTest
@CsvSource({
"MT101, 'A,B'",
"MT102, 'A,B,C'",
"MT300, 'A,B,B/B1,B/B2,C,D,D/D1,E,E/E1,E/E1/E1a,E/E1/E1a/E1a1,F'",
"MT508, 'A,A/A1,B,B/B1,C'",
// Add edge cases
"MT999, 'A'", // Single sequence
"MT199, 'A/A1/A1a/A1a1'" // Deeply nested
})
void testGetSequencesInfo(MtSequenceInfoEnum sequenceInfo, String expectedSequences) {
assertEquals(toSet(expectedSequences), sequenceInfo.sequencesInfo());
}

Comment on lines 42 to 82
@Test
void testAllEnumValuesHaveSequences() {
for (MtSequenceInfoEnum sequenceInfo : MtSequenceInfoEnum.values()) {
assertNotNull(sequenceInfo.sequencesInfo(), "Sequence info should not be null");
assertFalse(sequenceInfo.sequencesInfo().isEmpty(), "Sequence info should not be empty");
// Validate sequence format
Set<String> sequences = sequenceInfo.sequencesInfo();
for (String sequence : sequences) {
assertTrue(
sequence.matches("^[A-Z](?:/[A-Z][0-9]?(?:[a-z][0-9]?[A-Za-z0-9]*)?)*$"),
"Sequence " + sequence + " should match expected format");
}
// Check for duplicates
assertEquals(
sequences.size(),
Arrays.stream(sequences.toArray()).distinct().count(),
"Sequences should not contain duplicates");
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Improve maintainability and error reporting of validation test

The comprehensive validation test could be enhanced in several ways:

+    private static final String SEQUENCE_PATTERN = "^[A-Z](?:/[A-Z][0-9]?(?:[a-z][0-9]?[A-Za-z0-9]*)?)*$";
+
     @Test
     void testAllEnumValuesHaveSequences() {
         for (MtSequenceInfoEnum sequenceInfo : MtSequenceInfoEnum.values()) {
+            String enumName = sequenceInfo.name();
-            assertNotNull(sequenceInfo.sequencesInfo(), "Sequence info should not be null");
-            assertFalse(sequenceInfo.sequencesInfo().isEmpty(), "Sequence info should not be empty");
+            assertNotNull(sequenceInfo.sequencesInfo(), 
+                String.format("Sequence info for %s should not be null", enumName));
+            assertFalse(sequenceInfo.sequencesInfo().isEmpty(), 
+                String.format("Sequence info for %s should not be empty", enumName));
             
             // Validate sequence format
             Set<String> sequences = sequenceInfo.sequencesInfo();
             for (String sequence : sequences) {
                 assertTrue(
-                        sequence.matches("^[A-Z](?:/[A-Z][0-9]?(?:[a-z][0-9]?[A-Za-z0-9]*)?)*$"),
-                        "Sequence " + sequence + " should match expected format");
+                        sequence.matches(SEQUENCE_PATTERN),
+                        String.format("Sequence '%s' in %s should match format: %s", 
+                            sequence, enumName, SEQUENCE_PATTERN));
             }
             
             // Check for duplicates
-            assertEquals(
-                    sequences.size(),
-                    Arrays.stream(sequences.toArray()).distinct().count(),
-                    "Sequences should not contain duplicates");
+            Set<String> uniqueSequences = new HashSet<>(sequences);
+            assertEquals(sequences.size(), uniqueSequences.size(),
+                String.format("Sequences in %s contain duplicates: %s", 
+                    enumName, sequences));
         }
     }
📝 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.

Suggested change
@Test
void testAllEnumValuesHaveSequences() {
for (MtSequenceInfoEnum sequenceInfo : MtSequenceInfoEnum.values()) {
assertNotNull(sequenceInfo.sequencesInfo(), "Sequence info should not be null");
assertFalse(sequenceInfo.sequencesInfo().isEmpty(), "Sequence info should not be empty");
// Validate sequence format
Set<String> sequences = sequenceInfo.sequencesInfo();
for (String sequence : sequences) {
assertTrue(
sequence.matches("^[A-Z](?:/[A-Z][0-9]?(?:[a-z][0-9]?[A-Za-z0-9]*)?)*$"),
"Sequence " + sequence + " should match expected format");
}
// Check for duplicates
assertEquals(
sequences.size(),
Arrays.stream(sequences.toArray()).distinct().count(),
"Sequences should not contain duplicates");
}
}
private static final String SEQUENCE_PATTERN = "^[A-Z](?:/[A-Z][0-9]?(?:[a-z][0-9]?[A-Za-z0-9]*)?)*$";
@Test
void testAllEnumValuesHaveSequences() {
for (MtSequenceInfoEnum sequenceInfo : MtSequenceInfoEnum.values()) {
String enumName = sequenceInfo.name();
assertNotNull(sequenceInfo.sequencesInfo(),
String.format("Sequence info for %s should not be null", enumName));
assertFalse(sequenceInfo.sequencesInfo().isEmpty(),
String.format("Sequence info for %s should not be empty", enumName));
// Validate sequence format
Set<String> sequences = sequenceInfo.sequencesInfo();
for (String sequence : sequences) {
assertTrue(
sequence.matches(SEQUENCE_PATTERN),
String.format("Sequence '%s' in %s should match format: %s",
sequence, enumName, SEQUENCE_PATTERN));
}
// Check for duplicates
Set<String> uniqueSequences = new HashSet<>(sequences);
assertEquals(sequences.size(), uniqueSequences.size(),
String.format("Sequences in %s contain duplicates: %s",
enumName, sequences));
}
}

@ptorres-prowide ptorres-prowide force-pushed the CU-86b1uerqp_Generar-un-enum-de-MTs-para-validar-sus-secuencias-y-paths_SRU2024 branch from afab311 to f538ee4 Compare November 13, 2024 16:56
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Reviewing files that changed from the base of the PR and between afab311 and f538ee4.

⛔ Files ignored due to path filters (1)
  • src/generated/java/com/prowidesoftware/swift/model/mt/MtSequenceInfoEnum.java is excluded by !**/generated/**
📒 Files selected for processing (2)
  • CHANGELOG.md (1 hunks)
  • src/test/java/com/prowidesoftware/swift/model/mt/MtSequenceInfoTest.java (1 hunks)
🧰 Additional context used
🪛 Markdownlint
CHANGELOG.md

6-6: Expected: 0; Actual: 2
Unordered list indentation

(MD007, ul-indent)

🔇 Additional comments (3)
src/test/java/com/prowidesoftware/swift/model/mt/MtSequenceInfoTest.java (2)

1-12: LGTM!

The class structure and imports are well-organized and include all necessary dependencies.


12-61: Verify complete test coverage of MtSequenceInfoEnum.

Let's ensure we have tests for all public methods in the MtSequenceInfoEnum class.

✅ Verification successful

Let me try a different approach to locate and analyze the files.


Now I can analyze the complete picture. Looking at the enum class and its test file, I can generate the final response:

All public methods in MtSequenceInfoEnum are adequately tested

The enum class has only two public members that need testing:

  • The sequencesInfo() method - thoroughly tested via testGetSequencesInfo and testAllEnumValuesHaveSequences
  • The valueOf() method (inherited from Enum) - comprehensively tested via testFromFieldNameValid and testFromFieldNameInvalid

The test coverage is complete with:

  • Parameterized tests for valid sequence info retrieval
  • Validation of all enum values' sequence formats
  • Null/empty/invalid input handling
  • Duplicate checking
  • Format validation for all sequence strings
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for untested public methods in MtSequenceInfoEnum

# Find all public methods in MtSequenceInfoEnum
echo "Public methods in MtSequenceInfoEnum:"
ast-grep --pattern 'public $_ $NAME($$$) { $$$ }' src/main/java/com/prowidesoftware/swift/model/mt/MtSequenceInfoEnum.java

# Find all tested methods in test file
echo -e "\nTested methods (referenced in test file):"
rg -o 'MtSequenceInfoEnum\.[a-zA-Z]+' src/test/java/com/prowidesoftware/swift/model/mt/MtSequenceInfoEnumTest.java | sort -u

Length of output: 672


Script:

#!/bin/bash
# First, let's find the correct paths
echo "Finding relevant files:"
fd -e java MtSequenceInfo

echo -e "\nChecking content of enum file:"
fd -e java MtSequenceInfo --type f --exec cat {}

Length of output: 9068

CHANGELOG.md (1)

6-6: LGTM! Clear and well-formatted changelog entry.

The new entry follows the established format and clearly documents the addition of the MtSequenceInfoEnum feature.

🧰 Tools
🪛 Markdownlint

6-6: Expected: 0; Actual: 2
Unordered list indentation

(MD007, ul-indent)

Comment on lines 29 to 44
@ParameterizedTest
@CsvSource({"MT101, MT101", "MT102, MT102", "MT508, MT508"})
void testFromFieldNameValid(String fieldName, MtSequenceInfoEnum expectedEnum) {
assertEquals(expectedEnum, MtSequenceInfoEnum.valueOf(fieldName));
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Consider adding more edge cases for valid field names.

The current test covers basic valid cases. Consider adding tests for:

  1. MT numbers with leading zeros (e.g., "MT001")
  2. Maximum valid MT number
  3. Boundary cases for valid MT numbers
 @ParameterizedTest
-@CsvSource({"MT101, MT101", "MT102, MT102", "MT508, MT508"})
+@CsvSource({
+    "MT101, MT101",
+    "MT102, MT102",
+    "MT508, MT508",
+    "MT001, MT001",  // Leading zeros
+    "MT999, MT999",  // Maximum valid number
+    "MT000, MT000"   // Boundary case
+})
 void testFromFieldNameValid(String fieldName, MtSequenceInfoEnum expectedEnum) {
     assertEquals(expectedEnum, MtSequenceInfoEnum.valueOf(fieldName));
 }

Committable suggestion skipped: line range outside the PR's diff.

@ptorres-prowide ptorres-prowide force-pushed the CU-86b1uerqp_Generar-un-enum-de-MTs-para-validar-sus-secuencias-y-paths_SRU2024 branch from f538ee4 to 3fd4237 Compare November 13, 2024 17:09
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Outside diff range comments (1)
CHANGELOG.md (1)

Line range hint 1-6: Fix bullet point indentation inconsistency.

The bullet points in the changelog have inconsistent indentation - some use 2 spaces while others use 4 spaces. For better readability and maintainability, standardize the indentation to 2 spaces for all bullet points.

Apply this diff to fix the indentation:

# Prowide Core - CHANGELOG

#### 9.5.3 - SNAPSHOT
- (PW-2006) Fixed `getMUR` and `setMUR` in `SwiftMessage` to prioritize field 108 in block 4 over block 3 for system messages (category 0)
- Added `isSystemMessage()` to SwiftMessage to check if the message is a category 0 message (010. 011, etc...)
-  * Added new `MtSequenceInfoEnum` with all the available inner sequences of specific MT schemas
+- Added new `MtSequenceInfoEnum` with all the available inner sequences of specific MT schemas
🧰 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)


5-5: Expected: 0; Actual: 2
Unordered list indentation

(MD007, ul-indent)


6-6: Expected: 0; Actual: 2
Unordered list indentation

(MD007, ul-indent)


9-9: 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)


8-8: 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)


9-9: null
Lists should be surrounded by blank lines

(MD032, blanks-around-lists)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Reviewing files that changed from the base of the PR and between f538ee4 and 3fd4237.

⛔ Files ignored due to path filters (1)
  • src/generated/java/com/prowidesoftware/swift/model/mt/MtSequenceInfoEnum.java is excluded by !**/generated/**
📒 Files selected for processing (2)
  • CHANGELOG.md (1 hunks)
  • src/test/java/com/prowidesoftware/swift/model/mt/MtSequenceInfoTest.java (1 hunks)
🧰 Additional context used
🪛 Markdownlint
CHANGELOG.md

6-6: Expected: 0; Actual: 2
Unordered list indentation

(MD007, ul-indent)

🔇 Additional comments (2)
src/test/java/com/prowidesoftware/swift/model/mt/MtSequenceInfoTest.java (2)

18-27: LGTM with previous suggestions!

The test structure is good, and the previous review comments about enhancing test coverage and documentation are still valid.


29-38: LGTM - Robust implementation!

The helper method properly handles edge cases and ensures consistent results through trimming and filtering.


class MtSequenceInfoEnumTest {

private static final String SEQUENCE_PATTERN = "^[A-Z](?:/[A-Z][0-9]?(?:[a-z][0-9]?[A-Za-z0-9]*)?)*$";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Add documentation for the sequence pattern regex

Consider adding Javadoc to explain the components of the regex pattern and provide examples of valid/invalid sequences.

+    /**
+     * Regex pattern for validating MT sequence format:
+     * - Starts with an uppercase letter (A-Z)
+     * - Optionally followed by nested sequences:
+     *   - Forward slash
+     *   - Uppercase letter
+     *   - Optional digit
+     *   - Optional lowercase letter + digit + alphanumeric
+     * Examples:
+     * - Valid: "A", "A/B1", "A/B1a2"
+     * - Invalid: "1A", "A/", "A/1"
+     */
     private static final String SEQUENCE_PATTERN = "^[A-Z](?:/[A-Z][0-9]?(?:[a-z][0-9]?[A-Za-z0-9]*)?)*$";
📝 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.

Suggested change
private static final String SEQUENCE_PATTERN = "^[A-Z](?:/[A-Z][0-9]?(?:[a-z][0-9]?[A-Za-z0-9]*)?)*$";
/**
* Regex pattern for validating MT sequence format:
* - Starts with an uppercase letter (A-Z)
* - Optionally followed by nested sequences:
* - Forward slash
* - Uppercase letter
* - Optional digit
* - Optional lowercase letter + digit + alphanumeric
* Examples:
* - Valid: "A", "A/B1", "A/B1a2"
* - Invalid: "1A", "A/", "A/1"
*/
private static final String SEQUENCE_PATTERN = "^[A-Z](?:/[A-Z][0-9]?(?:[a-z][0-9]?[A-Za-z0-9]*)?)*$";

Comment on lines 56 to 82
@Test
void testAllEnumValuesHaveSequences() {
for (MtSequenceInfoEnum sequenceInfo : MtSequenceInfoEnum.values()) {
String enumName = sequenceInfo.name();
assertNotNull(
sequenceInfo.sequencesInfo(), String.format("Sequence info for %s should not be null", enumName));
assertFalse(
sequenceInfo.sequencesInfo().isEmpty(),
String.format("Sequence info for %s should not be empty", enumName));

// Validate sequence format
Set<String> sequences = sequenceInfo.sequencesInfo();
for (String sequence : sequences) {
assertTrue(
sequence.matches(SEQUENCE_PATTERN),
String.format(
"Sequence '%s' in %s should match format: %s", sequence, enumName, SEQUENCE_PATTERN));
}

// Check for duplicates
Set<String> uniqueSequences = new HashSet<>(sequences);
assertEquals(
sequences.size(),
uniqueSequences.size(),
String.format("Sequences in %s contain duplicates: %s", enumName, sequences));
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Consider optimizing for performance with large enums

For better performance with large enums, consider:

  1. Precompiling the regex pattern
  2. Using a more efficient data structure for duplicate checking
+    private static final Pattern COMPILED_SEQUENCE_PATTERN = Pattern.compile(SEQUENCE_PATTERN);
+
     @Test
     void testAllEnumValuesHaveSequences() {
+        // Pre-allocate set with expected capacity
+        Set<String> uniqueSequences = new HashSet<>(32);
         for (MtSequenceInfoEnum sequenceInfo : MtSequenceInfoEnum.values()) {
             // ... validation code ...
             
             // Validate sequence format
             Set<String> sequences = sequenceInfo.sequencesInfo();
             for (String sequence : sequences) {
                 assertTrue(
-                        sequence.matches(SEQUENCE_PATTERN),
+                        COMPILED_SEQUENCE_PATTERN.matcher(sequence).matches(),
                         String.format(
                                 "Sequence '%s' in %s should match format: %s", 
                                 sequence, enumName, SEQUENCE_PATTERN));
             }
             
             // Check for duplicates
-            Set<String> uniqueSequences = new HashSet<>(sequences);
+            uniqueSequences.clear();
+            uniqueSequences.addAll(sequences);
             assertEquals(
                     sequences.size(),
                     uniqueSequences.size(),
                     String.format("Sequences in %s contain duplicates: %s", 
                             enumName, sequences));
         }
     }
📝 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.

Suggested change
@Test
void testAllEnumValuesHaveSequences() {
for (MtSequenceInfoEnum sequenceInfo : MtSequenceInfoEnum.values()) {
String enumName = sequenceInfo.name();
assertNotNull(
sequenceInfo.sequencesInfo(), String.format("Sequence info for %s should not be null", enumName));
assertFalse(
sequenceInfo.sequencesInfo().isEmpty(),
String.format("Sequence info for %s should not be empty", enumName));
// Validate sequence format
Set<String> sequences = sequenceInfo.sequencesInfo();
for (String sequence : sequences) {
assertTrue(
sequence.matches(SEQUENCE_PATTERN),
String.format(
"Sequence '%s' in %s should match format: %s", sequence, enumName, SEQUENCE_PATTERN));
}
// Check for duplicates
Set<String> uniqueSequences = new HashSet<>(sequences);
assertEquals(
sequences.size(),
uniqueSequences.size(),
String.format("Sequences in %s contain duplicates: %s", enumName, sequences));
}
}
private static final Pattern COMPILED_SEQUENCE_PATTERN = Pattern.compile(SEQUENCE_PATTERN);
@Test
void testAllEnumValuesHaveSequences() {
// Pre-allocate set with expected capacity
Set<String> uniqueSequences = new HashSet<>(32);
for (MtSequenceInfoEnum sequenceInfo : MtSequenceInfoEnum.values()) {
String enumName = sequenceInfo.name();
assertNotNull(
sequenceInfo.sequencesInfo(), String.format("Sequence info for %s should not be null", enumName));
assertFalse(
sequenceInfo.sequencesInfo().isEmpty(),
String.format("Sequence info for %s should not be empty", enumName));
// Validate sequence format
Set<String> sequences = sequenceInfo.sequencesInfo();
for (String sequence : sequences) {
assertTrue(
COMPILED_SEQUENCE_PATTERN.matcher(sequence).matches(),
String.format(
"Sequence '%s' in %s should match format: %s", sequence, enumName, SEQUENCE_PATTERN));
}
// Check for duplicates
uniqueSequences.clear();
uniqueSequences.addAll(sequences);
assertEquals(
sequences.size(),
uniqueSequences.size(),
String.format("Sequences in %s contain duplicates: %s", enumName, sequences));
}
}

Comment on lines 46 to 54
@Test
void testFromFieldNameInvalid() {
assertThrows(NullPointerException.class, () -> MtSequenceInfoEnum.valueOf(null));
assertThrows(IllegalArgumentException.class, () -> MtSequenceInfoEnum.valueOf("INVALID"));
assertThrows(IllegalArgumentException.class, () -> MtSequenceInfoEnum.valueOf(""));
assertThrows(IllegalArgumentException.class, () -> MtSequenceInfoEnum.valueOf("MT"));
assertThrows(IllegalArgumentException.class, () -> MtSequenceInfoEnum.valueOf("MT999999"));
assertThrows(IllegalArgumentException.class, () -> MtSequenceInfoEnum.valueOf("MTxxx"));
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Consider verifying exception messages

While the test covers various invalid scenarios, it would be more robust to verify the actual exception messages to ensure proper error reporting.

     @Test
     void testFromFieldNameInvalid() {
-        assertThrows(NullPointerException.class, () -> MtSequenceInfoEnum.valueOf(null));
-        assertThrows(IllegalArgumentException.class, () -> MtSequenceInfoEnum.valueOf("INVALID"));
+        NullPointerException npe = assertThrows(NullPointerException.class, 
+            () -> MtSequenceInfoEnum.valueOf(null));
+        assertEquals("Field name cannot be null", npe.getMessage());
+
+        IllegalArgumentException iae = assertThrows(IllegalArgumentException.class, 
+            () -> MtSequenceInfoEnum.valueOf("INVALID"));
+        assertEquals("Invalid MT field name format: INVALID", iae.getMessage());
         // ... rest of the test cases
     }

Committable suggestion skipped: line range outside the PR's diff.

CHANGELOG.md Outdated
@@ -3,6 +3,7 @@
#### 9.5.3 - SNAPSHOT
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Consider using a more specific version identifier.

Using "SNAPSHOT" in the version number indicates this is a development version. Consider using a more specific version identifier that follows semantic versioning principles, especially if this version contains significant changes like fixes and new functionality.

🧰 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)

@ptorres-prowide ptorres-prowide force-pushed the CU-86b1uerqp_Generar-un-enum-de-MTs-para-validar-sus-secuencias-y-paths_SRU2024 branch from 86a0195 to 83f3bbf Compare November 15, 2024 17:29
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Reviewing files that changed from the base of the PR and between 3fd4237 and b2b7472.

⛔ Files ignored due to path filters (2)
  • src/generated/java/com/prowidesoftware/swift/model/field/FieldEnum.java is excluded by !**/generated/**
  • src/generated/java/com/prowidesoftware/swift/model/mt/MtSequenceEnum.java is excluded by !**/generated/**
📒 Files selected for processing (2)
  • CHANGELOG.md (1 hunks)
  • src/test/java/com/prowidesoftware/swift/model/mt/MtSequenceEnumTest.java (1 hunks)
🧰 Additional context used
🪛 Markdownlint
CHANGELOG.md

6-6: Expected: 0; Actual: 2
Unordered list indentation

(MD007, ul-indent)

🔇 Additional comments (1)
CHANGELOG.md (1)

6-6: LGTM!

The changelog entry is well-formatted and provides clear documentation about the addition of the new MtSequenceEnum feature.

🧰 Tools
🪛 Markdownlint

6-6: Expected: 0; Actual: 2
Unordered list indentation

(MD007, ul-indent)

Comment on lines 74 to 111
@Test
void testAllEnumValuesHaveSequences() {
for (MtSequenceEnum seqValue : MtSequenceEnum.values()) {
String enumName = seqValue.name();
assertNotNull(seqValue.sequences(), String.format("Sequence for enum value '%s' is null", enumName));
assertFalse(
seqValue.sequences().isEmpty(),
String.format("Sequence for enum value '%s' is empty. Expected at least one sequence.", enumName));

// Validate sequence format
Set<String> sequences = seqValue.sequences();
for (String sequence : sequences) {
assertTrue(
sequence.matches(SEQUENCE_PATTERN),
String.format(
"Sequence '%s' in %s should match format: %s", sequence, enumName, SEQUENCE_PATTERN));
}

// Check for duplicates
Set<String> uniqueSequences = new HashSet<>(sequences);
assertEquals(
sequences.size(),
uniqueSequences.size(),
String.format("Sequences in %s contain duplicates: %s", enumName, sequences));
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Consider splitting the comprehensive test into focused methods.

While thorough, this test method is doing multiple validations that could be separated for better clarity and maintenance.

Consider refactoring to:

+    @Test
+    void shouldHaveNonEmptySequences() {
+        for (MtSequenceEnum seqValue : MtSequenceEnum.values()) {
+            assertNotNull(seqValue.sequences(), 
+                String.format("Sequence for enum value '%s' is null", seqValue.name()));
+            assertFalse(seqValue.sequences().isEmpty(),
+                String.format("Sequence for enum value '%s' is empty", seqValue.name()));
+        }
+    }
+
+    @Test
+    void shouldHaveValidSequenceFormat() {
+        for (MtSequenceEnum seqValue : MtSequenceEnum.values()) {
+            seqValue.sequences().forEach(sequence -> 
+                assertTrue(sequence.matches(SEQUENCE_PATTERN),
+                    String.format("Invalid sequence format '%s' in %s", 
+                        sequence, seqValue.name())));
+        }
+    }
+
+    @Test
+    void shouldNotHaveDuplicateSequences() {
+        for (MtSequenceEnum seqValue : MtSequenceEnum.values()) {
+            Set<String> sequences = seqValue.sequences();
+            Set<String> uniqueSequences = new HashSet<>(sequences);
+            assertEquals(sequences.size(), uniqueSequences.size(),
+                String.format("Duplicates found in %s: %s", 
+                    seqValue.name(), sequences));
+        }
+    }

Also consider creating custom assertions for better readability:

private static void assertValidSequence(String sequence, String enumName) {
    assertTrue(sequence.matches(SEQUENCE_PATTERN),
        String.format("Invalid sequence format '%s' in %s", sequence, enumName));
}

Comment on lines 1 to 112
package com.prowidesoftware.swift.model.mt;

import static org.junit.jupiter.api.Assertions.*;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import org.junit.jupiter.api.Test;

class MtSequenceEnumTest {

private static final String SEQUENCE_PATTERN = "^[A-Z](?:/[A-Z][0-9]?(?:[a-z][0-9]?[A-Za-z0-9]*)?)*$";

@Test
void testGetSequences_MT101() {
MtSequenceEnum sequence = MtSequenceEnum.MT101;
Set<String> expectedSequences = new HashSet<>(Arrays.asList("A", "B"));
assertEquals(expectedSequences, sequence.sequences());
}

@Test
void testGetSequences_MT102() {
MtSequenceEnum sequence = MtSequenceEnum.MT102;
Set<String> expectedSequences = new HashSet<>(Arrays.asList("A", "B", "C"));
assertEquals(expectedSequences, sequence.sequences());
}

@Test
void testGetSequences_MT300() {
MtSequenceEnum sequence = MtSequenceEnum.MT300;
Set<String> expectedSequences = new HashSet<>(Arrays.asList(
"A", "B", "B/B1", "B/B2", "C", "D", "D/D1", "E", "E/E1", "E/E1/E1a", "E/E1/E1a/E1a1", "F"));
assertEquals(expectedSequences, sequence.sequences());
}

@Test
void testGetSequences_MT508() {
MtSequenceEnum sequence = MtSequenceEnum.MT508;
Set<String> expectedSequences = new HashSet<>(Arrays.asList("A", "A/A1", "B", "B/B1", "C"));
assertEquals(expectedSequences, sequence.sequences());
}

@Test
void testFromFieldNameValid_MT101() {
String fieldName = "MT101";
MtSequenceEnum expectedEnum = MtSequenceEnum.MT101;
assertEquals(expectedEnum, MtSequenceEnum.valueOf(fieldName));
}

@Test
void testFromFieldNameValid_MT102() {
String fieldName = "MT102";
MtSequenceEnum expectedEnum = MtSequenceEnum.MT102;
assertEquals(expectedEnum, MtSequenceEnum.valueOf(fieldName));
}

@Test
void testFromFieldNameValid_MT508() {
String fieldName = "MT508";
MtSequenceEnum expectedEnum = MtSequenceEnum.MT508;
assertEquals(expectedEnum, MtSequenceEnum.valueOf(fieldName));
}

@Test
void testFromFieldNameInvalid() {
assertThrows(NullPointerException.class, () -> MtSequenceEnum.valueOf(null));
assertThrows(IllegalArgumentException.class, () -> MtSequenceEnum.valueOf("INVALID"));
assertThrows(IllegalArgumentException.class, () -> MtSequenceEnum.valueOf(""));
assertThrows(IllegalArgumentException.class, () -> MtSequenceEnum.valueOf("MT"));
assertThrows(IllegalArgumentException.class, () -> MtSequenceEnum.valueOf("MT999999"));
assertThrows(IllegalArgumentException.class, () -> MtSequenceEnum.valueOf("MTxxx"));
}

@Test
void testAllEnumValuesHaveSequences() {
for (MtSequenceEnum seqValue : MtSequenceEnum.values()) {
String enumName = seqValue.name();
assertNotNull(seqValue.sequences(), String.format("Sequence for enum value '%s' is null", enumName));
assertFalse(
seqValue.sequences().isEmpty(),
String.format("Sequence for enum value '%s' is empty. Expected at least one sequence.", enumName));

// Validate sequence format
Set<String> sequences = seqValue.sequences();
for (String sequence : sequences) {
assertTrue(
sequence.matches(SEQUENCE_PATTERN),
String.format(
"Sequence '%s' in %s should match format: %s", sequence, enumName, SEQUENCE_PATTERN));
}

// Check for duplicates
Set<String> uniqueSequences = new HashSet<>(sequences);
assertEquals(
sequences.size(),
uniqueSequences.size(),
String.format("Sequences in %s contain duplicates: %s", enumName, sequences));
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Test coverage for MT message types is incomplete

The test class only covers 4 MT types (MT101, MT102, MT300, MT508) out of 200+ MT types found in the codebase. While the test structure and validation logic is solid, it needs to be expanded to include more message types, especially:

  • Common message types like MT103 (Customer Credit Transfer), MT202 (General Financial Institution Transfer)
  • Message types with complex sequence structures like MT564 (Corporate Action Notification), MT535 (Statement of Holdings)
  • Representative samples from different message categories (1xx, 2xx, etc.)
🔗 Analysis chain

Verify coverage of all MT message types.

The test class provides good coverage but we should verify if all supported MT message types are included in the tests.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Find all MT types referenced in the codebase
echo "Finding all MT types in the codebase..."
rg -o "MT[0-9]{3}" --no-filename | sort -u > /tmp/mt_types.txt

echo "MT types tested in MtSequenceEnumTest:"
rg -o "MT[0-9]{3}" src/test/java/com/prowidesoftware/swift/model/mt/MtSequenceEnumTest.java | sort -u

echo "Comparing with all MT types in codebase:"
cat /tmp/mt_types.txt

Length of output: 2113


class MtSequenceEnumTest {

private static final String SEQUENCE_PATTERN = "^[A-Z](?:/[A-Z][0-9]?(?:[a-z][0-9]?[A-Za-z0-9]*)?)*$";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Add documentation for the sequence pattern regex.

The regex pattern is complex and would benefit from documentation explaining its components and the sequence format it validates.

Add a comment explaining the pattern, for example:

+    /**
+     * Pattern to validate SWIFT message sequence format:
+     * - Starts with an uppercase letter
+     * - Can be followed by optional sub-sequences:
+     *   - Separated by '/'
+     *   - Contains uppercase letter + optional digit
+     *   - Can have optional lowercase extensions
+     * Example valid sequences: "A", "A/B1", "A/B1a", "A/B1a2"
+     */
     private static final String SEQUENCE_PATTERN = "^[A-Z](?:/[A-Z][0-9]?(?:[a-z][0-9]?[A-Za-z0-9]*)?)*$";
📝 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.

Suggested change
private static final String SEQUENCE_PATTERN = "^[A-Z](?:/[A-Z][0-9]?(?:[a-z][0-9]?[A-Za-z0-9]*)?)*$";
/**
* Pattern to validate SWIFT message sequence format:
* - Starts with an uppercase letter
* - Can be followed by optional sub-sequences:
* - Separated by '/'
* - Contains uppercase letter + optional digit
* - Can have optional lowercase extensions
* Example valid sequences: "A", "A/B1", "A/B1a", "A/B1a2"
*/
private static final String SEQUENCE_PATTERN = "^[A-Z](?:/[A-Z][0-9]?(?:[a-z][0-9]?[A-Za-z0-9]*)?)*$";

Comment on lines 64 to 84
@Test
void testFromFieldNameInvalid() {
assertThrows(NullPointerException.class, () -> MtSequenceEnum.valueOf(null));
assertThrows(IllegalArgumentException.class, () -> MtSequenceEnum.valueOf("INVALID"));
assertThrows(IllegalArgumentException.class, () -> MtSequenceEnum.valueOf(""));
assertThrows(IllegalArgumentException.class, () -> MtSequenceEnum.valueOf("MT"));
assertThrows(IllegalArgumentException.class, () -> MtSequenceEnum.valueOf("MT999999"));
assertThrows(IllegalArgumentException.class, () -> MtSequenceEnum.valueOf("MTxxx"));
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Enhance invalid test cases with descriptive names and messages.

While the invalid test cases are comprehensive, they could be more descriptive and better organized.

Consider refactoring to:

-    @Test
-    void testFromFieldNameInvalid() {
-        assertThrows(NullPointerException.class, () -> MtSequenceEnum.valueOf(null));
-        assertThrows(IllegalArgumentException.class, () -> MtSequenceEnum.valueOf("INVALID"));
-        assertThrows(IllegalArgumentException.class, () -> MtSequenceEnum.valueOf(""));
-        assertThrows(IllegalArgumentException.class, () -> MtSequenceEnum.valueOf("MT"));
-        assertThrows(IllegalArgumentException.class, () -> MtSequenceEnum.valueOf("MT999999"));
-        assertThrows(IllegalArgumentException.class, () -> MtSequenceEnum.valueOf("MTxxx"));
-    }
+    @Test
+    void shouldThrowNPE_WhenValueOfNull() {
+        assertThrows(NullPointerException.class, 
+            () -> MtSequenceEnum.valueOf(null),
+            "Should throw NPE for null input");
+    }
+
+    @ParameterizedTest
+    @ValueSource(strings = {
+        "INVALID",  // Random string
+        "",         // Empty string
+        "MT",       // Incomplete MT number
+        "MT999999", // Invalid MT number
+        "MTxxx"     // Invalid format
+    })
+    void shouldThrowIAE_WhenInvalidFormat(String invalid) {
+        assertThrows(IllegalArgumentException.class, 
+            () -> MtSequenceEnum.valueOf(invalid),
+            String.format("Should throw IAE for invalid input: %s", invalid));
+    }
📝 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.

Suggested change
@Test
void testFromFieldNameInvalid() {
assertThrows(NullPointerException.class, () -> MtSequenceEnum.valueOf(null));
assertThrows(IllegalArgumentException.class, () -> MtSequenceEnum.valueOf("INVALID"));
assertThrows(IllegalArgumentException.class, () -> MtSequenceEnum.valueOf(""));
assertThrows(IllegalArgumentException.class, () -> MtSequenceEnum.valueOf("MT"));
assertThrows(IllegalArgumentException.class, () -> MtSequenceEnum.valueOf("MT999999"));
assertThrows(IllegalArgumentException.class, () -> MtSequenceEnum.valueOf("MTxxx"));
}
@Test
void shouldThrowNPE_WhenValueOfNull() {
assertThrows(NullPointerException.class,
() -> MtSequenceEnum.valueOf(null),
"Should throw NPE for null input");
}
@ParameterizedTest
@ValueSource(strings = {
"INVALID", // Random string
"", // Empty string
"MT", // Incomplete MT number
"MT999999", // Invalid MT number
"MTxxx" // Invalid format
})
void shouldThrowIAE_WhenInvalidFormat(String invalid) {
assertThrows(IllegalArgumentException.class,
() -> MtSequenceEnum.valueOf(invalid),
String.format("Should throw IAE for invalid input: %s", invalid));
}

@ptorres-prowide ptorres-prowide force-pushed the CU-86b1uerqp_Generar-un-enum-de-MTs-para-validar-sus-secuencias-y-paths_SRU2024 branch from b2b7472 to 10d1781 Compare November 15, 2024 17:42
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🧹 Outside diff range comments (1)
src/test/java/com/prowidesoftware/swift/model/field/FieldEnumTest.java (1)

Line range hint 51-51: Consider consistent method naming

For consistency with the new test methods, consider renaming:

  • testfromFieldNameInvalidtestFromFieldNameInvalid
  • testfromFieldNameEdgeCasestestFromFieldNameEdgeCases
-    void testfromFieldNameInvalid() {
+    void testFromFieldNameInvalid() {

-    void testfromFieldNameEdgeCases() {
+    void testFromFieldNameEdgeCases() {

Also applies to: 60-60

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Reviewing files that changed from the base of the PR and between b2b7472 and 10d1781.

⛔ Files ignored due to path filters (2)
  • src/generated/java/com/prowidesoftware/swift/model/field/FieldEnum.java is excluded by !**/generated/**
  • src/generated/java/com/prowidesoftware/swift/model/mt/MtSequenceEnum.java is excluded by !**/generated/**
📒 Files selected for processing (3)
  • CHANGELOG.md (1 hunks)
  • src/test/java/com/prowidesoftware/swift/model/field/FieldEnumTest.java (1 hunks)
  • src/test/java/com/prowidesoftware/swift/model/mt/MtSequenceEnumTest.java (1 hunks)
🧰 Additional context used
🪛 Markdownlint
CHANGELOG.md

6-6: Expected: 0; Actual: 2
Unordered list indentation

(MD007, ul-indent)

🔇 Additional comments (3)
src/test/java/com/prowidesoftware/swift/model/field/FieldEnumTest.java (1)

30-35: LGTM! Well-structured test methods

The individual test methods for field enum lookup are well-implemented with clear assertions and good test coverage.

Also applies to: 37-42, 44-49

src/test/java/com/prowidesoftware/swift/model/mt/MtSequenceEnumTest.java (1)

17-17: Consider preserving sequence order in tests

The tests use HashSet which doesn't preserve order. If the sequence order is significant for MT message processing, consider using LinkedHashSet or asserting the sequence list directly:

-        Set<String> expectedSequences = new HashSet<>(Arrays.asList("A", "B"));
+        List<String> expectedSequences = Arrays.asList("A", "B");

Or if using a Set is preferred but order matters:

-        Set<String> expectedSequences = new HashSet<>(Arrays.asList("A", "B"));
+        Set<String> expectedSequences = new LinkedHashSet<>(Arrays.asList("A", "B"));

Also applies to: 24-24, 31-32, 39-39

CHANGELOG.md (1)

6-6: LGTM! Clear and concise changelog entry.

The entry properly documents the addition of the new MtSequenceEnum feature, maintaining consistent style with other entries.

🧰 Tools
🪛 Markdownlint

6-6: Expected: 0; Actual: 2
Unordered list indentation

(MD007, ul-indent)

@@ -3,20 +3,48 @@
import static org.junit.jupiter.api.Assertions.*;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;

class FieldEnu5mTest {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix typo in class name

The class name contains a typo: FieldEnu5mTest. It should be FieldEnumTest to match the file name and follow Java naming conventions.

-class FieldEnu5mTest {
+class FieldEnumTest {
📝 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.

Suggested change
class FieldEnu5mTest {
class FieldEnumTest {

@zubri zubri changed the title Cu 86b1uerqp generar un enum de m ts para validar sus secuencias y paths sru2024 CU-86b1uerqp: generar un enum de MTs para validar sus secuencias y paths sru2024 Nov 15, 2024
@zubri zubri changed the title CU-86b1uerqp: generar un enum de MTs para validar sus secuencias y paths sru2024 CU-86b1uerqp: Add enum with all possible MT sequence paths SRU2024 Nov 15, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Reviewing files that changed from the base of the PR and between 10d1781 and 031f093.

📒 Files selected for processing (1)
  • src/test/java/com/prowidesoftware/swift/model/field/FieldEnumTest.java (1 hunks)

Comment on lines 30 to 48
@Test
void testFromFieldNameValid_11A() {
String fieldName = "11A";
FieldEnum expectedEnum = FieldEnum.F11A;
assertEquals(expectedEnum, FieldEnum.fromFieldName(fieldName));
}

@Test
void testFromFieldNameValid_29Q() {
String fieldName = "29Q";
FieldEnum expectedEnum = FieldEnum.F29Q;
assertEquals(expectedEnum, FieldEnum.fromFieldName(fieldName));
}

@Test
void testFromFieldNameValid_30K() {
String fieldName = "30K";
FieldEnum expectedEnum = FieldEnum.F30K;
assertEquals(expectedEnum, FieldEnum.fromFieldName(fieldName));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Consolidate valid fromFieldName tests using parameterization

Similar to the fieldName tests, these valid test cases could be parameterized for better maintainability. Additionally, consider adding more test cases to cover different field patterns.

Example refactor:

@ParameterizedTest
@CsvSource({
    "11A, F11A",
    "29Q, F29Q",
    "30K, F30K"
})
void testFromFieldNameValid(String fieldName, FieldEnum expectedEnum) {
    assertEquals(expectedEnum, FieldEnum.fromFieldName(fieldName));
}

Comment on lines 9 to 28
@Test
void testFieldName_F11A() {
FieldEnum field = FieldEnum.F11A;
String expectedName = "11A";
assertEquals(expectedName, field.fieldName());
}

@Test
void testFieldName_F29Q() {
FieldEnum field = FieldEnum.F29Q;
String expectedName = "29Q";
assertEquals(expectedName, field.fieldName());
}

@Test
void testFieldName_F30K() {
FieldEnum field = FieldEnum.F30K;
String expectedName = "30K";
assertEquals(expectedName, field.fieldName());
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

💡 Codebase verification

Expand test coverage for fieldName() method

The fieldName() implementation is straightforward (removes leading 'F'), but test coverage is insufficient. Recommended test cases:

  • Regular fields with different number patterns (F11A, F111A)
  • Fields with varying letter suffixes (F12A through F12F)
  • Edge cases like longest and shortest field names

Example parameterized test structure:

@ParameterizedTest
@CsvSource({
    "F11A, 11A",   // Basic case
    "F111A, 111A", // Three-digit number
    "F12A, 12A",   // Start of sequence
    "F12F, 12F",   // End of sequence
    "F29Q, 29Q",   // Current test case
    "F30K, 30K"    // Current test case
})
void testFieldName(FieldEnum field, String expectedName) {
    assertEquals(expectedName, field.fieldName());
}
🔗 Analysis chain

Consider using parameterized tests for better maintainability

While individual test methods are clear, they follow an identical pattern. Consider using JUnit's @ParameterizedTest to reduce code duplication and make it easier to add more test cases.

Example refactor:

@ParameterizedTest
@CsvSource({
    "F11A, 11A",
    "F29Q, 29Q",
    "F30K, 30K"
})
void testFieldName(FieldEnum field, String expectedName) {
    assertEquals(expectedName, field.fieldName());
}

Test coverage for fieldName() is insufficient (3/701 fields tested)

The current test suite only covers 3 field enums (F11A, F29Q, F30K) out of 701 available fields. This represents less than 0.5% of the total fields. Consider:

  • Expanding test coverage to include more field variations (e.g., F11R, F11S, F11T, F12A)
  • Adding edge cases and boundary values
  • Using parameterized tests for better maintainability and easier coverage expansion
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check total number of field enums to assess test coverage

# Count total number of field enums
rg "^    F\d+" src/generated/java/com/prowidesoftware/swift/model/field/FieldEnum.java | wc -l

# Show some examples of untested fields
rg "^    F\d+" src/generated/java/com/prowidesoftware/swift/model/field/FieldEnum.java | head -n 5

Length of output: 251


Script:

#!/bin/bash
# Check if there are any special field names or patterns that should be tested
rg "^    F\d+[A-Z]\d*" src/generated/java/com/prowidesoftware/swift/model/field/FieldEnum.java | head -n 10

# Check implementation of fieldName() to understand if there are special cases
ast-grep --pattern 'public String fieldName() {
  $$$
}'

Length of output: 636

@ptorres-prowide ptorres-prowide force-pushed the CU-86b1uerqp_Generar-un-enum-de-MTs-para-validar-sus-secuencias-y-paths_SRU2024 branch from 031f093 to a09a018 Compare November 15, 2024 21:12
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Outside diff range comments (2)
src/test/java/com/prowidesoftware/swift/model/field/FieldEnumTest.java (2)

Line range hint 9-28: Consider using parameterized tests and expanding coverage

While the individual test methods are clear, they follow an identical pattern that could be simplified using JUnit's @ParameterizedTest. This would make the tests more maintainable and make it easier to add more test cases. Additionally, testing only 3 out of 701 field types provides minimal coverage.

Consider refactoring to use parameterized tests:

@ParameterizedTest
@CsvSource({
    "F11A, 11A",
    "F29Q, 29Q",
    "F30K, 30K",
    // Add more test cases here
    "F22A, 22A",   // Common field type
    "F95P, 95P",   // High number field
    "F50H, 50H"    // Mid-range field
})
void testFieldName(FieldEnum field, String expectedName) {
    assertEquals(expectedName, field.fieldName());
}

Line range hint 30-49: Consolidate fromFieldName tests using parameterization

Similar to the fieldName tests, these valid test cases follow an identical pattern and could be parameterized for better maintainability.

Consider refactoring to:

@ParameterizedTest
@CsvSource({
    "11A, F11A",
    "29Q, F29Q",
    "30K, F30K",
    // Add more test cases here
    "22A, F22A",   // Common field type
    "95P, F95P",   // High number field
    "50H, F50H"    // Mid-range field
})
void testFromFieldNameValid(String fieldName, FieldEnum expectedEnum) {
    assertEquals(expectedEnum, FieldEnum.fromFieldName(fieldName));
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Reviewing files that changed from the base of the PR and between 031f093 and a09a018.

⛔ Files ignored due to path filters (2)
  • src/generated/java/com/prowidesoftware/swift/model/field/FieldEnum.java is excluded by !**/generated/**
  • src/generated/java/com/prowidesoftware/swift/model/mt/MtSequenceEnum.java is excluded by !**/generated/**
📒 Files selected for processing (2)
  • CHANGELOG.md (1 hunks)
  • src/test/java/com/prowidesoftware/swift/model/field/FieldEnumTest.java (3 hunks)
🧰 Additional context used
🪛 Markdownlint
CHANGELOG.md

8-8: Expected: 0; Actual: 2
Unordered list indentation

(MD007, ul-indent)

🔇 Additional comments (2)
src/test/java/com/prowidesoftware/swift/model/field/FieldEnumTest.java (1)

Line range hint 51-71: LGTM! Good edge case coverage

The edge case tests thoroughly cover invalid inputs, and the testAllEnumValues method provides a good safety net by verifying all enum values.

CHANGELOG.md (1)

8-8: ⚠️ Potential issue

Remove duplicate bullet point.

The bullet point about MtSequenceEnum appears twice in version 9.5.3. Remove the duplicate entry to maintain a clean changelog.

Apply this diff to remove the duplicate:

  * Added new `MtSequenceEnum` with all the available inner sequences of specific MT schemas
  * Added `isSystemMessage()` to SwiftMessage to check if the message is a category 0 message (010. 011, etc...)
- * Added new `MtSequenceEnum` with all the available inner sequences of specific MT schemas

Likely invalid or redundant comment.

🧰 Tools
🪛 Markdownlint

8-8: Expected: 0; Actual: 2
Unordered list indentation

(MD007, ul-indent)

@zubri zubri merged commit b8ba86f into SRU2024 Nov 15, 2024
3 checks passed
@zubri zubri deleted the CU-86b1uerqp_Generar-un-enum-de-MTs-para-validar-sus-secuencias-y-paths_SRU2024 branch November 15, 2024 22:57
zubri added a commit that referenced this pull request Nov 19, 2024
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants