Search in sources :

Example 11 with JobExplorer

use of org.springframework.batch.core.explore.JobExplorer 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());
}
Also used : JobExecution(org.springframework.batch.core.JobExecution) JobInstance(org.springframework.batch.core.JobInstance) JobExplorer(org.springframework.batch.core.explore.JobExplorer) Test(org.junit.Test)

Example 12 with JobExplorer

use of org.springframework.batch.core.explore.JobExplorer 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());
}
Also used : JobExecution(org.springframework.batch.core.JobExecution) JobInstance(org.springframework.batch.core.JobInstance) JobExplorer(org.springframework.batch.core.explore.JobExplorer) Test(org.junit.Test)

Example 13 with JobExplorer

use of org.springframework.batch.core.explore.JobExplorer in project head by mifos.

the class LoanArrearsAndPortfolioAtRiskIntegrationTest method testLoanArrearsTaskRunFailed.

@Test
@Ignore
public void testLoanArrearsTaskRunFailed() throws Exception {
    mifosScheduler = getMifosScheduler("org/mifos/framework/components/batchjobs/loanArrearsAndPortfolioTask2.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.FAILED, lastExecution.getStatus());
    Collection<StepExecution> stepExecutions = lastExecution.getStepExecutions();
    Assert.assertEquals(1, stepExecutions.size());
    for (StepExecution stepExecution : stepExecutions) {
        Assert.assertEquals(BatchStatus.FAILED, stepExecution.getStatus());
    }
}
Also used : JobExecution(org.springframework.batch.core.JobExecution) JobInstance(org.springframework.batch.core.JobInstance) JobExplorer(org.springframework.batch.core.explore.JobExplorer) StepExecution(org.springframework.batch.core.StepExecution) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 14 with JobExplorer

use of org.springframework.batch.core.explore.JobExplorer in project head by mifos.

the class LoanArrearsAndPortfolioAtRiskIntegrationTest method testLoanArrearsTaskRunSuccessfull.

@Test
@Ignore
public void testLoanArrearsTaskRunSuccessfull() throws Exception {
    mifosScheduler = getMifosScheduler("org/mifos/framework/components/batchjobs/loanArrearsAndPortfolioTask.xml");
    mifosScheduler.runIndividualTask(jobName);
    Thread.sleep(2000);
    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());
    Collection<StepExecution> stepExecutions = lastExecution.getStepExecutions();
    Assert.assertEquals(2, stepExecutions.size());
    for (StepExecution stepExecution : stepExecutions) {
        Assert.assertEquals(BatchStatus.COMPLETED, stepExecution.getStatus());
    }
}
Also used : JobExecution(org.springframework.batch.core.JobExecution) JobInstance(org.springframework.batch.core.JobInstance) JobExplorer(org.springframework.batch.core.explore.JobExplorer) StepExecution(org.springframework.batch.core.StepExecution) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 15 with JobExplorer

use of org.springframework.batch.core.explore.JobExplorer in project spring-boot by spring-projects.

the class BatchAutoConfigurationTests method testRenamePrefix.

@Test
public void testRenamePrefix() throws Exception {
    this.context = new AnnotationConfigApplicationContext();
    EnvironmentTestUtils.addEnvironment(this.context, "spring.datasource.name:batchtest", "spring.batch.schema:classpath:batch/custom-schema-hsql.sql", "spring.batch.tablePrefix:PREFIX_");
    this.context.register(TestConfiguration.class, EmbeddedDataSourceConfiguration.class, HibernateJpaAutoConfiguration.class, BatchAutoConfiguration.class, TransactionAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class);
    this.context.refresh();
    assertThat(this.context.getBean(JobLauncher.class)).isNotNull();
    assertThat(this.context.getBean(BatchProperties.class).getInitializer().isEnabled()).isTrue();
    assertThat(new JdbcTemplate(this.context.getBean(DataSource.class)).queryForList("select * from PREFIX_JOB_EXECUTION")).isEmpty();
    JobExplorer jobExplorer = this.context.getBean(JobExplorer.class);
    assertThat(jobExplorer.findRunningJobExecutions("test")).isEmpty();
    JobRepository jobRepository = this.context.getBean(JobRepository.class);
    assertThat(jobRepository.getLastJobExecution("test", new JobParameters())).isNull();
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) JobExplorer(org.springframework.batch.core.explore.JobExplorer) JobParameters(org.springframework.batch.core.JobParameters) JdbcTemplate(org.springframework.jdbc.core.JdbcTemplate) JobRepository(org.springframework.batch.core.repository.JobRepository) Test(org.junit.Test)

Aggregations

JobExplorer (org.springframework.batch.core.explore.JobExplorer)16 Test (org.junit.Test)12 JobInstance (org.springframework.batch.core.JobInstance)12 JobExecution (org.springframework.batch.core.JobExecution)11 Date (java.util.Date)5 Ignore (org.junit.Ignore)3 StepExecution (org.springframework.batch.core.StepExecution)3 JobLocator (org.springframework.batch.core.configuration.JobLocator)3 JobLauncher (org.springframework.batch.core.launch.JobLauncher)3 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)2 Calendar (java.util.Calendar)1 ProductStatus (org.mifos.framework.components.batchjobs.helpers.ProductStatus)1 CronTrigger (org.quartz.CronTrigger)1 JobDataMap (org.quartz.JobDataMap)1 JobDetail (org.quartz.JobDetail)1 JobExecutionContext (org.quartz.JobExecutionContext)1 Scheduler (org.quartz.Scheduler)1 BaseCalendar (org.quartz.impl.calendar.BaseCalendar)1 TriggerFiredBundle (org.quartz.spi.TriggerFiredBundle)1 JobParameters (org.springframework.batch.core.JobParameters)1