use of org.springframework.batch.core.JobExecution in project RecordManager2 by moravianlibrary.
the class OAIHarvestJobTest method testHarvestSpecificSet.
@Test
public void testHarvestSpecificSet() throws Exception {
reset(httpClient);
InputStream response0 = this.getClass().getResourceAsStream("/sample/IdentifyMLP.xml");
InputStream response1 = this.getClass().getResourceAsStream("/sample/ListRecordsMLPset.xml");
expect(httpClient.executeGet("http://web2.mlp.cz/cgi/oai?verb=Identify")).andReturn(response0);
expect(httpClient.executeGet("http://web2.mlp.cz/cgi/oai?verb=ListRecords&metadataPrefix=marc21&set=complete")).andReturn(response1);
replay(httpClient);
Map<String, JobParameter> params = new HashMap<>();
params.put(Constants.JOB_PARAM_CONF_ID, new JobParameter(303L));
JobExecution exec = jobExecutor.execute(Constants.JOB_ID_HARVEST, new JobParameters(params));
Assert.assertEquals(exec.getExitStatus(), ExitStatus.COMPLETED);
}
use of org.springframework.batch.core.JobExecution in project RecordManager2 by moravianlibrary.
the class OAIHarvestJobTest method emptySet.
@Test
public void emptySet() throws Exception {
reset(httpClient);
InputStream response0 = this.getClass().getResourceAsStream("/sample/Identify.xml");
InputStream response1 = this.getClass().getResourceAsStream("/sample/ListRecordsEmptySet.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&from=2015-01-01T01%3A00%3A00Z")).andReturn(response1);
replay(httpClient);
Map<String, JobParameter> params = new HashMap<>();
params.put(Constants.JOB_PARAM_CONF_ID, new JobParameter(300L));
params.put(Constants.JOB_PARAM_FROM_DATE, new JobParameter(new Date(1420070400000L)));
JobExecution exec = jobExecutor.execute("oaiHarvestJob", new JobParameters(params));
Assert.assertEquals(exec.getExitStatus(), ExitStatus.COMPLETED);
}
use of org.springframework.batch.core.JobExecution in project RecordManager2 by moravianlibrary.
the class OAIHarvestJobTest method testTimeGranularityConversion.
@Test
public void testTimeGranularityConversion() throws Exception {
reset(httpClient);
InputStream response0 = this.getClass().getResourceAsStream("/sample/IdentifyNonstandardGranularity.xml");
InputStream response1 = this.getClass().getResourceAsStream("/sample/ListRecordsNLK.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&from=2015-01-01")).andReturn(response1);
replay(httpClient);
Map<String, JobParameter> params = new HashMap<>();
params.put(Constants.JOB_PARAM_CONF_ID, new JobParameter(301L));
params.put(Constants.JOB_PARAM_FROM_DATE, new JobParameter(new Date(1420070400000L)));
JobExecution exec = jobExecutor.execute("oaiHarvestJob", new JobParameters(params));
Assert.assertEquals(exec.getExitStatus(), ExitStatus.COMPLETED);
}
use of org.springframework.batch.core.JobExecution in project RecordManager2 by moravianlibrary.
the class OAIHarvestJobTest method testHarvestOneByOne.
@Test
public void testHarvestOneByOne() throws Exception {
reset(httpClient);
InputStream response0 = this.getClass().getResourceAsStream("/sample/Identify.xml");
InputStream response1 = this.getClass().getResourceAsStream("/sample/ListIdentifiersMZK.xml");
InputStream response2 = this.getClass().getResourceAsStream("/sample/GetRecordMZK1.xml");
InputStream response3 = this.getClass().getResourceAsStream("/sample/GetRecordMZK2.xml");
expect(httpClient.executeGet("http://aleph.mzk.cz/OAI?verb=Identify")).andReturn(response0);
expect(httpClient.executeGet("http://aleph.mzk.cz/OAI?verb=ListIdentifiers&metadataPrefix=marc21")).andReturn(response1);
expect(httpClient.executeGet("http://aleph.mzk.cz/OAI?verb=GetRecord&metadataPrefix=marc21&identifier=oai%3Aaleph.mzk.cz%3AMZK01-100000151")).andReturn(response2);
expect(httpClient.executeGet("http://aleph.mzk.cz/OAI?verb=GetRecord&metadataPrefix=marc21&identifier=oai%3Aaleph.mzk.cz%3AMZK01-100000152")).andReturn(response3);
replay(httpClient);
Map<String, JobParameter> params = new HashMap<>();
params.put(Constants.JOB_PARAM_CONF_ID, new JobParameter(300L));
JobExecution exec = jobExecutor.execute(Constants.JOB_ID_HARVEST_ONE_BY_ONE, new JobParameters(params));
Assert.assertEquals(exec.getExitStatus(), ExitStatus.COMPLETED);
Assert.assertNotNull(recordDao.findByIdAndHarvestConfiguration("MZK01-100000151", 300L));
Assert.assertNotNull(recordDao.findByIdAndHarvestConfiguration("MZK01-100000152", 300L));
}
use of org.springframework.batch.core.JobExecution in project RecordManager2 by moravianlibrary.
the class OAIHarvestJobTest method reharvest.
@Test
public void reharvest() throws Exception {
reset(httpClient);
InputStream response0 = this.getClass().getResourceAsStream("/sample/Identify.xml");
InputStream response1 = this.getClass().getResourceAsStream("/sample/ListRecordsEmptySet.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);
Map<String, JobParameter> params = new HashMap<>();
params.put(Constants.JOB_PARAM_CONF_ID, new JobParameter(300L));
params.put(Constants.JOB_PARAM_REHARVEST, new JobParameter(Constants.JOB_PARAM_TRUE_VALUE));
params.put(Constants.JOB_PARAM_START_TIME, new JobParameter(new Date()));
JobExecution exec = jobExecutor.execute("oaiHarvestJob", new JobParameters(params));
Assert.assertEquals(exec.getExitStatus(), ExitStatus.COMPLETED);
}
Aggregations