Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(#236): drop assumption that indentation doesn't change since this… #237

Merged
merged 1 commit into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,7 @@ protected String populateCodeList(BufferedReader reader, CodeList codeList) thro
line = readUntilCode(reader);
Matcher firstCodeMatcher = CODE.matcher(line);
firstCodeMatcher.matches();

int expectedIndentLength = firstCodeMatcher.group(1).length();
while (line != null && !line.matches(ELEMENT_SEPARATOR)) {
Matcher codeMatcher = CODE.matcher(line);
Expand All @@ -623,7 +624,7 @@ protected String populateCodeList(BufferedReader reader, CodeList codeList) thro
}

protected boolean isCode(Matcher codeMatcher, int expectedIndentLength) {
return codeMatcher.matches() && codeMatcher.group(1).length() == expectedIndentLength;
return codeMatcher.matches() && codeMatcher.group(1).length() <= expectedIndentLength;
}

protected String readUntilCode(BufferedReader reader) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,20 @@

public class D96ADirectoryParserTest {
@Test
@DisplayName("should extract legacy D96A code list values correctly")
public void checkThatD96ACodeListsAreReadCorrectlyForLegacyD96A() throws Exception {
@DisplayName("should extract D96A code list values correctly")
public void checkThatD96ACodeListsAreReadCorrectly() throws Exception {
InputStream inputStream = getClass().getResourceAsStream("/d96a.zip");
ZipInputStream zipInputStream = new ZipInputStream(inputStream);
DirectoryParser d96AReader = new D96ADirectoryParser(zipInputStream, false, false);

Map<String, byte[]> definitionFiles = d96AReader.getDefinitionFiles();
assertFalse(definitionFiles.get("uncl") == null || definitionFiles.get("uncl").length == 0);

final Component component = getSimpleDataElement(d96AReader, "5125");
assertEquals(9, component.getCodeList().getCodes().size());
final Component component5125 = getSimpleDataElement(d96AReader, "5125");
assertEquals(9, component5125.getCodeList().getCodes().size());

final Component component6063 = getSimpleDataElement(d96AReader, "6063");
assertEquals(180, component6063.getCodeList().getCodes().size());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,6 @@ public void parseD08A() throws Exception {
d08AReader_shortnames = new UnEdifactDirectoryParser(zipInputStream, false, true);
}

public void _disabled_test_D08A_Messages() throws IOException, EdiParseException {
test("BANSTA", d08AReader_longnames);
test("CASRES", d08AReader_longnames);
test("INVOIC", d08AReader_longnames);
test("PAYMUL", d08AReader_longnames);
test("TPFREP", d08AReader_longnames);
}

@Test
@DisplayName("should support long messages names")
public void test_getMessagesLongName() throws IOException {
Expand Down