From 1b9e727ab5669aa9b81f4fe4da6d317242239cf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jero=CC=81nimo=20Matavel?= <49800473+Jeronimo-MZ@users.noreply.github.com> Date: Tue, 30 Jul 2024 17:38:51 +0200 Subject: [PATCH] Add MZ (Mozambique) IBAN validation (#144) * feat: Add MZ Bban Structure * test: Add MZ Bban Structure test sample * test: change IBANs used for random with seed tests --- src/main/java/org/iban4j/bban/BbanStructure.java | 8 +++++++- src/test/java/org/iban4j/IbanTest.java | 12 ++++++------ src/test/java/org/iban4j/TestDataHelper.java | 10 ++++++++++ 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/iban4j/bban/BbanStructure.java b/src/main/java/org/iban4j/bban/BbanStructure.java index d074ef2..382f0ab 100644 --- a/src/main/java/org/iban4j/bban/BbanStructure.java +++ b/src/main/java/org/iban4j/bban/BbanStructure.java @@ -388,7 +388,13 @@ public class BbanStructure { BbanStructureEntry.bankCode(6, 'c'), BbanStructureEntry.branchCode(2, 'n'), BbanStructureEntry.accountNumber(18, 'c'))); - + structures.put( + CountryCode.MZ, + new BbanStructure( + BbanStructureEntry.bankCode(4, 'n'), + BbanStructureEntry.branchCode(4, 'n'), + BbanStructureEntry.accountNumber(11, 'n'), + BbanStructureEntry.nationalCheckDigit(2, 'n'))); structures.put( CountryCode.NL, new BbanStructure( diff --git a/src/test/java/org/iban4j/IbanTest.java b/src/test/java/org/iban4j/IbanTest.java index 9900187..0c04224 100644 --- a/src/test/java/org/iban4j/IbanTest.java +++ b/src/test/java/org/iban4j/IbanTest.java @@ -301,9 +301,9 @@ public void ibanConstructionRandom() { @Test public void ibanConstructionSeeded() { assertAll( - () -> assertIbanUtilRandomWithSeedEquals("GI33 XNNK KKDA PM6A HNQF XLK", 1), - () -> assertIbanUtilRandomWithSeedEquals("CZ17 0679 0988 8783 6940 3497", 2), - () -> assertIbanUtilRandomWithSeedEquals("NC29 0882 8280 41ER G8WO UQNL Y52", 3)); + () -> assertIbanUtilRandomWithSeedEquals("BY38 LPL2 0836 1HJE NISJ S339 QZGT", 1), + () -> assertIbanUtilRandomWithSeedEquals("IE70 QKBB 0988 8722 1186 81", 2), + () -> assertIbanUtilRandomWithSeedEquals("MC38 0882 8280 41ER G8WO UQNL Y52", 3)); } private void assertIbanUtilRandomWithSeedEquals( @@ -321,9 +321,9 @@ private void assertIbanUtilRandomWithSeedEquals( @Test public void ibanBuilderConstructionSeeded() { assertAll( - () -> assertIbanBuilderRandomWithSeedEquals("GI33 XNNK KKDA PM6A HNQF XLK", 1), - () -> assertIbanBuilderRandomWithSeedEquals("CZ17 0679 0988 8783 6940 3497", 2), - () -> assertIbanBuilderRandomWithSeedEquals("NC29 0882 8280 41ER G8WO UQNL Y52", 3)); + () -> assertIbanBuilderRandomWithSeedEquals("BY38 LPL2 0836 1HJE NISJ S339 QZGT", 1), + () -> assertIbanBuilderRandomWithSeedEquals("IE70 QKBB 0988 8722 1186 81", 2), + () -> assertIbanBuilderRandomWithSeedEquals("MC38 0882 8280 41ER G8WO UQNL Y52", 3)); } @Test diff --git a/src/test/java/org/iban4j/TestDataHelper.java b/src/test/java/org/iban4j/TestDataHelper.java index 2703407..e3de7b5 100644 --- a/src/test/java/org/iban4j/TestDataHelper.java +++ b/src/test/java/org/iban4j/TestDataHelper.java @@ -520,6 +520,16 @@ public static Collection getIbanData() { .build(), "NC551234512345123456789AB13" }, + { + new Iban.Builder() + .countryCode(CountryCode.MZ) + .bankCode("0003") + .branchCode("0108") + .accountNumber("00163671023") + .nationalCheckDigit("71") + .build(), + "MZ59000301080016367102371" + }, { new Iban.Builder() .countryCode(CountryCode.NL)