@Override @Nullable public JobInstance getJobInstance(JobExecution jobExecution) { return jobExecution.getJobInstance(); }
/** * Convenient accessor for current job name identifier. * * @return the job name identifier of the enclosing {@link JobInstance} associated with the current * {@link JobExecution} */ public String getJobName() { Assert.state(jobExecution.getJobInstance() != null, "JobExecution does not have a JobInstance"); return jobExecution.getJobInstance().getJobName(); }
@Override public String getJobName() { return jobExecution.getJobInstance().getJobName(); }
@Override public String getJobName() { return this.execution.getJobInstance().getJobName(); }
@Override public Set<JobExecution> findRunningJobExecutions(String jobName) { Set<JobExecution> result = new HashSet<>(); for (JobExecution exec : executionsById.values()) { if (!exec.getJobInstance().getJobName().equals(jobName) || !exec.isRunning()) { continue; } result.add(copy(exec)); } return result; }
/** * Convenient accessor for current job name identifier. * * @return the job name identifier of the enclosing {@link JobInstance} * associated with the current {@link StepExecution} */ public String getJobName() { Assert.state(stepExecution.getJobExecution() != null, "StepExecution does not have a JobExecution"); Assert.state(stepExecution.getJobExecution().getJobInstance() != null, "StepExecution does not have a JobInstance"); return stepExecution.getJobExecution().getJobInstance().getJobName(); }
/** * Convenient accessor for current job identifier. * * @return the job identifier of the enclosing {@link JobInstance} * associated with the current {@link StepExecution} */ public Long getJobId() { Assert.state(stepExecution.getJobExecution() != null, "StepExecution does not have a JobExecution"); Assert.state(stepExecution.getJobExecution().getJobInstance() != null, "StepExecution does not have a JobInstance"); return stepExecution.getJobExecution().getJobInstance().getId(); }
@Override public JobInstance getJobInstance(long executionId) throws NoSuchJobExecutionException, JobSecurityException { org.springframework.batch.core.JobExecution execution = jobExplorer.getJobExecution(executionId); if(execution == null) { throw new NoSuchJobExecutionException("The JobExecution was not found"); } return jobExplorer.getJobInstance(execution.getJobInstance().getId()); }
@Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); Properties properties = new Properties(); properties.put("jobLevelProperty1", "jobLevelValue1"); context = new JsrJobContext(); context.setProperties(properties); context.setJobExecution(execution); when(execution.getJobInstance()).thenReturn(instance); }
@Override public StepExecution doInTransaction(TransactionStatus status) { return jobRepository.getLastStepExecution(jobExecution.getJobInstance(), step.getName()); } });
/** * Test method for * {@link org.springframework.batch.core.JobExecution#getJobId()}. */ @Test public void testGetJob() { assertNotNull(execution.getJobInstance()); }
@Test public void testContextContainsInfo() throws Exception { assertEquals("foo", execution.getJobInstance().getJobName()); }
@Transactional @Test public void testCreateAndFindWithNoStartDate() throws Exception { job.setRestartable(true); JobExecution firstExecution = jobRepository.createJobExecution(job.getName(), jobParameters); firstExecution.setStartTime(new Date(0)); firstExecution.setEndTime(new Date(1)); jobRepository.update(firstExecution); JobExecution secondExecution = jobRepository.createJobExecution(job.getName(), jobParameters); assertEquals(firstExecution.getJobInstance(), secondExecution.getJobInstance()); assertEquals(job.getName(), secondExecution.getJobInstance().getJobName()); }
@Override public void beforeStep(StepExecution stepExecution) { this.jobName = stepExecution.getJobExecution().getJobInstance().getJobName().trim(); this.stepName = (String) stepExecution.getJobExecution().getExecutionContext().get("stepName"); this.stepExecution = stepExecution; stepExecution.getJobExecution().getExecutionContext().remove("stepName"); }
private void checkRepository(BatchStatus status, ExitStatus exitStatus) { // because map dao stores in memory, it can be checked directly JobInstance jobInstance = jobExecution.getJobInstance(); JobExecution other = jobExecutionDao.findJobExecutions(jobInstance).get(0); assertEquals(jobInstance.getId(), other.getJobId()); assertEquals(status, other.getStatus()); if (exitStatus != null) { assertEquals(exitStatus.getExitCode(), other.getExitStatus().getExitCode()); } }
private void checkRepository(BatchStatus status, ExitStatus exitStatus) { // because map DAO stores in memory, it can be checked directly JobInstance jobInstance = jobExecution.getJobInstance(); JobExecution other = jobExecutionDao.findJobExecutions(jobInstance).get(0); assertEquals(jobInstance.getId(), other.getJobId()); assertEquals(status, other.getStatus()); if (exitStatus != null) { assertEquals(exitStatus.getExitCode(), other.getExitStatus().getExitCode()); } }
@Test public void testJobParameters() throws Exception { JobParameters jobParameters = new JobParametersBuilder().addString("foo", "bar").toJobParameters(); JobInstance instance = stepExecution.getJobExecution().getJobInstance(); stepExecution = new StepExecution("step", new JobExecution(instance, jobParameters)); context = new StepContext(stepExecution); assertEquals("bar", context.getJobParameters().get("foo")); }
@Test public void testExecutionContextIsSet() throws Exception { testRunNormally(); assertEquals(jobInstance, jobExecution.getJobInstance()); assertEquals(2, jobExecution.getStepExecutions().size()); assertEquals(step1.getName(), stepExecution1.getStepName()); assertEquals(step2.getName(), stepExecution2.getStepName()); }
@Before public void onSetUp() throws Exception { repository = getJobRepository(); jobExecution = repository.createJobExecution("job", new JobParameters()); jobInstance = jobExecution.getJobInstance(); step = new StepSupport("foo"); stepExecution = new StepExecution(step.getName(), jobExecution); dao = getStepExecutionDao(); }
@Test public void testRestart() throws Exception { JobParametersBuilder paramBuilder = new JobParametersBuilder(); paramBuilder.addDate("value", new Date()); JobExecution jobExecution = jobRepository.createJobExecution(job.getName(), paramBuilder.toJobParameters()); job.execute(jobExecution); jobExecution = jobRepository.createJobExecution(job.getName(), paramBuilder.toJobParameters()); job.execute(jobExecution); int count = jobRepository.getStepExecutionCount(jobExecution.getJobInstance(), "simpleJob.step1"); assertEquals(2, count); } }