@SuppressWarnings("unchecked")
@Test
public void testBatchCSVDatabase() throws Exception {
JobOperator jobOperator = BatchRuntime.getJobOperator();
Long executionId = jobOperator.start("myJob", new Properties());
JobExecution jobExecution = jobOperator.getJobExecution(executionId);
jobExecution = BatchTestHelper.keepTestAlive(jobExecution);
List<StepExecution> stepExecutions = jobOperator.getStepExecutions(executionId);
for (StepExecution stepExecution : stepExecutions) {
if (stepExecution.getStepName().equals("myStep")) {
Map<Metric.MetricType, Long> metricsMap = BatchTestHelper.getMetricsMap(stepExecution.getMetrics());
(1)
assertEquals(7L, metricsMap.get(Metric.MetricType.READ_COUNT).longValue());
(2)
assertEquals(7L, metricsMap.get(Metric.MetricType.WRITE_COUNT).longValue());
(3)
assertEquals(3L, metricsMap.get(Metric.MetricType.COMMIT_COUNT).longValue());
}
}
Query query = entityManager.createNamedQuery("Person.findAll");
List<Person> persons = query.getResultList();
(4)
assertEquals(7L, persons.size());
(5)
assertEquals(jobExecution.getBatchStatus(), BatchStatus.COMPLETED);
}