use of cz.mzk.recordmanager.server.model.HarvestedRecord in project RecordManager2 by moravianlibrary.
the class KrameriusHarvesterTest method harvesterNoServerResponse.
// Kramerius Harvester without sorting
@Test
public void harvesterNoServerResponse() throws Exception {
initHttpClientWithException();
initSolrServerWithException();
KrameriusHarvesterParams parameters = new KrameriusHarvesterParams();
parameters.setUrl("http://k4.techlib.cz/search/api/v5.0");
parameters.setMetadataStream("DC");
KrameriusHarvester harvester = new KrameriusHarvester(httpClient, solrServerFactory, parameters, 1L);
// 1st response with IOException => uuid list is empty
List<String> uuids = harvester.getUuids(null);
Assert.assertTrue(uuids.isEmpty());
// 2nd response with SolrServerException => uuid list is empty
uuids = harvester.getUuids(null);
Assert.assertTrue(uuids.isEmpty());
// 3rd response is => OK
uuids = harvester.getUuids(null);
Assert.assertFalse(uuids.isEmpty());
// 1st DC download - server responds with IOException, download returns null;
HarvestedRecord record = harvester.downloadRecord(uuids.get(0));
Assert.assertNull(record);
// 2nd DC download - OK
record = harvester.downloadRecord(uuids.get(1));
Assert.assertNotNull(record);
}
use of cz.mzk.recordmanager.server.model.HarvestedRecord in project RecordManager2 by moravianlibrary.
the class KrameriusHarvesterTest method downloadRecord.
// Kramerius Harvester with sorting
@Test
public void downloadRecord() throws Exception {
init();
KrameriusHarvesterParams parameters = new KrameriusHarvesterParams();
parameters.setUrl("http://k4.techlib.cz/search/api/v5.0");
parameters.setMetadataStream("DC");
KrameriusHarvester harvester = new KrameriusHarvester(httpClient, solrServerFactory, parameters, 1L);
List<String> uuids = harvester.getUuids(null);
for (String uuid : uuids) {
HarvestedRecord record = harvester.downloadRecord(uuid);
Assert.assertNotNull(record);
}
}
use of cz.mzk.recordmanager.server.model.HarvestedRecord in project RecordManager2 by moravianlibrary.
the class MarcXmlDedupKeyParserTest method parseCorrectRecord.
@Test
public void parseCorrectRecord() throws Exception {
InputStream is = this.getClass().getResourceAsStream("/records/marcxml/MZK01-001439241.xml");
ImportConfiguration ic = importConfDao.get(300L);
HarvestedRecordUniqueId id = new HarvestedRecordUniqueId(ic, "1");
HarvestedRecord record = new HarvestedRecord(id);
record.setHarvestedFrom(ic);
record.setFormat("marc21-xml");
byte[] rawRecord = ByteStreams.toByteArray(is);
record.setRawRecord(rawRecord);
record.setId(1L);
parser.parse(record);
Assert.assertTrue(record.getIsbns().size() > 0);
Assert.assertEquals(record.getIsbns().get(0).getIsbn(), EXPECTED_ISBN);
Assert.assertEquals(record.getTitles().size(), 1);
Assert.assertEquals(record.getTitles().get(0).getTitleStr(), EXPECTED_TITLE);
Assert.assertEquals(record.getPhysicalFormats().size(), 1);
Assert.assertEquals(record.getPhysicalFormats().get(0).getName(), HarvestedRecordFormatEnum.BOOKS.name());
Assert.assertEquals(record.getPublicationYear(), new Long(2014));
Assert.assertEquals(record.getAuthorAuthKey(), EXPECTED_AUTHORAUTHKEY);
Assert.assertEquals(record.getAuthorString(), EXPECTED_AUTHORSTRING);
Assert.assertEquals(record.getScale(), EXPECTED_SCALE);
Assert.assertEquals(record.getUuid(), EXPECTED_UUID);
Assert.assertEquals(record.getIssnSeries(), EXPECTED_ISSNSERIES);
Assert.assertEquals(record.getIssnSeriesOrder(), EXPECTED_ISSNSERIESORDER);
}
use of cz.mzk.recordmanager.server.model.HarvestedRecord in project RecordManager2 by moravianlibrary.
the class ImportRecordsJobTest method testSimpleImportOsobnosti.
@Test
public void testSimpleImportOsobnosti() throws Exception {
Job job = jobRegistry.getJob(Constants.JOB_ID_IMPORT);
Map<String, JobParameter> params = new HashMap<>();
params.put(Constants.JOB_PARAM_CONF_ID, new JobParameter(300L));
params.put(Constants.JOB_PARAM_IN_FILE, new JobParameter(testFileOsobnosti1));
params.put(Constants.JOB_PARAM_FORMAT, new JobParameter("osobnosti"));
JobParameters jobParams = new JobParameters(params);
jobLauncher.run(job, jobParams);
HarvestedRecord hr = harvestedRecordDao.findByIdAndHarvestConfiguration("5", 300L);
Assert.assertNotNull(hr);
InputStream is = new ByteArrayInputStream(hr.getRawRecord());
MarcRecord mr = new MarcRecordImpl(marcXmlParser.parseUnderlyingRecord(is));
Assert.assertFalse(mr.getDataFields("100").isEmpty());
Assert.assertFalse(mr.getDataFields("670").isEmpty());
Assert.assertEquals(mr.getDataFields("856").size(), 1);
}
use of cz.mzk.recordmanager.server.model.HarvestedRecord in project RecordManager2 by moravianlibrary.
the class ImportRecordsJobTest method testSimpleImportPatents.
@Test
public void testSimpleImportPatents() throws Exception {
Job job = jobRegistry.getJob(Constants.JOB_ID_IMPORT);
Map<String, JobParameter> params = new HashMap<>();
params.put(Constants.JOB_PARAM_CONF_ID, new JobParameter(300L));
params.put(Constants.JOB_PARAM_IN_FILE, new JobParameter(testFilePatents1));
params.put(Constants.JOB_PARAM_FORMAT, new JobParameter("patents"));
JobParameters jobParams = new JobParameters(params);
jobLauncher.run(job, jobParams);
HarvestedRecord hr = harvestedRecordDao.findByIdAndHarvestConfiguration("St36_CZ_305523_B6", 300L);
Assert.assertNotNull(hr);
InputStream is = new ByteArrayInputStream(hr.getRawRecord());
MarcRecord mr = new MarcRecordImpl(marcXmlParser.parseUnderlyingRecord(is));
Assert.assertFalse(mr.getDataFields("100").isEmpty());
Assert.assertFalse(mr.getDataFields("520").isEmpty());
}
Aggregations