use of org.springframework.batch.core.JobExecution in project RecordManager2 by moravianlibrary.
the class CosmotronHarvestJobTest method testCopy996ToParentRecord.
@Test
public void testCopy996ToParentRecord() throws Exception {
reset(httpClient);
InputStream response0 = this.getClass().getResourceAsStream("/sample/Identify.xml");
InputStream response1 = this.getClass().getResourceAsStream("/sample/cosmotron/RecordAnd996.xml");
InputStream response2 = this.getClass().getResourceAsStream("/sample/cosmotron/Deleted996.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=123456")).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);
InputStream is = new ByteArrayInputStream(hr.getRawRecord());
Record record = marcXmlParser.parseUnderlyingRecord(is);
MarcRecord marcRecord = new MarcRecordImpl(record);
Assert.assertEquals(marcRecord.getDataFields("996").size(), 2);
}
use of org.springframework.batch.core.JobExecution in project RecordManager2 by moravianlibrary.
the class CosmotronHarvestJobTest method testHarvestRecords.
@Test
public void testHarvestRecords() throws Exception {
reset(httpClient);
InputStream response0 = this.getClass().getResourceAsStream("/sample/Identify.xml");
InputStream response1 = this.getClass().getResourceAsStream("/sample/ListRecords2.xml");
expect(httpClient.executeGet("http://aleph.mzk.cz/OAI?verb=Identify")).andReturn(response0);
expect(httpClient.executeGet("http://aleph.mzk.cz/OAI?verb=ListRecords&metadataPrefix=marc21")).andReturn(response1);
replay(httpClient);
final Long confID = 300L;
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);
HarvestedRecord hr = recordDao.findByIdAndHarvestConfiguration("MZK01-000213478", confID);
Assert.assertNotNull(hr);
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 org.springframework.batch.core.JobExecution in project RecordManager2 by moravianlibrary.
the class CosmotronHarvestJobTest method testDeletedExistsRecord.
@Test
public void testDeletedExistsRecord() throws Exception {
reset(httpClient);
InputStream response0 = this.getClass().getResourceAsStream("/sample/IdentifyNonstandardGranularity.xml");
InputStream response1 = this.getClass().getResourceAsStream("/sample/ListRecordsNLKdeleted1.xml");
InputStream response2 = this.getClass().getResourceAsStream("/sample/ListRecordsNLKdeleted2.xml");
expect(httpClient.executeGet("http://oai.medvik.cz/medvik2cpk/oai?verb=Identify")).andReturn(response0);
expect(httpClient.executeGet("http://oai.medvik.cz/medvik2cpk/oai?verb=ListRecords&metadataPrefix=marc21")).andReturn(response1);
expect(httpClient.executeGet("http://oai.medvik.cz/medvik2cpk/oai?verb=ListRecords&resumptionToken=xaiutmvy00003")).andReturn(response2);
replay(httpClient);
final Long confID = 301L;
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);
HarvestedRecord record = recordDao.findByIdAndHarvestConfiguration("111111", confID);
Assert.assertNotNull(record, "Record not stored.");
Assert.assertNotNull(record.getDeleted());
}
use of org.springframework.batch.core.JobExecution in project RecordManager2 by moravianlibrary.
the class OAIHarvestAuthorityJobTest method testHarvestAuthorityRecords.
@Test
public void testHarvestAuthorityRecords() throws Exception {
reset(httpClient);
InputStream response0 = this.getClass().getResourceAsStream("/auth/Identify.xml");
InputStream response1 = this.getClass().getResourceAsStream("/auth/ListRecords1.xml");
expect(httpClient.executeGet("http://aleph.nkp.cz/OAI?verb=Identify")).andReturn(response0);
expect(httpClient.executeGet("http://aleph.nkp.cz/OAI?verb=ListRecords&metadataPrefix=marc21&set=AUTH")).andReturn(response1);
replay(httpClient);
final Long configId = oaiConfiguration.getId();
Map<String, JobParameter> params = new HashMap<String, JobParameter>();
params.put("configurationId", new JobParameter(configId));
JobParameters jobParams = new JobParameters(params);
JobExecution exec = jobExecutor.execute(Constants.JOB_ID_HARVEST_AUTH, jobParams);
Assert.assertEquals(exec.getExitStatus(), ExitStatus.COMPLETED);
AuthorityRecord authRec = authorityRecordDao.findByIdAndHarvestConfiguration("oai:aleph-nkp.cz:AUT10-000000001", oaiConfiguration);
Assert.assertNotNull(authRec);
Assert.assertEquals(authRec.getAuthorityCode(), "jk01010001");
authRec = authorityRecordDao.findByIdAndHarvestConfiguration("oai:aleph-nkp.cz:AUT10-000000006", oaiConfiguration);
Assert.assertEquals(authRec.getAuthorityCode(), "jk01010009");
Assert.assertNotNull(authRec);
authRec = authorityRecordDao.findByIdAndHarvestConfiguration("oai:aleph-nkp.cz:AUT10-000000007", oaiConfiguration);
Assert.assertEquals(authRec.getAuthorityCode(), "jk01010010");
Assert.assertNotNull(authRec);
}
use of org.springframework.batch.core.JobExecution in project spring-boot by spring-projects.
the class JobLauncherApplicationRunner method execute.
protected void execute(Job job, JobParameters jobParameters) throws JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException, JobParametersInvalidException, JobParametersNotFoundException {
JobParameters parameters = getNextJobParameters(job, jobParameters);
JobExecution execution = this.jobLauncher.run(job, parameters);
if (this.publisher != null) {
this.publisher.publishEvent(new JobExecutionEvent(execution));
}
}
Aggregations