Search in sources :

Example 1 with ExitStatus

use of org.springframework.batch.core.ExitStatus in project hub-alert by blackducksoftware.

the class CommonConfigTest method testRun.

@Test
public void testRun() throws Exception {
    final SimpleJobLauncher simpleJobLauncher = Mockito.mock(SimpleJobLauncher.class);
    C config = getConfigWithSimpleJobLauncher(simpleJobLauncher);
    final JobExecution jobExecution = Mockito.mock(JobExecution.class);
    final ExitStatus exitStatus = Mockito.mock(ExitStatus.class);
    Mockito.when(exitStatus.getExitCode()).thenReturn("exit");
    Mockito.when(exitStatus.getExitDescription()).thenReturn("description");
    Mockito.when(jobExecution.getExitStatus()).thenReturn(exitStatus);
    Mockito.when(simpleJobLauncher.run(Mockito.any(), Mockito.any())).thenReturn(jobExecution);
    config = Mockito.spy(config);
    final Job job = Mockito.mock(Job.class);
    Mockito.doReturn(job).when(config).createJob(Mockito.any(), Mockito.any(), Mockito.any());
    config.run();
    final boolean successfulRun = outputLogger.isLineContainingText("Job finished with status");
    assertTrue(successfulRun);
}
Also used : JobExecution(org.springframework.batch.core.JobExecution) ExitStatus(org.springframework.batch.core.ExitStatus) SimpleJobLauncher(org.springframework.batch.core.launch.support.SimpleJobLauncher) Job(org.springframework.batch.core.Job) Test(org.junit.Test)

Example 2 with ExitStatus

use of org.springframework.batch.core.ExitStatus in project nixmash-blog by mintster.

the class GithubJobListener method afterJob.

@Override
public void afterJob(JobExecution jobExecution) {
    if (jobExecution.getStatus() == BatchStatus.COMPLETED) {
        long statId = (long) jobExecution.getExecutionContext().get("statId");
        logger.info("!!! GITHUB JOB FINISHED! CURRENT STATID: " + statId);
        ExitStatus es = jobExecution.getExitStatus();
        jobExecution.setExitStatus(new ExitStatus(es.getExitCode(), String.valueOf(statId)));
    }
}
Also used : ExitStatus(org.springframework.batch.core.ExitStatus)

Aggregations

ExitStatus (org.springframework.batch.core.ExitStatus)2 Test (org.junit.Test)1 Job (org.springframework.batch.core.Job)1 JobExecution (org.springframework.batch.core.JobExecution)1 SimpleJobLauncher (org.springframework.batch.core.launch.support.SimpleJobLauncher)1