@Test public void testOnApplicationEventJobExecution() { final JobInstance instance = new JobInstance(1L, "testJob"); final JobExecution jobExecution = new JobExecution(1L); jobExecution.setJobInstance(instance); jobExecution.setExitStatus(ExitStatus.COMPLETED); final JobExecutionEvent jobExecutionEvent = new JobExecutionEvent(jobExecution, "testApplication"); this.onJobExecutionFinishedEventListener.onApplicationEvent(jobExecutionEvent); Mockito.verify(this.jobExecutionEventPublisher, Mockito.times(1)) .publishEvent(any(JobExecutionEventInfo.class)); }
@Override public void onApplicationEvent(final JobExecutionEvent jobExecutionEvent) { final JobExecution jobExecution = jobExecutionEvent.getJobExecution(); if (jobExecution != null) { log.info(jobExecution.getJobInstance().getJobName() + ", Status: " + jobExecution.getStatus().getBatchStatus() + ", Exit: " + jobExecution.getExitStatus().getExitCode()); final JobExecutionEventInfo jobExecutionEventInfo = EventTransformer.transformToJobExecutionEventInfo( jobExecution, jobExecutionEvent.getApplicationName()); this.jobExecutionEventPublisher.publishEvent(jobExecutionEventInfo); jobExecution.getStepExecutions() .stream() .map(step -> EventTransformer.transformToStepExecutionEventInfo(step, jobExecutionEvent.getApplicationName())) .forEach(this.stepExecutionEventPublisher::publishEvent); } else { log.debug("could not fire JobExcutionEvent, exitStatus was null"); } }
OnJobExecutionFinishedEventListener implements ApplicationListener<JobExecutionEvent> { @Override public void onApplicationEvent(final JobExecutionEvent jobExecutionEvent) { final JobExecution jobExecution = jobExecutionEvent.getJobExecution(); if (jobExecution != null) { log.info(jobExecution.getJobInstance().getJobName() + ", Status: " + jobExecution.getStatus().getBatchStatus() + ", Exit: " + jobExecution.getExitStatus().getExitCode()); final JobExecutionEventInfo jobExecutionEventInfo = EventTransformer.transformToJobExecutionEventInfo( jobExecution, jobExecutionEvent.getApplicationName()); this.jobExecutionEventPublisher.publishEvent(jobExecutionEventInfo); jobExecution.getStepExecutions() .stream() .map(step -> EventTransformer.transformToStepExecutionEventInfo(step, jobExecutionEvent.getApplicationName())) .forEach(this.stepExecutionEventPublisher::publishEvent); } else { log.debug("could not fire JobExcutionEvent, exitStatus was null"); } } }
OnJobExecutionFinishedEventListener implements ApplicationListener<JobExecutionEvent> { @Override public void onApplicationEvent(final JobExecutionEvent jobExecutionEvent) { final JobExecution jobExecution = jobExecutionEvent.getJobExecution(); if (jobExecution != null) { log.info(jobExecution.getJobInstance().getJobName() + ", Status: " + jobExecution.getStatus().getBatchStatus() + ", Exit: " + jobExecution.getExitStatus().getExitCode()); final JobExecutionEventInfo jobExecutionEventInfo = EventTransformer.transformToJobExecutionEventInfo( jobExecution, jobExecutionEvent.getApplicationName()); this.jobExecutionEventPublisher.publishEvent(jobExecutionEventInfo); jobExecution.getStepExecutions() .stream() .map(step -> EventTransformer.transformToStepExecutionEventInfo(step, jobExecutionEvent.getApplicationName())) .forEach(this.stepExecutionEventPublisher::publishEvent); } else { log.debug("could not fire JobExcutionEvent, exitStatus was null"); } } OnJobExecutionFinishedEventListener(final JobExecutionEventPublisher jobExecutionEventPublisher, final StepExecutionEventPublisher stepExecutionEventPublisher); }
OnJobExecutionFinishedEventListener implements ApplicationListener<JobExecutionEvent> { @Override public void onApplicationEvent(final JobExecutionEvent jobExecutionEvent) { final JobExecution jobExecution = jobExecutionEvent.getJobExecution(); if (jobExecution != null) { log.info(jobExecution.getJobInstance().getJobName() + ", Status: " + jobExecution.getStatus().getBatchStatus() + ", Exit: " + jobExecution.getExitStatus().getExitCode()); final JobExecutionEventInfo jobExecutionEventInfo = EventTransformer.transformToJobExecutionEventInfo( jobExecution, jobExecutionEvent.getApplicationName()); this.jobExecutionEventPublisher.publishEvent(jobExecutionEventInfo); jobExecution.getStepExecutions() .stream() .map(step -> EventTransformer.transformToStepExecutionEventInfo(step, jobExecutionEvent.getApplicationName())) .forEach(this.stepExecutionEventPublisher::publishEvent); } else { log.debug("could not fire JobExcutionEvent, exitStatus was null"); } } OnJobExecutionFinishedEventListener(final JobExecutionEventPublisher jobExecutionEventPublisher, final StepExecutionEventPublisher stepExecutionEventPublisher); @Override void onApplicationEvent(final JobExecutionEvent jobExecutionEvent); }
OnJobExecutionFinishedEventListener implements ApplicationListener<JobExecutionEvent> { @Override public void onApplicationEvent(final JobExecutionEvent jobExecutionEvent) { final JobExecution jobExecution = jobExecutionEvent.getJobExecution(); if (jobExecution != null) { log.info(jobExecution.getJobInstance().getJobName() + ", Status: " + jobExecution.getStatus().getBatchStatus() + ", Exit: " + jobExecution.getExitStatus().getExitCode()); final JobExecutionEventInfo jobExecutionEventInfo = EventTransformer.transformToJobExecutionEventInfo( jobExecution, jobExecutionEvent.getApplicationName()); this.jobExecutionEventPublisher.publishEvent(jobExecutionEventInfo); jobExecution.getStepExecutions() .stream() .map(step -> EventTransformer.transformToStepExecutionEventInfo(step, jobExecutionEvent.getApplicationName())) .forEach(this.stepExecutionEventPublisher::publishEvent); } else { log.debug("could not fire JobExcutionEvent, exitStatus was null"); } } OnJobExecutionFinishedEventListener(final JobExecutionEventPublisher jobExecutionEventPublisher, final StepExecutionEventPublisher stepExecutionEventPublisher); @Override void onApplicationEvent(final JobExecutionEvent jobExecutionEvent);  }