Search in sources :

Example 6 with JobUpdateRequest

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());
}
Also used : JobUpdateRequest(org.finra.herd.model.api.xml.JobUpdateRequest) Task(org.activiti.engine.task.Task) Job(org.finra.herd.model.api.xml.Job) Test(org.junit.Test)

Example 7 with JobUpdateRequest

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());
    }
}
Also used : JobUpdateRequest(org.finra.herd.model.api.xml.JobUpdateRequest) Test(org.junit.Test)

Aggregations

JobUpdateRequest (org.finra.herd.model.api.xml.JobUpdateRequest)7 Test (org.junit.Test)7 Job (org.finra.herd.model.api.xml.Job)6 Task (org.activiti.engine.task.Task)4 HashMap (java.util.HashMap)1 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)1 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)1 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)1 JobDeleteRequest (org.finra.herd.model.api.xml.JobDeleteRequest)1 JobStatusEnum (org.finra.herd.model.api.xml.JobStatusEnum)1 JobSummaries (org.finra.herd.model.api.xml.JobSummaries)1 JobDefinitionEntity (org.finra.herd.model.jpa.JobDefinitionEntity)1 Transactional (org.springframework.transaction.annotation.Transactional)1