-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
src/main/java/de/gwdg/metadataqa/marc/definition/tags/bltags/Tag592.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package de.gwdg.metadataqa.marc.definition.tags.bltags; | ||
|
||
import de.gwdg.metadataqa.marc.definition.Cardinality; | ||
import de.gwdg.metadataqa.marc.definition.DataFieldDefinition; | ||
import de.gwdg.metadataqa.marc.definition.Indicator; | ||
|
||
/** | ||
* National Bibliography Issue Number | ||
*/ | ||
public class Tag592 extends DataFieldDefinition { | ||
|
||
private static Tag592 uniqueInstance; | ||
|
||
private Tag592() { | ||
initialize(); | ||
postCreation(); | ||
} | ||
|
||
public static Tag592 getInstance() { | ||
if (uniqueInstance == null) | ||
uniqueInstance = new Tag592(); | ||
return uniqueInstance; | ||
} | ||
|
||
private void initialize() { | ||
|
||
tag = "592"; | ||
label = "Collaboration Note"; | ||
mqTag = "collaborationNote"; | ||
cardinality = Cardinality.Repeatable; | ||
// descriptionUrl = "https://www.loc.gov/marc/bibliographic/bd037.html"; | ||
// setCompilanceLevels("O"); | ||
|
||
ind1 = new Indicator(); | ||
ind2 = new Indicator(); | ||
|
||
setSubfieldsWithCardinality( | ||
"a", "Collaboration note", "NR" | ||
); | ||
|
||
getSubfield("a") | ||
.setMqTag("collaborationNote"); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
src/test/java/de/gwdg/metadataqa/marc/definition/tags/bltags/Tag592Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package de.gwdg.metadataqa.marc.definition.tags.bltags; | ||
|
||
import de.gwdg.metadataqa.marc.DataField; | ||
import de.gwdg.metadataqa.marc.MarcRecord; | ||
import de.gwdg.metadataqa.marc.definition.MarcVersion; | ||
import org.junit.Test; | ||
|
||
import static junit.framework.TestCase.assertFalse; | ||
import static junit.framework.TestCase.assertTrue; | ||
|
||
public class Tag592Test { | ||
|
||
@Test | ||
public void testValidFields() { | ||
validField("a", "ARGUS collaboration."); | ||
} | ||
|
||
@Test | ||
public void testInvalidFields() { | ||
invalidField("b", "NLS copy dimensions: 16 cm."); | ||
invalidField("1", "a", "NLS copy dimensions: 16 cm."); | ||
} | ||
|
||
public void validField(String subfield, String value) { | ||
DataField field = new DataField(Tag592.getInstance(), " ", " ", subfield, value); | ||
|
||
MarcRecord record = new MarcRecord("test"); | ||
field.setRecord(record); | ||
|
||
assertFalse( | ||
String.format("592$%s=%s should be invalid in normal case", subfield, value), | ||
field.validate(MarcVersion.MARC21)); | ||
assertTrue( | ||
String.format("592$%s=%s should be valid in normal case", subfield, value), | ||
field.validate(MarcVersion.BL)); | ||
} | ||
|
||
public void invalidField(String subfield, String value) { | ||
invalidField(" ", subfield, value); | ||
} | ||
|
||
public void invalidField(String ind1, String subfield, String value) { | ||
DataField field = new DataField(Tag592.getInstance(), ind1, " ", subfield, value); | ||
|
||
MarcRecord record = new MarcRecord("test"); | ||
field.setRecord(record); | ||
|
||
assertFalse( | ||
String.format("592$%s=%s should be invalid in normal case", subfield, value), | ||
field.validate(MarcVersion.MARC21)); | ||
assertFalse( | ||
String.format("592$%s=%s should be invalid in BL", subfield, value), | ||
field.validate(MarcVersion.BL)); | ||
} | ||
} |