public void testJobCommandsWithNestedFailingCommand() {
// create a job
createJob(TweetNestedCommandExceptionHandler.TYPE);
// execute the existing job
Job job = managementService.createJobQuery().singleResult();
assertEquals(3, job.getRetries());
try {
managementService.executeJob(job.getId());
fail("Exception expected");
} catch (Exception e) {
// expected
}
job = managementService.createJobQuery().singleResult();
assertEquals(2, job.getRetries());
executeAvailableJobs();
// the job execution failed (job.retries = 0)
job = managementService.createJobQuery().noRetriesLeft().singleResult();
assertNotNull(job);
assertEquals(0, job.getRetries());
}