-
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
14 changed files
with
204 additions
and
333 deletions.
There are no files selected for viewing
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
46 changes: 46 additions & 0 deletions
46
src/main/java/de/gwdg/metadataqa/marc/definition/tags/bltags/Tag595.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,46 @@ | ||
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; | ||
import de.gwdg.metadataqa.marc.definition.general.validator.RegexValidator; | ||
|
||
/** | ||
* National Bibliography Issue Number | ||
*/ | ||
public class Tag595 extends DataFieldDefinition { | ||
|
||
private static Tag595 uniqueInstance; | ||
|
||
private Tag595() { | ||
initialize(); | ||
postCreation(); | ||
} | ||
|
||
public static Tag595 getInstance() { | ||
if (uniqueInstance == null) | ||
uniqueInstance = new Tag595(); | ||
return uniqueInstance; | ||
} | ||
|
||
private void initialize() { | ||
|
||
tag = "595"; | ||
label = "Document Supply Bibliographic History Note"; | ||
mqTag = "documentSupplyBibliographicHistoryNote"; | ||
cardinality = Cardinality.Repeatable; | ||
// descriptionUrl = "https://www.loc.gov/marc/bibliographic/bd037.html"; | ||
// setCompilanceLevels("O"); | ||
|
||
ind1 = new Indicator(); | ||
ind2 = new Indicator(); | ||
|
||
setSubfieldsWithCardinality( | ||
"a", "Bibliographic history note", "NR" | ||
); | ||
|
||
getSubfield("a") | ||
.setValidator(new RegexValidator("^.*\\.$")) | ||
.setMqTag("note"); | ||
} | ||
} |
76 changes: 76 additions & 0 deletions
76
src/test/java/de/gwdg/metadataqa/marc/definition/tags/bltags/BLTagTest.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,76 @@ | ||
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.MarcSubfield; | ||
import de.gwdg.metadataqa.marc.definition.DataFieldDefinition; | ||
import de.gwdg.metadataqa.marc.definition.MarcVersion; | ||
|
||
import static junit.framework.TestCase.assertFalse; | ||
import static junit.framework.TestCase.assertTrue; | ||
|
||
public class BLTagTest { | ||
|
||
protected DataFieldDefinition tag; | ||
|
||
public BLTagTest(DataFieldDefinition tag) { | ||
this.tag = tag; | ||
} | ||
|
||
public void validField(String subfield, String value) { | ||
validField(" ", subfield, value); | ||
} | ||
|
||
public void validField(String ind1, String subfield, String value) { | ||
validField(new DataField(tag, ind1, " ", subfield, value)); | ||
} | ||
|
||
public void validField(DataField field) { | ||
MarcRecord record = new MarcRecord("test"); | ||
field.setRecord(record); | ||
|
||
MarcSubfield subfield = field.parseSubfields().get(0); | ||
|
||
assertFalse( | ||
String.format("%s$%s=%s should be invalid in normal case", | ||
tag.getTag(), subfield.getCode(), subfield.getValue()), | ||
field.validate(MarcVersion.MARC21)); | ||
assertTrue( | ||
String.format("%s$%s=%s should be valid in normal case", | ||
tag.getTag(), subfield.getCode(), subfield.getValue()), | ||
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(tag, ind1, " ", subfield, value); | ||
|
||
MarcRecord record = new MarcRecord("test"); | ||
field.setRecord(record); | ||
|
||
assertFalse( | ||
String.format("%s$%s=%s should be invalid in normal case", tag.getTag(), subfield, value), | ||
field.validate(MarcVersion.MARC21)); | ||
assertFalse( | ||
String.format("%s$%s=%s should be invalid in BL", tag.getTag(), subfield, value), | ||
field.validate(MarcVersion.BL)); | ||
} | ||
|
||
public void invalidFieldInBL(String ind1, String subfield, String value) { | ||
DataField field = new DataField(tag, ind1, " ", subfield, value); | ||
|
||
MarcRecord record = new MarcRecord("test"); | ||
field.setRecord(record); | ||
|
||
assertTrue( | ||
String.format("%s$%s=%s should be invalid in normal case", tag.getTag(), subfield, value), | ||
field.validate(MarcVersion.MARC21)); | ||
assertFalse( | ||
String.format("%s$%s=%s should be invalid in BL", tag.getTag(), subfield, value), | ||
field.validate(MarcVersion.BL)); | ||
} | ||
|
||
} |
60 changes: 11 additions & 49 deletions
60
src/test/java/de/gwdg/metadataqa/marc/definition/tags/bltags/Tag037Test.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 |
---|---|---|
@@ -1,63 +1,25 @@ | ||
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 de.gwdg.metadataqa.marc.definition.tags.tags01x.Tag037; | ||
import org.junit.Test; | ||
|
||
import static junit.framework.TestCase.assertFalse; | ||
import static junit.framework.TestCase.assertTrue; | ||
public class Tag037Test extends BLTagTest { | ||
|
||
public class Tag037Test { | ||
|
||
@Test | ||
public void testDisallowedSubfield_c() { | ||
MarcRecord record = new MarcRecord("test"); | ||
DataField field = new DataField(Tag037.getInstance(), " ", " ", "c", "$175.00"); | ||
field.setRecord(record); | ||
|
||
assertTrue("037$c should be valid in normal case", field.validate(MarcVersion.MARC21)); | ||
assertFalse("037$c should be invalid in BL", field.validate(MarcVersion.BL)); | ||
public Tag037Test() { | ||
super(Tag037.getInstance()); | ||
} | ||
|
||
@Test | ||
public void testDisallowedSubfield_f() { | ||
MarcRecord record = new MarcRecord("test"); | ||
DataField field = new DataField(Tag037.getInstance(), " ", " ", "f", "paperbound"); | ||
field.setRecord(record); | ||
|
||
assertTrue("037$f should be valid in normal case", field.validate(MarcVersion.MARC21)); | ||
assertFalse("037$f should be invalid in BL", field.validate(MarcVersion.BL)); | ||
public void testValidFields() { | ||
// validField("a", "c7507160a"); | ||
} | ||
|
||
@Test | ||
public void testDisallowedSubfield_g() { | ||
MarcRecord record = new MarcRecord("test"); | ||
DataField field = new DataField(Tag037.getInstance(), " ", " ", "g", "paperbound"); | ||
field.setRecord(record); | ||
|
||
assertTrue("037$g should be valid in normal case", field.validate(MarcVersion.MARC21)); | ||
assertFalse("037$g should be invalid in BL", field.validate(MarcVersion.BL)); | ||
} | ||
|
||
@Test | ||
public void testDisallowedSubfield_6() { | ||
MarcRecord record = new MarcRecord("test"); | ||
DataField field = new DataField(Tag037.getInstance(), " ", " ", "6", "100-01/(N"); | ||
field.setRecord(record); | ||
|
||
assertTrue("037$6 should be valid in normal case", field.validate(MarcVersion.MARC21)); | ||
assertFalse("037$6 should be invalid in BL", field.validate(MarcVersion.BL)); | ||
} | ||
|
||
@Test | ||
public void testDisallowedSubfield_8() { | ||
MarcRecord record = new MarcRecord("test"); | ||
DataField field = new DataField(Tag037.getInstance(), " ", " ", "8", "1.5\\a"); | ||
field.setRecord(record); | ||
|
||
assertTrue("037$8 should be valid in normal case", field.validate(MarcVersion.MARC21)); | ||
assertFalse("037$8 should be invalid in BL", field.validate(MarcVersion.BL)); | ||
public void testInvalidFields() { | ||
invalidFieldInBL(" ", "c", "$175.00"); | ||
invalidFieldInBL(" ", "f", "paperbound"); | ||
invalidFieldInBL(" ", "g", "paperbound"); | ||
invalidFieldInBL(" ", "6", "100-01/(N"); | ||
invalidFieldInBL(" ", "8", "1.5\\a"); | ||
} | ||
} |
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
29 changes: 9 additions & 20 deletions
29
src/test/java/de/gwdg/metadataqa/marc/definition/tags/bltags/Tag091Test.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 |
---|---|---|
@@ -1,32 +1,21 @@ | ||
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 de.gwdg.metadataqa.marc.definition.tags.oclctags.Tag029; | ||
import org.junit.Test; | ||
|
||
import static junit.framework.TestCase.assertFalse; | ||
import static junit.framework.TestCase.assertTrue; | ||
public class Tag091Test extends BLTagTest { | ||
|
||
public class Tag091Test { | ||
public Tag091Test() { | ||
super(Tag091.getInstance()); | ||
} | ||
|
||
@Test | ||
public void testFieldDefinition() { | ||
MarcRecord record = new MarcRecord("test"); | ||
DataField field = new DataField(Tag091.getInstance(), " ", " ", "a", "c7507160a"); | ||
field.setRecord(record); | ||
|
||
assertFalse("091$a should be invalid in normal case", field.validate(MarcVersion.MARC21)); | ||
assertTrue("091$a should be valid in BL", field.validate(MarcVersion.BL)); | ||
public void testValidFields() { | ||
validField("a", "c7507160a"); | ||
} | ||
|
||
@Test | ||
public void testInvalidData() { | ||
MarcRecord record = new MarcRecord("test"); | ||
DataField field = new DataField(Tag091.getInstance(), " ", " ", "a", "c7507160b"); | ||
field.setRecord(record); | ||
|
||
assertFalse("091$a should be invalid in BL", field.validate(MarcVersion.BL)); | ||
public void testInvalidFields() { | ||
invalidField("a", "c7507160b"); | ||
invalidField("b", "c7507160b"); | ||
} | ||
} |
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
Oops, something went wrong.