use of org.springframework.batch.core.JobExecution in project tutorials by eugenp.
the class SpringbatchPartitionerApp method main.
public static void main(final String[] args) {
// Spring Java config
final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
context.register(SpringbatchPartitionConfig.class);
context.refresh();
final JobLauncher jobLauncher = (JobLauncher) context.getBean("jobLauncher");
final Job job = (Job) context.getBean("partitionerJob");
System.out.println("Starting the batch job");
try {
final JobExecution execution = jobLauncher.run(job, new JobParameters());
System.out.println("Job Status : " + execution.getStatus());
System.out.println("Job succeeded");
} catch (final Exception e) {
e.printStackTrace();
System.out.println("Job failed");
}
}
use of org.springframework.batch.core.JobExecution in project tutorials by eugenp.
the class ChunksTest method givenChunksJob_WhenJobEnds_ThenStatusCompleted.
@Test
public void givenChunksJob_WhenJobEnds_ThenStatusCompleted() throws Exception {
JobExecution jobExecution = jobLauncherTestUtils.launchJob();
Assert.assertEquals(ExitStatus.COMPLETED, jobExecution.getExitStatus());
}
use of org.springframework.batch.core.JobExecution in project spring-boot by spring-projects.
the class JobExecutionExitCodeGeneratorTests method testExitCodeForCompleted.
@Test
void testExitCodeForCompleted() {
JobExecution execution = new JobExecution(0L);
execution.setStatus(BatchStatus.COMPLETED);
this.generator.onApplicationEvent(new JobExecutionEvent(execution));
assertThat(this.generator.getExitCode()).isEqualTo(0);
}
use of org.springframework.batch.core.JobExecution in project head by mifos.
the class LoanArrearsTaskIntegrationTest method testExecute.
@Test
public void testExecute() throws Exception {
int statusChangeHistorySize = loanAccount.getAccountStatusChangeHistory().size();
mifosScheduler.runIndividualTask(jobName);
Thread.sleep(1500);
JobExplorer explorer = mifosScheduler.getBatchJobExplorer();
List<JobInstance> jobInstances = explorer.getJobInstances(jobName, 0, 10);
Assert.assertEquals(1, jobInstances.size());
JobInstance lastInstance = jobInstances.get(0);
List<JobExecution> jobExecutions = explorer.getJobExecutions(lastInstance);
Assert.assertEquals(1, jobExecutions.size());
JobExecution lastExecution = jobExecutions.get(0);
Assert.assertEquals(BatchStatus.COMPLETED, lastExecution.getStatus());
StaticHibernateUtil.getSessionTL().refresh(loanAccount);
loanAccount = legacyAccountDao.getAccount(loanAccount.getAccountId());
Assert.assertEquals(AccountState.LOAN_ACTIVE_IN_BAD_STANDING, loanAccount.getState());
Assert.assertEquals(statusChangeHistorySize + 1, loanAccount.getAccountStatusChangeHistory().size());
}
use of org.springframework.batch.core.JobExecution in project head by mifos.
the class ProductStatusHelperIntegrationTest method testExecuteTask.
@Test
public void testExecuteTask() throws Exception {
createInactiveLoanOffering();
mifosScheduler = getMifosScheduler("org/mifos/framework/components/batchjobs/productStatusTestTask.xml");
mifosScheduler.runIndividualTask(jobName);
Thread.sleep(1000);
JobExplorer explorer = mifosScheduler.getBatchJobExplorer();
List<JobInstance> jobInstances = explorer.getJobInstances(jobName, 0, 10);
Assert.assertTrue(jobInstances.size() > 0);
JobInstance lastInstance = jobInstances.get(0);
List<JobExecution> jobExecutions = explorer.getJobExecutions(lastInstance);
Assert.assertEquals(1, jobExecutions.size());
JobExecution lastExecution = jobExecutions.get(0);
Assert.assertEquals(BatchStatus.COMPLETED, lastExecution.getStatus());
product = (LoanOfferingBO) TestObjectFactory.getObject(LoanOfferingBO.class, product.getPrdOfferingId());
Assert.assertEquals(PrdStatus.LOAN_ACTIVE, product.getStatus());
}
Aggregations