diff --git a/src/main/java/com/prowidesoftware/swift/model/field/NarrativeResolver.java b/src/main/java/com/prowidesoftware/swift/model/field/NarrativeResolver.java index 0613645e2..9f6f9b93a 100644 --- a/src/main/java/com/prowidesoftware/swift/model/field/NarrativeResolver.java +++ b/src/main/java/com/prowidesoftware/swift/model/field/NarrativeResolver.java @@ -169,7 +169,14 @@ private static Narrative parseFormat( if (supportsSupplement) { firstSupplementAdded = addNarrativeSupplement(firstSupplementAdded, text, structured); } else if (textWithoutBankCode != null) { - structured.addNarrativeFragment(textWithoutBankCode); + if (supportsCountry) { + if (!textWithoutBankCode.isEmpty()) { + structured.addNarrativeFragment( + textWithoutBankCode); // structured.addNarrativeFragment(null); + } + } else { + structured.addNarrativeFragment(textWithoutBankCode); + } } narrative.add(structured); diff --git a/src/test/java/com/prowidesoftware/swift/model/field/NarrativeResolverTest.java b/src/test/java/com/prowidesoftware/swift/model/field/NarrativeResolverTest.java index 621e7d750..cdc718fb7 100644 --- a/src/test/java/com/prowidesoftware/swift/model/field/NarrativeResolverTest.java +++ b/src/test/java/com/prowidesoftware/swift/model/field/NarrativeResolverTest.java @@ -215,8 +215,8 @@ public void testFormat2_5() { /** * valid input - * 1 Fragment Empty - * 2 Fragments with values + * 1 Fragment Empty 1 codeword + * 2 Fragments with values 2 Codewords */ @Test public void testFormat2_6() { @@ -235,6 +235,8 @@ public void testFormat2_6() { /** * valid input + * 1 Fragment Empty + 1 Non empty value, 1 codeword + * 1 Non empty value, 1 codeword */ @Test public void testFormat2_7() { @@ -247,7 +249,6 @@ public void testFormat2_7() { n.getStructured("RETN").getNarrativeFragments().get(1)); assertEquals("UNKNOWN BENEFICIARY", n.getStructured("RETN").getNarrative()); assertEquals("0511030094000014", n.getStructured("MREF").getNarrative()); - assertEquals("0511030094000014", n.getStructured("MREF").getNarrative()); // Check Fragments assertEquals(2, n.getStructured("RETN").getNarrativeFragments().size()); assertEquals(1, n.getStructured("MREF").getNarrativeFragments().size()); @@ -256,6 +257,7 @@ public void testFormat2_7() { /** * valid input + * 1 Fragment Empty + 4 Non empty value, 1 codeword */ @Test public void testFormat11() { @@ -343,8 +345,10 @@ public void testFormat2_12() { // Fragmento uno es . (White spaces detectados luego del /ACC/) Narrative n = NarrativeResolver.parse(new Field77J(v)); assertEquals(1, n.getStructured().size()); - assertEquals("FOO BAR CONTINUATION OF MYCODE", n.getStructured("MYCODE").getNarrative(" ")); - assertEquals("FREE ADDITIONAL NARRATIVE CONTINUATION", n.getUnstructured(" ")); + assertEquals(" ", n.getStructured("ACC").getNarrativeFragments().get(0)); + assertEquals( + "CONTINUATION OF MYCODE", + n.getStructured("ACC").getNarrativeFragments().get(1)); } /* @@ -559,7 +563,8 @@ public void testFormat3Score_6() { assertNull(s.getCountry()); assertNull(s.getCurrency()); assertNull(s.getAmount()); - assertTrue(s.getNarrativeFragments().isEmpty()); + assertEquals(1, s.getNarrativeFragments().size()); + assertTrue(s.getNarrative().isEmpty()); assertNull(n.getUnstructured()); }