Search in sources :

Example 16 with MetadataRecord

use of cz.mzk.recordmanager.server.metadata.MetadataRecord in project RecordManager2 by moravianlibrary.

the class MarcRecordImplTest method getPublicationYearTest.

@Test
public void getPublicationYearTest() throws Exception {
    MarcRecordImpl mri;
    MetadataRecord metadataRecord;
    List<String> data = new ArrayList<>();
    data.add("260 $c1977");
    mri = MarcRecordFactory.recordFactory(data);
    metadataRecord = metadataFactory.getMetadataRecord(mri);
    Assert.assertEquals(metadataRecord.getPublicationYear().longValue(), 1977);
    data.clear();
    data.add("260 $c[1977]");
    mri = MarcRecordFactory.recordFactory(data);
    metadataRecord = metadataFactory.getMetadataRecord(mri);
    Assert.assertEquals(metadataRecord.getPublicationYear().longValue(), 1977);
    data.clear();
    data.add("260 $cc1977");
    mri = MarcRecordFactory.recordFactory(data);
    metadataRecord = metadataFactory.getMetadataRecord(mri);
    Assert.assertEquals(metadataRecord.getPublicationYear().longValue(), 1977);
    data.clear();
    data.add("260 $cc[1977]");
    mri = MarcRecordFactory.recordFactory(data);
    metadataRecord = metadataFactory.getMetadataRecord(mri);
    Assert.assertEquals(metadataRecord.getPublicationYear().longValue(), 1977);
    data.clear();
    data.add("260 $cp1977");
    mri = MarcRecordFactory.recordFactory(data);
    metadataRecord = metadataFactory.getMetadataRecord(mri);
    Assert.assertEquals(metadataRecord.getPublicationYear().longValue(), 1977);
    data.clear();
    data.add("260 $cp[1977]");
    mri = MarcRecordFactory.recordFactory(data);
    metadataRecord = metadataFactory.getMetadataRecord(mri);
    Assert.assertEquals(metadataRecord.getPublicationYear().longValue(), 1977);
    data.clear();
    data.add("260 $c1977-2003");
    mri = MarcRecordFactory.recordFactory(data);
    metadataRecord = metadataFactory.getMetadataRecord(mri);
    Assert.assertEquals(metadataRecord.getPublicationYear().longValue(), 1977);
    data.clear();
    data.add("260 $c1977 printing, c1975");
    mri = MarcRecordFactory.recordFactory(data);
    metadataRecord = metadataFactory.getMetadataRecord(mri);
    Assert.assertEquals(metadataRecord.getPublicationYear().longValue(), 1977);
    data.clear();
    data.add("260 $c1977-");
    mri = MarcRecordFactory.recordFactory(data);
    metadataRecord = metadataFactory.getMetadataRecord(mri);
    Assert.assertEquals(metadataRecord.getPublicationYear().longValue(), 1977);
    data.clear();
    data.add("260 $c1977, c1978");
    mri = MarcRecordFactory.recordFactory(data);
    metadataRecord = metadataFactory.getMetadataRecord(mri);
    Assert.assertEquals(metadataRecord.getPublicationYear().longValue(), 1977);
    data.clear();
    data.add("260 $cApril 15, 1977");
    mri = MarcRecordFactory.recordFactory(data);
    metadataRecord = metadataFactory.getMetadataRecord(mri);
    Assert.assertEquals(metadataRecord.getPublicationYear().longValue(), 1977);
    data.clear();
    data.add("260 $c1977[i.e. 1971]");
    mri = MarcRecordFactory.recordFactory(data);
    metadataRecord = metadataFactory.getMetadataRecord(mri);
    Assert.assertEquals(metadataRecord.getPublicationYear().longValue(), 1977);
    data.clear();
    data.add("260 $c<1977->");
    mri = MarcRecordFactory.recordFactory(data);
    metadataRecord = metadataFactory.getMetadataRecord(mri);
    Assert.assertEquals(metadataRecord.getPublicationYear().longValue(), 1977);
    data.clear();
    data.add("260 $c197-");
    mri = MarcRecordFactory.recordFactory(data);
    metadataRecord = metadataFactory.getMetadataRecord(mri);
    Assert.assertNull(metadataRecord.getPublicationYear());
    data.clear();
    data.add("260 $casdba");
    mri = MarcRecordFactory.recordFactory(data);
    metadataRecord = metadataFactory.getMetadataRecord(mri);
    Assert.assertNull(metadataRecord.getPublicationYear());
    data.clear();
    data.add("264 $c<1977->");
    data.add("260 $c<1978->");
    mri = MarcRecordFactory.recordFactory(data);
    metadataRecord = metadataFactory.getMetadataRecord(mri);
    Assert.assertEquals(metadataRecord.getPublicationYear().longValue(), 1977);
    data.clear();
    data.add("008 950928s1981----xr ||||e||||||||||||cze||");
    mri = MarcRecordFactory.recordFactory(data);
    metadataRecord = metadataFactory.getMetadataRecord(mri);
    Assert.assertEquals(metadataRecord.getPublicationYear().longValue(), 1981);
    data.clear();
}
Also used : ArrayList(java.util.ArrayList) MetadataRecord(cz.mzk.recordmanager.server.metadata.MetadataRecord) Test(org.testng.annotations.Test) AbstractTest(cz.mzk.recordmanager.server.AbstractTest)

Example 17 with MetadataRecord

use of cz.mzk.recordmanager.server.metadata.MetadataRecord in project RecordManager2 by moravianlibrary.

the class MarcRecordImplTest method getISMNsTest.

@Test
public void getISMNsTest() throws Exception {
    MarcRecordImpl mri;
    MetadataRecord metadataRecord;
    List<String> data = new ArrayList<>();
    List<Ismn> ismnlist = new ArrayList<>();
    // no ismn test
    mri = MarcRecordFactory.recordFactory(data);
    metadataRecord = metadataFactory.getMetadataRecord(mri);
    Assert.assertEquals(metadataRecord.getISMNs(), Collections.EMPTY_LIST);
    data.clear();
    // create ismn
    data.add("024 2 $aM-2600-0224-1$q(brož.)");
    ismnlist.add(Ismn.create(9790260002241L, 1L, "brož."));
    data.add("024 2 $a979-0-2600-0125-1$q(sešity v obálce)");
    ismnlist.add(Ismn.create(9790260001251L, 2L, "sešity v obálce"));
    data.add("024 2 $aM-66056-061-7$q(Praha ;$qv hudebnině neuvedeno ;$qbrož.)");
    ismnlist.add(Ismn.create(9790660560617L, 3L, "Praha v hudebnině neuvedeno ; brož."));
    data.add("024 2 $aM-66056-061-7 (Brno)$q(Praha)");
    ismnlist.add(Ismn.create(9790660560617L, 4L, "Brno Praha"));
    mri = MarcRecordFactory.recordFactory(data);
    metadataRecord = metadataFactory.getMetadataRecord(mri);
    List<Ismn> results = metadataRecord.getISMNs();
    Assert.assertEquals(results.size(), ismnlist.size());
    for (int i = 0; i < ismnlist.size(); i++) {
        Assert.assertEquals(results.get(i), ismnlist.get(i), String.format("ISMN on position %d differs.", i));
    }
}
Also used : ArrayList(java.util.ArrayList) MetadataRecord(cz.mzk.recordmanager.server.metadata.MetadataRecord) Test(org.testng.annotations.Test) AbstractTest(cz.mzk.recordmanager.server.AbstractTest)

Example 18 with MetadataRecord

use of cz.mzk.recordmanager.server.metadata.MetadataRecord in project RecordManager2 by moravianlibrary.

the class MarcRecordImplTest method getOclcsTest.

@Test
public void getOclcsTest() throws Exception {
    MarcRecordImpl mri;
    MetadataRecord metadataRecord;
    List<String> data = new ArrayList<>();
    final String oclc1 = "11608569";
    final String oclc2 = "ocn123456789";
    data.add("035 $a(OCoLC)" + oclc1);
    data.add("035 $a(OCoLC)" + oclc2);
    mri = MarcRecordFactory.recordFactory(data);
    metadataRecord = metadataFactory.getMetadataRecord(mri);
    Assert.assertEquals(metadataRecord.getOclcs().size(), 2);
    Assert.assertEquals(metadataRecord.getOclcs().get(0).getOclcStr(), oclc1);
    Assert.assertEquals(metadataRecord.getOclcs().get(1).getOclcStr(), oclc2);
}
Also used : ArrayList(java.util.ArrayList) MetadataRecord(cz.mzk.recordmanager.server.metadata.MetadataRecord) Test(org.testng.annotations.Test) AbstractTest(cz.mzk.recordmanager.server.AbstractTest)

Example 19 with MetadataRecord

use of cz.mzk.recordmanager.server.metadata.MetadataRecord in project RecordManager2 by moravianlibrary.

the class MarcRecordImplTest method shortTitleTest.

@Test
public void shortTitleTest() throws Exception {
    MarcRecordImpl mri;
    MetadataRecord metadataRecord;
    List<String> data = new ArrayList<>();
    data.add("245 $nn$aa$pp$bb");
    data.add("240 $aa$nn$bb$pp");
    data.add("245 $aa$pp$nn");
    mri = MarcRecordFactory.recordFactory(data);
    metadataRecord = metadataFactory.getMetadataRecord(mri);
    ShortTitle expectedST1 = ShortTitle.create("nap", 1L, false);
    ShortTitle expectedST2 = ShortTitle.create("anp", 2L, false);
    Assert.assertEquals(2, metadataRecord.getShortTitles().size());
    Assert.assertEquals(metadataRecord.getShortTitles().get(0), expectedST1);
    Assert.assertEquals(metadataRecord.getShortTitles().get(1), expectedST2);
}
Also used : ArrayList(java.util.ArrayList) MetadataRecord(cz.mzk.recordmanager.server.metadata.MetadataRecord) Test(org.testng.annotations.Test) AbstractTest(cz.mzk.recordmanager.server.AbstractTest)

Example 20 with MetadataRecord

use of cz.mzk.recordmanager.server.metadata.MetadataRecord in project RecordManager2 by moravianlibrary.

the class MarcRecordImplTest method getCitationFormatElectronicArticles.

@Test
public void getCitationFormatElectronicArticles() throws Exception {
    MarcRecordImpl mri;
    MetadataRecord metadataRecord;
    List<String> data = new ArrayList<>();
    data.add("000 0000000b");
    data.add("856 41$atest");
    mri = MarcRecordFactory.recordFactory(data);
    metadataRecord = metadataFactory.getMetadataRecord(mri);
    Assert.assertEquals(metadataRecord.getCitationFormat(), CitationRecordType.ELECTRONIC_ARTICLE);
    data.clear();
}
Also used : ArrayList(java.util.ArrayList) MetadataRecord(cz.mzk.recordmanager.server.metadata.MetadataRecord) Test(org.testng.annotations.Test) AbstractTest(cz.mzk.recordmanager.server.AbstractTest)

Aggregations

MetadataRecord (cz.mzk.recordmanager.server.metadata.MetadataRecord)46 AbstractTest (cz.mzk.recordmanager.server.AbstractTest)42 Test (org.testng.annotations.Test)42 ArrayList (java.util.ArrayList)32 MarcRecord (cz.mzk.recordmanager.server.marc.MarcRecord)3 Title (cz.mzk.recordmanager.server.model.Title)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 InputStream (java.io.InputStream)3 MarcWriter (org.marc4j.MarcWriter)3 MarcXmlWriter (org.marc4j.MarcXmlWriter)3 Record (org.marc4j.marc.Record)3 MarcRecordImpl (cz.mzk.recordmanager.server.marc.MarcRecordImpl)2 MarcRecordInterceptor (cz.mzk.recordmanager.server.marc.intercepting.MarcRecordInterceptor)2 HarvestedRecordFormatEnum (cz.mzk.recordmanager.server.model.HarvestedRecordFormat.HarvestedRecordFormatEnum)2 Date (java.util.Date)2 MetadataRecordFactory (cz.mzk.recordmanager.server.metadata.MetadataRecordFactory)1 Cosmotron996 (cz.mzk.recordmanager.server.model.Cosmotron996)1 HarvestedRecord (cz.mzk.recordmanager.server.model.HarvestedRecord)1 HarvestedRecordUniqueId (cz.mzk.recordmanager.server.model.HarvestedRecord.HarvestedRecordUniqueId)1 TezaurusRecord (cz.mzk.recordmanager.server.model.TezaurusRecord)1