private List<Object[]> buildStepExecutionParameters(StepExecution stepExecution) { Assert.isNull( stepExecution.getId(), "to-be-saved (not updated) StepExecution can't already have an id assigned"); Assert.isNull( stepExecution.getVersion(), "to-be-saved (not updated) StepExecution can't already have a version assigned"); validateStepExecution(stepExecution); stepExecution.setId(stepExecutionIncrementer.nextLongValue()); stepExecution.incrementVersion(); // Should be 0 List<Object[]> parameters = new ArrayList<Object[]>(); String exitDescription = truncateExitDescription(stepExecution.getExitStatus().getExitDescription()); Object[] parameterValues = new Object[] { stepExecution.getId(), stepExecution.getVersion(), stepExecution.getStepName(), stepExecution.getJobExecutionId(), stepExecution.getStartTime(), stepExecution.getEndTime(), stepExecution.getStatus().toString(), stepExecution.getCommitCount(), stepExecution.getReadCount(), stepExecution.getFilterCount(), stepExecution.getWriteCount(), stepExecution.getExitStatus().getExitCode(), exitDescription, stepExecution.getReadSkipCount(), stepExecution.getWriteSkipCount(), stepExecution.getProcessSkipCount(), stepExecution.getRollbackCount(), stepExecution.getLastUpdated() }; Integer[] parameterTypes = new Integer[] { Types.BIGINT, Types.INTEGER, Types.VARCHAR, Types.BIGINT, Types.TIMESTAMP, Types.TIMESTAMP, Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.VARCHAR, Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.TIMESTAMP }; parameters.add(0, Arrays.copyOf(parameterValues, parameterValues.length)); parameters.add(1, Arrays.copyOf(parameterTypes, parameterTypes.length)); return parameters; }
@Test public void testProcess() throws Exception { // GIVEN 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)); // WHEN TaxCalculation taxCalculation = calculateTaxProcessor.process(employee); // THEN 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)); }