Package org.activiti.engine.runtime

Examples of org.activiti.engine.runtime.Job


    Task task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
    assertEquals("First line support", task.getName());

    // Manually execute the job
    ManagementService managementService = activitiRule.getManagementService();
    Job timer = managementService.createJobQuery().singleResult();
    managementService.executeJob(timer.getId());

    // The timer has fired, and the second task (secondlinesupport) now exists
    task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
    assertEquals("Handle escalated issue", task.getName());
  }
View Full Code Here


    // There should be one task, with a timer : first line support
    Task task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
    assertEquals("First line support", task.getName());

    // Manually execute the job
    Job timer = managementService.createJobQuery().singleResult();
    managementService.executeJob(timer.getId());

    // The timer has fired, and the second task (secondlinesupport) now exists
    task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
    assertEquals("Handle escalated issue", task.getName());
  }
View Full Code Here

  @Get
  public JobResponse getJob() {
    if(authenticate(SecuredResource.ADMIN) == false) return null;
   
    String jobId = (String) getRequest().getAttributes().get("jobId");
    Job job = ActivitiUtil.getManagementService().createJobQuery().jobId(jobId).singleResult();
    String stacktrace = ActivitiUtil.getManagementService().getJobExceptionStacktrace(jobId);
    JobResponse response = new JobResponse(job);
    response.setStacktrace(stacktrace);
    return response;
  }
View Full Code Here

    variables.put("routing", Routing.DEFAULT);
   
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(
        "ErrorHandling", variables);
     
    Job job = managementService.createJobQuery().processInstanceId(processInstance.getId()).singleResult();
    assertNotNull(job);
    managementService.executeJob(job.getId());
   
    Thread.sleep(WAIT);
   
    assertEquals("Process instance not completed", 0, runtimeService.createProcessInstanceQuery()
        .processInstanceId(processInstance.getId())
View Full Code Here

    variables.put("routing", Routing.HANDLE_ERROR);
   
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(
        "ErrorHandling", variables);
   
    Job job = managementService.createJobQuery().processInstanceId(processInstance.getId()).singleResult();
    assertNotNull(job);
    managementService.executeJob(job.getId());
   
    Thread.sleep(WAIT);
     
    assertEquals("Process instance did not reach next wait state", 1, runtimeService.createExecutionQuery()
        .processInstanceId(processInstance.getId())
View Full Code Here

  }

  private void verifyFailedJob(JobQuery query, ProcessInstance processInstance) {
    verifyQueryResults(query, 1);
   
    Job failedJob = query.singleResult();
    assertNotNull(failedJob);
    assertEquals(processInstance.getId(), failedJob.getProcessInstanceId());
    assertNotNull(failedJob.getExceptionMessage());
    assertTextPresent(EXCEPTION_MESSAGE, failedJob.getExceptionMessage());
  }
View Full Code Here

      .tenantId(TEST_TENANT_ID)
      .deploy()
      .getId();
   
    // verify job (timer start)
    Job job = managementService.createJobQuery().singleResult();
    assertEquals(TEST_TENANT_ID, job.getTenantId());
    managementService.executeJob(job.getId());
   
    // Verify Job tenancy (process intermediary timer)
    job = managementService.createJobQuery().singleResult();
    assertEquals(TEST_TENANT_ID, job.getTenantId());
   
    // Start process, and verify async job has correct tenant id
    managementService.executeJob(job.getId());
    job = managementService.createJobQuery().singleResult();
    assertEquals(TEST_TENANT_ID, job.getTenantId());
   
    // Finish process
    managementService.executeJob(job.getId());
   
    // Do the same, but now without a tenant
    String deploymentId2 = repositoryService.createDeployment()
        .addClasspathResource("org/activiti/engine/test/api/tenant/TenancyTest.testJobTenancy.bpmn20.xml")
        .deploy()
        .getId();
   
    job = managementService.createJobQuery().singleResult();
    assertEquals("", job.getTenantId());
    managementService.executeJob(job.getId());
    job = managementService.createJobQuery().singleResult();
    assertEquals("", job.getTenantId());
    managementService.executeJob(job.getId());
    job = managementService.createJobQuery().singleResult();
    assertEquals("", job.getTenantId());
   
    // clean up
    repositoryService.deleteDeployment(deploymentId, true);
    repositoryService.deleteDeployment(deploymentId2, true);
  }
View Full Code Here

   
    String newTenant = "newTenant";
    repositoryService.changeDeploymentTenantId(deploymentId, newTenant);
   
    // verify job (timer start)
    Job job = managementService.createJobQuery().singleResult();
    assertEquals(newTenant, job.getTenantId());
    managementService.executeJob(job.getId());
   
    // Verify Job tenancy (process intermediary timer)
    job = managementService.createJobQuery().singleResult();
    assertEquals(newTenant, job.getTenantId());
   
    // Start process, and verify async job has correct tenant id
    managementService.executeJob(job.getId());
    job = managementService.createJobQuery().singleResult();
    assertEquals(newTenant, job.getTenantId());
   
    // Finish process
    managementService.executeJob(job.getId());
   
    // clean up
    repositoryService.deleteDeployment(deploymentId, true);
  }
View Full Code Here

  public void testGetJobExceptionStacktrace() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("exceptionInJobExecution");
   
    // The execution is waiting in the first usertask. This contains a boundry
    // timer event which we will execute manual for testing purposes.
    Job timerJob = managementService.createJobQuery()
      .processInstanceId(processInstance.getId())
      .singleResult();
   
    assertNotNull("No job found for process instance", timerJob);
   
    try {
      managementService.executeJob(timerJob.getId());
      fail("RuntimeException from within the script task expected");
    } catch(RuntimeException re) {
      assertTextPresent("This is an exception thrown from scriptTask", re.getCause().getMessage());
    }
   
    // Fetch the task to see that the exception that occurred is persisted
    timerJob = managementService.createJobQuery()
    .processInstanceId(processInstance.getId())
    .singleResult();
   
    assertNotNull(timerJob);
    assertNotNull(timerJob.getExceptionMessage());
    assertTextPresent("This is an exception thrown from scriptTask", timerJob.getExceptionMessage());
   
    // Get the full stacktrace using the managementService
    String exceptionStack = managementService.getJobExceptionStacktrace(timerJob.getId());
    assertNotNull(exceptionStack);
    assertTextPresent("This is an exception thrown from scriptTask", exceptionStack);   
  }
View Full Code Here

  public void testSetJobRetries() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("exceptionInJobExecution");

    // The execution is waiting in the first usertask. This contains a boundary
    // timer event.
    Job timerJob = managementService.createJobQuery()
      .processInstanceId(processInstance.getId())
      .singleResult();
   
    assertNotNull("No job found for process instance", timerJob);
    assertEquals(JobEntity.DEFAULT_RETRIES, timerJob.getRetries());

    managementService.setJobRetries(timerJob.getId(), 5);

    timerJob = managementService.createJobQuery()
      .processInstanceId(processInstance.getId())
      .singleResult();
    assertEquals(5, timerJob.getRetries());
  }
View Full Code Here

TOP

Related Classes of org.activiti.engine.runtime.Job

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.