Search in sources :

Example 11 with MetadataRecord

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

the class MarcRecordImplTest method getCitationFormatError.

@Test
public void getCitationFormatError() throws Exception {
    MarcRecordImpl mri;
    MetadataRecord metadataRecord;
    List<String> data = new ArrayList<>();
    data.add("000 00000000");
    mri = MarcRecordFactory.recordFactory(data);
    metadataRecord = metadataFactory.getMetadataRecord(mri);
    Assert.assertEquals(metadataRecord.getCitationFormat(), CitationRecordType.ERROR);
    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 12 with MetadataRecord

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

the class MarcRecordImplTest method getISSNsTest.

@Test
public void getISSNsTest() throws Exception {
    MarcRecordImpl mri;
    MetadataRecord metadataRecord;
    List<String> data = new ArrayList<>();
    List<Issn> issns = new ArrayList<>();
    Long issnCounter = 0L;
    // no issn test
    mri = MarcRecordFactory.recordFactory(data);
    metadataRecord = metadataFactory.getMetadataRecord(mri);
    Assert.assertEquals(metadataRecord.getISSNs(), Collections.EMPTY_LIST);
    data.clear();
    // create issn
    data.add("022 $a2336-4815");
    issns.add(Issn.create("2336-4815", ++issnCounter, ""));
    data.add("022 $a1214-4029 (pozn)");
    issns.add(Issn.create("1214-4029", ++issnCounter, "pozn"));
    data.add("022 $a0231-858X");
    issns.add(Issn.create("0231-858X", ++issnCounter, ""));
    mri = MarcRecordFactory.recordFactory(data);
    metadataRecord = metadataFactory.getMetadataRecord(mri);
    Assert.assertEquals(metadataRecord.getISSNs().toString(), issns.toString());
}
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 13 with MetadataRecord

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

the class MarcRecordImplTest method getWeightTest.

@Test
public void getWeightTest() throws Exception {
    MarcRecordImpl mri;
    MetadataRecord metadataRecord;
    List<String> data = new ArrayList<>();
    data.add("000 01234567890123456a");
    data.add("008 asd");
    data.add("020 $a80-200-0980-9");
    data.add("040 $erda");
    data.add("080 456");
    data.add("100 $aasd");
    data.add("245 00$asasd");
    data.add("300 $asd");
    data.add("752 $7asd");
    data.add("964 $asd");
    mri = MarcRecordFactory.recordFactory(data);
    metadataRecord = metadataFactory.getMetadataRecord(mri);
    Assert.assertEquals(metadataRecord.getWeight(0L).longValue(), 5L);
    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 14 with MetadataRecord

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

the class MarcRecordImplTest method getPageCountTest.

@Test
public void getPageCountTest() throws Exception {
    MarcRecordImpl mri;
    MetadataRecord metadataRecord;
    List<String> data = new ArrayList<>();
    data.add("300 $a257 s.");
    mri = MarcRecordFactory.recordFactory(data);
    metadataRecord = metadataFactory.getMetadataRecord(mri);
    Assert.assertEquals(metadataRecord.getPageCount().longValue(), 257);
    data.clear();
    data.add("300 $a1 zvuková deska (78:24)");
    mri = MarcRecordFactory.recordFactory(data);
    metadataRecord = metadataFactory.getMetadataRecord(mri);
    Assert.assertEquals(metadataRecord.getPageCount().longValue(), 78);
    data.clear();
    data.add("300 $a[14] s.");
    mri = MarcRecordFactory.recordFactory(data);
    metadataRecord = metadataFactory.getMetadataRecord(mri);
    Assert.assertEquals(metadataRecord.getPageCount().longValue(), 14);
    data.clear();
    mri = MarcRecordFactory.recordFactory(data);
    metadataRecord = metadataFactory.getMetadataRecord(mri);
    Assert.assertEquals(metadataRecord.getPageCount(), null);
    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 15 with MetadataRecord

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

the class MarcRecordImplTest method getEANsTest.

@Test
public void getEANsTest() throws Exception {
    MarcRecordImpl mri;
    MetadataRecord metadataRecord;
    List<String> data = new ArrayList<>();
    List<Ean> eanList = new ArrayList<>();
    // no ean
    mri = MarcRecordFactory.recordFactory(data);
    metadataRecord = metadataFactory.getMetadataRecord(mri);
    Assert.assertEquals(metadataRecord.getEANs(), Collections.EMPTY_LIST);
    // create eans
    data.add("024 3 $a4006381333931$q(brož.)");
    eanList.add(Ean.create(4006381333931L, 1L, "brož."));
    data.add("024 3 $a4006381333931 note$q(sešity v obálce)");
    eanList.add(Ean.create(4006381333931L, 2L, "note sešity v obálce"));
    data.add("024 3 $a4006381333931$q(Praha ;$qv hudebnině neuvedeno ;$qbrož.)");
    eanList.add(Ean.create(4006381333931L, 3L, "Praha v hudebnině neuvedeno ; brož."));
    // invalid
    data.add("024 3 $a73513536 (Brno)$q(Praha)");
    mri = MarcRecordFactory.recordFactory(data);
    metadataRecord = metadataFactory.getMetadataRecord(mri);
    List<Ean> results = metadataRecord.getEANs();
    Assert.assertEquals(results.size(), eanList.size());
    for (int i = 0; i < eanList.size(); i++) {
        Assert.assertEquals(results.get(i), eanList.get(i), String.format("EAN 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)

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