public void testBundlePurgeXCommandFailed() throws Exception {
BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.RUNNING, DateUtils.parseDateUTC("2011-01-01T01:00Z"));
this.addRecordToBundleActionTable(job.getId(), "action1", 0, Job.Status.RUNNING);
this.addRecordToBundleActionTable(job.getId(), "action2", 0, Job.Status.SUCCEEDED);
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
BundleJobGetJPAExecutor bundleJobGetExecutor = new BundleJobGetJPAExecutor(job.getId());
job = jpaService.execute(bundleJobGetExecutor);
assertEquals(Job.Status.RUNNING, job.getStatus());
BundleActionGetJPAExecutor bundleActionGetExecutor1 = new BundleActionGetJPAExecutor(job.getId(), "action1");
BundleActionBean action1 = jpaService.execute(bundleActionGetExecutor1);
assertEquals(Job.Status.RUNNING, action1.getStatus());
BundleActionGetJPAExecutor bundleActionGetExecutor2 = new BundleActionGetJPAExecutor(job.getId(), "action2");
BundleActionBean action2 = jpaService.execute(bundleActionGetExecutor2);
assertEquals(Job.Status.SUCCEEDED, action2.getStatus());
new BundlePurgeXCommand(7, 10).call();
try {
job = jpaService.execute(bundleJobGetExecutor);
}
catch (JPAExecutorException je) {
// Job should exist. Exception is not expected.
fail("Job should exist. If not, fail it.");
}
try {
jpaService.execute(bundleActionGetExecutor1);
}
catch (JPAExecutorException je) {
// Job should exist. Exception is not expected.
fail("Action should exist. If not, fail it.");
}
try {
jpaService.execute(bundleActionGetExecutor2);
}
catch (JPAExecutorException je) {
// Job should exist. Exception is not expected.
fail("Action should exist. If not, fail it.");
}