CoordinatorJobBean coordJob = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, false, false);
// Create a workflow job with RUNNING status
WorkflowJobBean wfJob1 = this
.addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
// Create a coordinator job with RUNNING status
CoordinatorActionBean action1 = addRecordToCoordActionTable(coordJob.getId(), 1,
CoordinatorAction.Status.RUNNING, "coord-action-get.xml", wfJob1.getId(), "RUNNING", 0);
// Create a coordinator job with WAITING status
CoordinatorActionBean action2 = addRecordToCoordActionTable(coordJob.getId(), 2,
CoordinatorAction.Status.WAITING, "coord-action-get.xml", null, null, 0);
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
CoordJobGetJPAExecutor coordJobGetCmd = new CoordJobGetJPAExecutor(coordJob.getId());
CoordActionGetJPAExecutor coordActionGetCmd1 = new CoordActionGetJPAExecutor(action1.getId());
CoordActionGetJPAExecutor coordActionGetCmd2 = new CoordActionGetJPAExecutor(action2.getId());
coordJob = jpaService.execute(coordJobGetCmd);
action1 = jpaService.execute(coordActionGetCmd1);
action2 = jpaService.execute(coordActionGetCmd2);
// Make sure the status is updated
assertEquals(coordJob.getStatus(), CoordinatorJob.Status.RUNNING);
assertEquals(action1.getStatus(), CoordinatorAction.Status.RUNNING);
assertEquals(action2.getStatus(), CoordinatorAction.Status.WAITING);
// Issue the kill command
new CoordKillXCommand(coordJob.getId()).call();
coordJob = jpaService.execute(coordJobGetCmd);
action1 = jpaService.execute(coordActionGetCmd1);
action2 = jpaService.execute(coordActionGetCmd2);
// Check the status and pending flag after kill command is issued
assertEquals(coordJob.getStatus(), CoordinatorJob.Status.KILLED);
assertEquals(action1.getStatus(), CoordinatorAction.Status.KILLED);
// The wf job is running and can be killed, so pending for coord action
// kill should be true
assertEquals(action1.getPending(), 1);
assertEquals(action2.getStatus(), CoordinatorAction.Status.KILLED);
// The coord job is waiting and no wf created yet, so pending for coord
// action kill should be false
assertEquals(action2.getPending(), 0);
}