Skip to content

Commit

Permalink
New version of NarrativeResolver now supports structuredNarrative val…
Browse files Browse the repository at this point in the history
…ues = ""
  • Loading branch information
fernando-prowide authored and zubri committed Mar 25, 2024
1 parent 4fea0c1 commit d654632
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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() {
Expand All @@ -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());
Expand All @@ -256,6 +257,7 @@ public void testFormat2_7() {

/**
* valid input
* 1 Fragment Empty + 4 Non empty value, 1 codeword
*/
@Test
public void testFormat11() {
Expand Down Expand Up @@ -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));
}

/*
Expand Down Expand Up @@ -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());
}

Expand Down

0 comments on commit d654632

Please sign in to comment.