CalculateTaxProcessor extends StepExecutionListenerSupport implements ItemProcessor<Employee, TaxCalculation> { @Override public TaxCalculation process(Employee employee) { LOG.info("Tax process {} on {} ", employee, getCurrentEnvironment() + getPartitionIfExists()); Money calculatedTax = taxCalculatorService.calculateTax(employee); return TaxCalculation.from(stepExecution.getJobExecutionId(), employee, year.intValue(), month.intValue(), calculatedTax); }  @Override TaxCalculation process(Employee employee); @Override void beforeStep(StepExecution stepExecution);  }
@Test public void testProcess() throws Exception { Employee employee = new EmployeeTestBuilder().withIncome(100).build(); setInternalState(calculateTaxProcessor, "year", 2014L); setInternalState(calculateTaxProcessor, "month", 5L); setInternalState(calculateTaxProcessor, "stepExecution", stepExecution); when(stepExecution.getJobExecutionId()).thenReturn(123L); when(taxCalculatorService.calculateTax(employee)).thenReturn(Money.of(CurrencyUnit.EUR, 10)); TaxCalculation taxCalculation = calculateTaxProcessor.process(employee); assertThat(taxCalculation.getJobExecutionId()).isEqualTo(123L); assertThat(taxCalculation.getEmployee()).isEqualTo(employee); assertThat(taxCalculation.getYear()).isEqualTo(2014); assertThat(taxCalculation.getMonth()).isEqualTo(5); assertThat(taxCalculation.getTax()).isEqualTo(Money.of(CurrencyUnit.EUR, 10)); }