CoordinatorActionBean ca3 = addRecordToCoordActionTable(job.getId(), 3, CoordinatorAction.Status.WAITING,
"coord-action-get.xml", 0);
CoordinatorActionBean ca4 = addRecordToCoordActionTable(job.getId(), 4, CoordinatorAction.Status.WAITING,
"coord-action-get.xml", 0);
SLARegistrationBean slaRegBean1 = new SLARegistrationBean();
slaRegBean1.setId(ca1.getId());
SLARegistrationBean slaRegBean2 = new SLARegistrationBean();
slaRegBean2.setId(ca2.getId());
SLARegistrationBean slaRegBean3 = new SLARegistrationBean();
slaRegBean3.setId(ca3.getId());
SLARegistrationBean slaRegBean4 = new SLARegistrationBean();
slaRegBean4.setId(ca4.getId());
SLASummaryBean slaSummaryBean1 = new SLASummaryBean();
slaSummaryBean1.setId(ca1.getId());
SLASummaryBean slaSummaryBean3 = new SLASummaryBean();
slaSummaryBean3.setId(ca3.getId());
List<JsonBean> insertList = new ArrayList<JsonBean>();
insertList.add(slaRegBean1);
insertList.add(slaRegBean2);
insertList.add(slaRegBean3);
insertList.add(slaRegBean4);
insertList.add(slaSummaryBean1);
insertList.add(slaSummaryBean3);
JPAService jpaService = Services.get().get(JPAService.class);
jpaService.execute(new SLACalculationInsertUpdateJPAExecutor(insertList, null));
new CoordChangeXCommand(job.getId(), pauseTimeChangeStr).call();
CoordJobGetJPAExecutor coordGetCmd = new CoordJobGetJPAExecutor(job.getId());
CoordinatorJobBean coordJob = jpaService.execute(coordGetCmd);
assertEquals(DateUtils.formatDateOozieTZ(coordJob.getPauseTime()), DateUtils.formatDateOozieTZ(pauseTime));
assertEquals(Job.Status.RUNNING, coordJob.getStatus());
assertEquals(2, coordJob.getLastActionNumber());
try {
jpaService.execute(new CoordJobGetActionByActionNumberJPAExecutor(job.getId(), 3));
fail("Expected to fail as action 3 should have been deleted");
}
catch (JPAExecutorException jpae) {
assertEquals(ErrorCode.E0603, jpae.getErrorCode());
jpae.printStackTrace();
}
try {
jpaService.execute(new CoordJobGetActionByActionNumberJPAExecutor(job.getId(), 4));
fail("Expected to fail as action 4 should have been deleted");
}
catch (JPAExecutorException jpae) {
assertEquals(ErrorCode.E0603, jpae.getErrorCode());
jpae.printStackTrace();
}
slaRegBean1 = jpaService.execute(new SLARegistrationGetJPAExecutor(slaRegBean1.getId()));
assertNotNull(slaRegBean1);
slaRegBean2 = jpaService.execute(new SLARegistrationGetJPAExecutor(slaRegBean2.getId()));
assertNotNull(slaRegBean2);
slaRegBean3 = jpaService.execute(new SLARegistrationGetJPAExecutor(slaRegBean3.getId()));
assertNull(slaRegBean3);
slaRegBean4 = jpaService.execute(new SLARegistrationGetJPAExecutor(slaRegBean4.getId()));
assertNull(slaRegBean4);
slaSummaryBean3 = jpaService.execute(new SLASummaryGetJPAExecutor(slaSummaryBean3.getId()));
assertNull(slaSummaryBean3);
slaSummaryBean1 = jpaService.execute(new SLASummaryGetJPAExecutor(slaSummaryBean1.getId()));
assertNotNull(slaSummaryBean1);