JobResultsTasklet implements Tasklet { @Override public RepeatStatus execute(StepContribution stepContribution, ChunkContext chunkContext) throws PDFGenerationException { Long jobExecutionId = chunkContext.getStepContext().getStepExecution().getJobExecutionId(); monthlyTaxReportService.generateReport(jobExecutionId, year.intValue(), month.intValue()); return FINISHED; }  @Override RepeatStatus execute(StepContribution stepContribution, ChunkContext chunkContext);  }
@Test public void testExecuteCallsService() throws Exception { when(chunkContextMock.getStepContext()).thenReturn(new StepContext(new StepExecution("stepName", new JobExecution(JOB_EXECUTION_ID), 123L))); setInternalState(jobResultsTasklet, "month", 2L); setInternalState(jobResultsTasklet, "year", 2015L); jobResultsTasklet.execute(stepContributionMock, chunkContextMock); verify(monthlyTaxReportServiceMock).generateReport(12345L, 2015, 2); }