public void testFailBundlePurgeXCommand() throws Exception {
BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.DONEWITHERROR, DateUtils.parseDateUTC("2011-01-01T01:00Z"));
this.addRecordToBundleActionTable(job.getId(), "action1", 0, Job.Status.FAILED);
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.DONEWITHERROR, job.getStatus());
BundleActionGetJPAExecutor bundleActionGetExecutor1 = new BundleActionGetJPAExecutor(job.getId(), "action1");
BundleActionBean action1 = jpaService.execute(bundleActionGetExecutor1);
assertEquals(Job.Status.FAILED, 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);
fail("Job should be purged. Should fail.");
}
catch (JPAExecutorException je) {
// Job doesn't exist. Exception is expected.
}
try {
jpaService.execute(bundleActionGetExecutor1);
fail("Action should be purged. Should fail.");
}
catch (JPAExecutorException je) {
// Job doesn't exist. Exception is expected.
}
try {
jpaService.execute(bundleActionGetExecutor2);
fail("Action should be purged. Should fail.");
}
catch (JPAExecutorException je) {
// Job doesn't exist. Exception is expected.
}