From a7833cc0fc43f71c3ca28ce65f0c1f69d8b648d4 Mon Sep 17 00:00:00 2001 From: Kayvan Tehrani Date: Sat, 27 Apr 2024 15:42:38 +0330 Subject: [PATCH] adding Oman country IBAN (#135) * adding Oman country IBAN * modify tests to cover the random seed --- src/main/java/org/iban4j/bban/BbanStructure.java | 3 +++ src/test/java/org/iban4j/IbanTest.java | 16 ++++++++-------- src/test/java/org/iban4j/TestDataHelper.java | 6 ++++-- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/iban4j/bban/BbanStructure.java b/src/main/java/org/iban4j/bban/BbanStructure.java index 4678209..0f39825 100644 --- a/src/main/java/org/iban4j/bban/BbanStructure.java +++ b/src/main/java/org/iban4j/bban/BbanStructure.java @@ -21,6 +21,7 @@ import java.util.EnumMap; import java.util.List; import java.util.Optional; + import org.iban4j.CountryCode; /** @@ -537,6 +538,8 @@ private BbanStructure(final BbanStructureEntry... entries) { BbanStructureEntry.bankCode(4, 'n'), BbanStructureEntry.branchCode(4, 'n'), BbanStructureEntry.accountNumber(13, 'c'))); + + structures.put(CountryCode.OM, new BbanStructure(BbanStructureEntry.bankCode(3, 'n'), BbanStructureEntry.accountNumber(16, 'c'))); } /** diff --git a/src/test/java/org/iban4j/IbanTest.java b/src/test/java/org/iban4j/IbanTest.java index cd9dedf..89cf06c 100644 --- a/src/test/java/org/iban4j/IbanTest.java +++ b/src/test/java/org/iban4j/IbanTest.java @@ -26,7 +26,9 @@ import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertThrows; + import java.util.Random; + import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -292,10 +294,9 @@ public void ibanConstructionRandom() { @Test public void ibanConstructionSeeded() { - assertAll( - () -> assertIbanUtilRandomWithSeedEquals("GL41 1918 0836 9682 13", 1), - () -> assertIbanUtilRandomWithSeedEquals("FR17 0679 7098 8804 5NYW S75F D50", 2), - () -> assertIbanUtilRandomWithSeedEquals("EG45 0882 2804 0304 6660 9507 6091 3", 3) + assertAll(() -> assertIbanUtilRandomWithSeedEquals("TN58 1908 31HJ ENIS JS33 9QZG", 1), + () -> assertIbanUtilRandomWithSeedEquals("LV92 QKBB C1OY WHST MPQA 7", 2), + () -> assertIbanUtilRandomWithSeedEquals("JO53 WQSM 2804 ERG8 WOUQ NLYT EEL7 3J", 3) ); } @@ -313,10 +314,9 @@ private void assertIbanUtilRandomWithSeedEquals( @Test public void ibanBuilderConstructionSeeded() { - assertAll( - () -> assertIbanBuilderRandomWithSeedEquals("GL41 1918 0836 9682 13", 1), - () -> assertIbanBuilderRandomWithSeedEquals("FR17 0679 7098 8804 5NYW S75F D50", 2), - () -> assertIbanBuilderRandomWithSeedEquals("EG45 0882 2804 0304 6660 9507 6091 3", 3) + assertAll(() -> assertIbanBuilderRandomWithSeedEquals("TN58 1908 31HJ ENIS JS33 9QZG", 1), + () -> assertIbanBuilderRandomWithSeedEquals("LV92 QKBB C1OY WHST MPQA 7", 2), + () -> assertIbanBuilderRandomWithSeedEquals("JO53 WQSM 2804 ERG8 WOUQ NLYT EEL7 3J", 3) ); } diff --git a/src/test/java/org/iban4j/TestDataHelper.java b/src/test/java/org/iban4j/TestDataHelper.java index d32bc30..cce8927 100644 --- a/src/test/java/org/iban4j/TestDataHelper.java +++ b/src/test/java/org/iban4j/TestDataHelper.java @@ -602,8 +602,10 @@ public static Collection getIbanData() { .countryCode(CountryCode.CV) .bankCode("0002") .branchCode("0000") - .accountNumber("0311180710148") - .build(), "CV64000200000311180710148"} + .accountNumber("0311180710148").build(), "CV64000200000311180710148" }, { new Iban.Builder().countryCode(CountryCode.OM) + .bankCode("028") + .accountNumber("12345678901") + .leftPadding(true).build(), "OM040280000012345678901" } }); }