Skip to content

Commit

Permalink
Merge #558 from remote-tracking branch 'origin/548-fixMarcLeaderInent…
Browse files Browse the repository at this point in the history
…ationWhenUsingType'
  • Loading branch information
dr0i committed Sep 23, 2024
2 parents 76b7a06 + 8414f02 commit edb3a8d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ public void literal(final String name, final String value) {
if (name.equals(Marc21EventNames.MARCXML_TYPE_LITERAL)) {
if (value != null) {
builder.insert(recordAttributeOffset, String.format(ATTRIBUTE_TEMPLATE, name, value));
recordLeaderOffset = builder.length();
}
}
else if (!appendLeader(name, value)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,21 @@ public void issue336_createRecordWithTopLevelLeader_dummy() {
assertEquals(expected, actual);
}

@Test
public void issue548_createRecordWithTypeAttributeInRecordTagAndLeader() {
encoder.startRecord(RECORD_ID);
encoder.literal("type", "Bibliographic");
encoder.startEntity(Marc21EventNames.LEADER_ENTITY);
encoder.literal(Marc21EventNames.LEADER_ENTITY, "dummy");
encoder.endEntity();
encoder.endRecord();
encoder.closeStream();
String expected = XML_DECLARATION + XML_ROOT_OPEN + "<marc:record type=\"Bibliographic\">" +
"<marc:leader>dummy</marc:leader></marc:record>" + XML_MARC_COLLECTION_END_TAG;
String actual = resultCollector.toString();
assertEquals(expected, actual);
}

@Test
public void issue336_createRecordWithTopLevelLeader_defaultMarc21Xml() {
issue336_createRecordWithTopLevelLeader(encoder, "00000naa a2200000uc 4500");
Expand Down

0 comments on commit edb3a8d

Please sign in to comment.