use of org.finra.herd.model.api.xml.JobUpdateRequest in project herd by FINRAOS.
the class JobServiceTest method testUpdateJobTrimParameters.
@Test
public void testUpdateJobTrimParameters() throws Exception {
// Create a test job definition.
jobDefinitionServiceTestHelper.createJobDefinition(ACTIVITI_XML_TEST_USER_TASK_WITH_CLASSPATH);
// Create and start the job.
Job job = jobService.createAndStartJob(jobServiceTestHelper.createJobCreateRequest(TEST_ACTIVITI_NAMESPACE_CD, TEST_ACTIVITI_JOB_NAME));
// Job should be waiting at User task.
// Get the running job with non verbose.
Job jobGet = jobService.getJob(job.getId(), false);
assertEquals(JobStatusEnum.RUNNING, jobGet.getStatus());
assertNull(jobGet.getActivitiJobXml());
assertTrue(CollectionUtils.isEmpty(jobGet.getCompletedWorkflowSteps()));
assertEquals("usertask1", jobGet.getCurrentWorkflowStep().getId());
// Suspend the job using input parameters with leading and trailing empty spaces.
jobService.updateJob(addWhitespace(job.getId()), new JobUpdateRequest(JobActionEnum.SUSPEND));
// Validate that the job is suspended.
jobGet = jobService.getJob(job.getId(), false);
assertEquals(JobStatusEnum.SUSPENDED, jobGet.getStatus());
assertNull(jobGet.getActivitiJobXml());
assertTrue(CollectionUtils.isEmpty(jobGet.getCompletedWorkflowSteps()));
assertEquals("usertask1", jobGet.getCurrentWorkflowStep().getId());
// Resume the job using input parameters with leading and trailing empty spaces.
jobService.updateJob(addWhitespace(job.getId()), new JobUpdateRequest(JobActionEnum.RESUME));
// Validate that the job is running.
jobGet = jobService.getJob(job.getId(), false);
assertEquals(JobStatusEnum.RUNNING, jobGet.getStatus());
assertNull(jobGet.getActivitiJobXml());
assertTrue(CollectionUtils.isEmpty(jobGet.getCompletedWorkflowSteps()));
assertEquals("usertask1", jobGet.getCurrentWorkflowStep().getId());
// Query the pending task and complete it
List<Task> tasks = activitiTaskService.createTaskQuery().processInstanceId(job.getId()).list();
activitiTaskService.complete(tasks.get(0).getId());
// Job should have been completed.
// Get the completed job with non verbose.
jobGet = jobService.getJob(job.getId(), false);
assertEquals(JobStatusEnum.COMPLETED, jobGet.getStatus());
assertNotNull(jobGet.getStartTime());
assertNotNull(jobGet.getEndTime());
assertNull(jobGet.getActivitiJobXml());
assertTrue(CollectionUtils.isEmpty(jobGet.getCompletedWorkflowSteps()));
assertNull(jobGet.getCurrentWorkflowStep());
}
use of org.finra.herd.model.api.xml.JobUpdateRequest in project herd by FINRAOS.
the class JobServiceTest method testUpdateJobMissingRequiredParameters.
@Test
public void testUpdateJobMissingRequiredParameters() {
// Try to update a job when job id is not specified.
try {
jobService.updateJob(BLANK_TEXT, new JobUpdateRequest(JobActionEnum.RESUME));
fail();
} catch (IllegalArgumentException e) {
assertEquals("A job id must be specified.", e.getMessage());
}
// Try to update a job when job update request is not specified.
try {
jobService.updateJob(INTEGER_VALUE.toString(), null);
fail();
} catch (IllegalArgumentException e) {
assertEquals("A job update request must be specified.", e.getMessage());
}
// Try to update a job when job update action is not specified.
try {
jobService.updateJob(INTEGER_VALUE.toString(), new JobUpdateRequest(null));
fail();
} catch (IllegalArgumentException e) {
assertEquals("A job update action must be specified.", e.getMessage());
}
}
Aggregations