Skip to content

Commit

Permalink
CU-86b1uerqp_Generar-un-enum-de-MTs-para-validar-sus-secuencias-y-paths
Browse files Browse the repository at this point in the history
  • Loading branch information
ptorres-prowide committed Nov 8, 2024
1 parent 69557a4 commit a976493
Show file tree
Hide file tree
Showing 3 changed files with 174 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#### 9.4.18 - October 2024
* Added new `FieldEnum` with all the available field names
* Code security improvements as per CodeQL recommendations
* Added new `MtSequenceInfoEnum` with all the available inner sequences of specific MT schemas

#### 9.4.17 - June 2024
* (PW-1913) Added IBAN validation for Egypt local account structure
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
/*
* Copyright 2006-2024 Prowide
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.prowidesoftware.swift.model.mt;

/**
* Enumeration representing all possible sequence paths for each MT (Message Type) schema.
* Each constant in this enumeration corresponds to a specific MT schema, identified by its
* sequence paths as a comma-separated string (CSV) for SRU 2023.
*
* <p>For example, the MT508 message type may have sequence paths such as "A", "A/A1", "B", "B/B1", and "C",
* which would be represented as the CSV string "A,A/A1,B,B/B1,C".
*
* @since 9.4.18
*/
public enum MtSequenceInfoEnum {

MTMT101("A,B"),
MTMT102("A,B,C"),
MTMT102_STP("A,B,C"),
MTMT104("A,B,C"),
MTMT107("A,B,C"),
MTMT202COV("A,B"),
MTMT204("A,B"),
MTMT205COV("A,B"),
MTMT300("A,B,B/B1,B/B2,C,D,D/D1,E,E/E1,E/E1/E1a,E/E1/E1a/E1a1,F"),
MTMT304("A,B,B/B1,B/B2,C,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1/D1a,D/D1/D1b,D/D2,D/D2/D2a,D/D2/D2b,E"),
MTMT567("A,A/A1,A/A2,A/A2/A2a,B,C"),
MTMT568("A,A/A1,B,B/B1,C"),
MTMT569("A,A/A1,A/A2,B,C,C/C1,C/C1/C1a,C/C1/C1a/C1a1,C/C1/C1a/C1a1/C1a1A,D"),
MTMT575("A,A/A1,B,B/B1,B/B1/B1a,B/B1/B1a/B1a1,B/B1/B1a/B1a2,B/B1/B1a/B1a3,B/B1/B1a/B1a4,C,C/C1,C/C2,C/C2/C2a,D"),
MTMT576("A,A/A1,B,B/B1,B/B2,B/B2/B2a,B/B2/B2b,B/B2/B2c,C"),
MTMT578("A,A/A1,B,B/B1,C,C/C1,D,E,E/E1,E/E2,E/E3,F"),
MTMT586("A,A/A1,B,B/B1,B/B2,B/B3,B/B4,B/B4/B4a,B/B5,B/B6,B/B6/B6a,B/B6/B6b,C"),
MTMT600("A,B,C,D,D/D1,D/D1/D1a,D/D1/D1a/D1a1"),
MTMT601("A,B,B/B1,B/B1/B1a,B/B1/B1a/B1a1"),
MTMT620("A,B,C,D,E,F,G,G/G1,G/G2,H"),
MTMT670("A,A/A1,A/A2,B,B/B1,B/B2,C"),
MTMT671("A,A/A1,B,B/B1,B/B2,C"),
MTMT760("A,B,C"),
MTMT767("A,B,C");

private final String sequencesInfo;

MtSequenceInfoEnum(String sequencesInfo) {
this.sequencesInfo = sequencesInfo;
}

/**
* Returns the sequence paths for this MT schema.
* Each sequence path represents a hierarchical structure within the MT schema.
*
* @return A comma-separated string of sequence paths.
*
*/
public String getSequencesInfo() {
return sequencesInfo;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.prowidesoftware.swift.model.mt;

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 MtSequenceInfoEnumTest {

@ParameterizedTest
@CsvSource({
"MTMT101, 'A,B'",
"MTMT102, 'A,B,C'",
"MTMT300, 'A,B,B/B1,B/B2,C,D,D/D1,E,E/E1,E/E1/E1a,E/E1/E1a/E1a1,F'",
"MTMT508, 'A,A/A1,B,B/B1,C'"
})
void testGetSequencesInfo(MtSequenceInfoEnum sequenceInfo, String expectedSequences) {
assertEquals(expectedSequences, sequenceInfo.getSequencesInfo());
}

@ParameterizedTest
@CsvSource({"MTMT101, MTMT101", "MTMT102, MTMT102", "MTMT508, MTMT508"})
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.getSequencesInfo(), "Sequence info should not be null");
assertFalse(sequenceInfo.getSequencesInfo().isEmpty(), "Sequence info should not be empty");
}
}
}

0 comments on commit a976493

Please sign in to comment.