Skip to content

Commit

Permalink
Resolve #282: merge branch 'eberhardtj-fix-issue-278'
Browse files Browse the repository at this point in the history
  • Loading branch information
cboehme committed Dec 19, 2018
2 parents 5e90310 + 25f2da3 commit 4d0df22
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,9 @@ private void startField(final String name) {

@Override
public void endEntity() {
builder.endDataField();
if (state.equals(State.IN_FIELD_ENTITY)) {
builder.endDataField();
}
state = State.IN_RECORD;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package org.metafacture.biblio.marc21;

import static org.metafacture.biblio.marc21.Marc21EventNames.LEADER_ENTITY;
import static org.metafacture.biblio.marc21.Marc21EventNames.RECORD_STATUS_LITERAL;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.matches;
import static org.mockito.Mockito.verify;
Expand All @@ -35,8 +37,6 @@
*/
public final class Marc21EncoderTest {

private static final String LEADER_LITERAL = "leader";

private Marc21Encoder marc21Encoder;

@Mock
Expand Down Expand Up @@ -102,4 +102,15 @@ public void issue231ShouldIgnoreTypeLiterals() {
verify(receiver).process(any(String.class));
}

@Test
public void issue278ShouldNotFailWhenProcessingLeaderEntity() {
marc21Encoder.startRecord("");
marc21Encoder.startEntity(LEADER_ENTITY);
marc21Encoder.literal(RECORD_STATUS_LITERAL, "a");
marc21Encoder.endEntity();
marc21Encoder.endRecord();

verify(receiver).process(any(String.class));
}

}

0 comments on commit 4d0df22

Please sign in to comment.