Skip to content

Commit

Permalink
WIP Junit scenarios
Browse files Browse the repository at this point in the history
  • Loading branch information
fernando-prowide authored and zubri committed Mar 25, 2024
1 parent d38b371 commit 4fea0c1
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ private static Narrative parseFormat(

if (supportsSupplement) {
firstSupplementAdded = addNarrativeSupplement(firstSupplementAdded, text, structured);
} else if (StringUtils.isNotEmpty(textWithoutBankCode)) {
} else if (textWithoutBankCode != null) {
structured.addNarrativeFragment(textWithoutBankCode);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,15 +215,21 @@ public void testFormat2_5() {

/**
* valid input
* 1 Fragment Empty
* 2 Fragments with values
*/
@Test
public void testFormat2_6() {
String v = "/RETN/\n" + "/BE02/UNKNOWN BENEFICIARY\n" + "/MREF/0511030094000014";
Narrative n = NarrativeResolver.parse(new Field72(v));
assertEquals(3, n.getStructured().size());
assertNull(n.getStructured("RETN").getNarrative());
assertEquals("", n.getStructured("RETN").getNarrative());
assertEquals("UNKNOWN BENEFICIARY", n.getStructured("BE02").getNarrative());
assertEquals("0511030094000014", n.getStructured("MREF").getNarrative());
// Check Fragments
assertEquals(1, n.getStructured("RETN").getNarrativeFragments().size());
assertEquals(1, n.getStructured("BE02").getNarrativeFragments().size());
assertEquals(1, n.getStructured("MREF").getNarrativeFragments().size());
assertNull(n.getUnstructured());
}

Expand All @@ -234,12 +240,48 @@ public void testFormat2_6() {
public void testFormat2_7() {
String v = "/RETN/\n" + "//UNKNOWN BENEFICIARY\n" + "/MREF/0511030094000014";
Narrative n = NarrativeResolver.parse(new Field72(v));
assertEquals(2, n.getStructured().size());
assertEquals(2, n.getStructured().size()); // This count only the CodeWords
assertEquals("", n.getStructured("RETN").getNarrativeFragments().get(0));
assertEquals(
"UNKNOWN BENEFICIARY",
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());
assertNull(n.getUnstructured());
}

/**
* valid input
*/
@Test
public void testFormat11() {
// PW-1812 - Invalid parsing for field 72 in prowide form
String v = "/ACC/\n"
+ "//ABU DHABI ISLAMIC BANK DUBAI INTE\n"
+ "//RNET CITY BRANCH, P.O. BOX 46000,\n"
+ "//DUBAI, UAE\n"
+ "//UNITED ARAB EMIRATES";
Narrative n = NarrativeResolver.parse(new Field72(v));
assertEquals(1, n.getStructured().size()); // This count only the CodeWords
assertEquals(5, n.getStructured("ACC").getNarrativeFragments().size());
assertEquals("", n.getStructured("ACC").getNarrativeFragments().get(0));
assertEquals(
"ABU DHABI ISLAMIC BANK DUBAI INTE",
n.getStructured("ACC").getNarrativeFragments().get(1));
assertEquals(
"RNET CITY BRANCH, P.O. BOX 46000,",
n.getStructured("ACC").getNarrativeFragments().get(2));
assertEquals(
"DUBAI, UAE", n.getStructured("ACC").getNarrativeFragments().get(3));
assertEquals(
"UNITED ARAB EMIRATES",
n.getStructured("ACC").getNarrativeFragments().get(4));
}

/**
* valid input
*/
Expand All @@ -248,7 +290,7 @@ public void testFormat2_8() {
String v = "/RETN/\n" + "/ /UNKNOWN BENEFICIARY\n" + "/MREF/0511030094000014\n" + "//WELL KNOWN BENEFICIARY";
Narrative n = NarrativeResolver.parse(new Field72(v));
assertEquals(1, n.getStructured().size());
assertNull(n.getStructured("RETN").getNarrative());
assertEquals("", n.getStructured("RETN").getNarrative());
assertEquals("/ /UNKNOWN BENEFICIARY /MREF/0511030094000014 //WELL KNOWN BENEFICIARY", n.getUnstructured(" "));
}

Expand Down Expand Up @@ -292,6 +334,19 @@ public void testFormat2_11() {
assertEquals("FREE ADDITIONAL NARRATIVE CONTINUATION", n.getUnstructured(" "));
}

/**
* valid input
*/
@Test
public void testFormat2_12() {
String v = "/ACC/ \n" + "//CONTINUATION OF MYCODE";
// 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(" "));
}

/*
* FORMAT 3
* Line 1: /8c/[3!a13d][additional information] (Code)(Currency)(Amount)(Narrative)
Expand Down

0 comments on commit 4fea0c1

Please sign in to comment.