use of cz.mzk.recordmanager.server.marc.MarcRecordImpl in project RecordManager2 by moravianlibrary.
the class CosmotronHarvestJobTest method test996BeforeRecord.
@Test
public void test996BeforeRecord() throws Exception {
reset(httpClient);
InputStream response0 = this.getClass().getResourceAsStream("/sample/Identify.xml");
InputStream response1 = this.getClass().getResourceAsStream("/sample/cosmotron/996BeforeRecord.xml");
expect(httpClient.executeGet("http://katalog.cbvk.cz/i2/i2.ws.oai.cls?verb=Identify")).andReturn(response0);
expect(httpClient.executeGet("http://katalog.cbvk.cz/i2/i2.ws.oai.cls?verb=ListRecords&metadataPrefix=oai_marcxml_cpk")).andReturn(response1);
replay(httpClient);
final Long confID = 328L;
Map<String, JobParameter> params = new HashMap<>();
params.put(Constants.JOB_PARAM_CONF_ID, new JobParameter(confID));
JobExecution exec = jobExecutor.execute(Constants.JOB_ID_HARVEST_COSMOTRON, new JobParameters(params));
Assert.assertEquals(exec.getExitStatus(), ExitStatus.COMPLETED);
OAIHarvestConfiguration config = configDao.get(confID);
HarvestedRecord hr = recordDao.findByIdAndHarvestConfiguration("CbvkUsCat" + Constants.COSMOTRON_RECORD_ID_CHAR + "m0000002", config);
Assert.assertNotNull(hr);
Assert.assertNotNull(cosmotronDao.findByIdAndHarvestConfiguration("CbvkUsCat" + Constants.COSMOTRON_RECORD_ID_CHAR + "0000003", config));
Assert.assertNotNull(cosmotronDao.findByIdAndHarvestConfiguration("CbvkUsCat" + Constants.COSMOTRON_RECORD_ID_CHAR + "0000004", config));
Assert.assertNotNull(cosmotronDao.findByIdAndHarvestConfiguration("CbvkUsCat" + Constants.COSMOTRON_RECORD_ID_CHAR + "0000005", config));
InputStream is = new ByteArrayInputStream(hr.getRawRecord());
Record record = marcXmlParser.parseUnderlyingRecord(is);
MarcRecord marcRecord = new MarcRecordImpl(record);
Assert.assertEquals(marcRecord.getDataFields("996").size(), 3);
}
use of cz.mzk.recordmanager.server.marc.MarcRecordImpl in project RecordManager2 by moravianlibrary.
the class CosmotronHarvestJobTest method testNew996.
@Test
public void testNew996() throws Exception {
reset(httpClient);
InputStream response0 = this.getClass().getResourceAsStream("/sample/Identify.xml");
InputStream response1 = this.getClass().getResourceAsStream("/sample/cosmotron/New9961.xml");
InputStream response2 = this.getClass().getResourceAsStream("/sample/cosmotron/New9962.xml");
expect(httpClient.executeGet("http://katalog.cbvk.cz/i2/i2.ws.oai.cls?verb=Identify")).andReturn(response0);
expect(httpClient.executeGet("http://katalog.cbvk.cz/i2/i2.ws.oai.cls?verb=ListRecords&metadataPrefix=oai_marcxml_cpk")).andReturn(response1);
expect(httpClient.executeGet("http://katalog.cbvk.cz/i2/i2.ws.oai.cls?verb=ListRecords&resumptionToken=12345")).andReturn(response2);
replay(httpClient);
final Long confID = 328L;
Map<String, JobParameter> params = new HashMap<>();
params.put(Constants.JOB_PARAM_CONF_ID, new JobParameter(confID));
JobExecution exec = jobExecutor.execute(Constants.JOB_ID_HARVEST_COSMOTRON, new JobParameters(params));
Assert.assertEquals(exec.getExitStatus(), ExitStatus.COMPLETED);
OAIHarvestConfiguration config = configDao.get(confID);
HarvestedRecord hr = recordDao.findByIdAndHarvestConfiguration("CbvkUsCat" + Constants.COSMOTRON_RECORD_ID_CHAR + "m0000002", config);
Assert.assertNotNull(hr);
Assert.assertNotNull(cosmotronDao.findByIdAndHarvestConfiguration("CbvkUsCat" + Constants.COSMOTRON_RECORD_ID_CHAR + "0000003", config));
Assert.assertNotNull(cosmotronDao.findByIdAndHarvestConfiguration("CbvkUsCat" + Constants.COSMOTRON_RECORD_ID_CHAR + "0000004", config));
InputStream is = new ByteArrayInputStream(hr.getRawRecord());
Record record = marcXmlParser.parseUnderlyingRecord(is);
MarcRecord marcRecord = new MarcRecordImpl(record);
Assert.assertEquals(marcRecord.getDataFields("996").size(), 5);
}
use of cz.mzk.recordmanager.server.marc.MarcRecordImpl in project RecordManager2 by moravianlibrary.
the class MzkFormatFunctionsTest method unknownFormat.
public void unknownFormat() throws Exception {
List<String> data = new ArrayList<String>();
data.add("000 -----------------2a-4500");
MarcRecordImpl record = MarcRecordFactory.recordFactory(data);
String format = formatFunctions.getMZKFormat(new MarcFunctionContext(record));
Assert.assertEquals(format, "Unknown");
}
use of cz.mzk.recordmanager.server.marc.MarcRecordImpl 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.marc.MarcRecordImpl 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