Package org.activiti.engine.runtime

Examples of org.activiti.engine.runtime.Job


    processEngineConfiguration.setClock(testClock);

    Date now = new Date();
    testClock.setCurrentTime(now);
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testRepetitionJobEvents");
    Job theJob = managementService.createJobQuery().processInstanceId(processInstance.getId()).singleResult();
    assertNotNull(theJob);

    // Check if create-event has been dispatched
    assertEquals(2, listener.getEventsReceived().size());
    ActivitiEvent event = listener.getEventsReceived().get(0);
View Full Code Here


    // GIVEN
    processEngineConfiguration.getClock().setCurrentTime(new Date());
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testTimerCancelledEvent");
    listener.clearEventsReceived();

    Job job = managementService.createJobQuery().processInstanceId(processInstance.getId()).singleResult();

    // WHEN
    managementService.deleteJob(job.getId());

    // THEN
    checkEventCount(1, ActivitiEventType.JOB_CANCELED);
  }
View Full Code Here

   * Test create, update and delete events of jobs entities.
   */
  @Deployment
  public void testJobEntityEventsException() throws Exception {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testJobEvents");
    Job theJob = managementService.createJobQuery().processInstanceId(processInstance.getId()).singleResult();
    assertNotNull(theJob);
   
    // Set retries to 1, to prevent multiple chains of events being thrown
    managementService.setJobRetries(theJob.getId(), 1);
   
    listener.clearEventsReceived();
   
    // Force timer to fire
    Calendar tomorrow = Calendar.getInstance();
    tomorrow.add(Calendar.DAY_OF_YEAR, 1);
    processEngineConfiguration.getClock().setCurrentTime(tomorrow.getTime());
    try {
      managementService.executeJob(theJob.getId());
      fail("Expected exception");
    } catch (Exception e) {
      // exception expected
    }
   
View Full Code Here

    runtimeService.suspendProcessInstanceById(processInstance.getId());
    assertEquals(1, managementService.createJobQuery().count());
   
    // The jobs should not be executed now
    processEngineConfiguration.getClock().setCurrentTime(new Date(now.getTime() + (60 * 60 * 1000))); // Timer is set to fire on 5 minutes
    Job job = managementService.createJobQuery().executable().singleResult();
    assertNull(job);
   
    assertEquals(1, managementService.createJobQuery().count());
   
    // Activation of the process instance should now allow for job execution
View Full Code Here

      processEngineConfiguration.getEventDispatcher().addEventListener(listener, ActivitiEventType.JOB_RETRIES_DECREMENTED);
     
      ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testSignal");
      assertNotNull(processInstance);
     
      Job signalJob = managementService.createJobQuery()
          .processInstanceId(processInstance.getId())
          .singleResult();
     
      try {
        managementService.executeJob(signalJob.getId());
        fail("Exception expected");
      } catch(ActivitiException ae) {
        // Ignore, expected exception
      }
     
      Job failedJob = managementService.createJobQuery()
          .withException()
          .processInstanceId(processInstance.getId())
          .singleResult();
     
      assertNotNull(failedJob);
      assertEquals(2, failedJob.getRetries());
     
      // One retry should have triggered dispatching of a retry-decrement event
      assertEquals(1, taskService.createTaskQuery().processInstanceId(processInstance.getId()).count());
     
      try {
        managementService.executeJob(failedJob.getId());
        fail("Exception expected");
      } catch(ActivitiException ae) {
        // Ignore, expected exception
        assertEquals(2, taskService.createTaskQuery().processInstanceId(processInstance.getId()).count());
      }
View Full Code Here

      processEngineConfiguration.getEventDispatcher().addEventListener(listener, ActivitiEventType.JOB_EXECUTION_FAILURE);
     
      ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testSignal");
      assertNotNull(processInstance);
     
      Job signalJob = managementService.createJobQuery()
          .processInstanceId(processInstance.getId())
          .singleResult();
     
      try {
        managementService.executeJob(signalJob.getId());
        fail("Exception expected");
      } catch(ActivitiException ae) {
        // Ignore, expected exception
      }
     
      Job failedJob = managementService.createJobQuery()
          .withException()
          .processInstanceId(processInstance.getId())
          .singleResult();
     
      assertNotNull(failedJob);
      assertEquals(2, failedJob.getRetries());
     
      // Three retries should each have triggered dispatching of a retry-decrement event
      assertEquals(0, taskService.createTaskQuery().processInstanceId(processInstance.getId()).count());
     
      try {
        managementService.executeJob(failedJob.getId());
        fail("Exception expected");
      } catch(ActivitiException ae) {
        // Ignore, expected exception
        assertEquals(0, taskService.createTaskQuery().processInstanceId(processInstance.getId()).count());
      }
View Full Code Here

   
    // Complete 1 tasks
    taskService.complete(taskService.createTaskQuery().singleResult().getId());
   
    // Fire timer
    Job timer = managementService.createJobQuery().singleResult();
    managementService.executeJob(timer.getId());
   
    Task taskAfterTimer = taskService.createTaskQuery().singleResult();
    assertEquals("taskAfterTimer", taskAfterTimer.getTaskDefinitionKey());
    taskService.complete(taskAfterTimer.getId());
    assertProcessEnded(procId);
View Full Code Here

  @Deployment
  public void testNonExclusiveService() {  
    // start process
    runtimeService.startProcessInstanceByKey("exclusive");
    // now there should be 1 non-exclusive job in the database:
    Job job = managementService.createJobQuery().singleResult();
    assertNotNull(job);
    assertFalse(((JobEntity)job).isExclusive());
              
    waitForJobExecutorToProcessAllJobs(6000L, 100L);
   
View Full Code Here

  @Deployment
  public void testExclusiveService() {  
    // start process
    runtimeService.startProcessInstanceByKey("exclusive");
    // now there should be 1 exclusive job in the database:
    Job job = managementService.createJobQuery().singleResult();
    assertNotNull(job);
    assertTrue(((JobEntity)job).isExclusive());
              
    waitForJobExecutorToProcessAllJobs(6000L, 100L);
   
View Full Code Here

   
    List<Task> tasks = taskService.createTaskQuery().list();
    taskService.complete(tasks.get(0).getId());
   
    // Fire timer
    Job timer = managementService.createJobQuery().singleResult();
    managementService.executeJob(timer.getId());
   
    Task taskAfterTimer = taskService.createTaskQuery().singleResult();
    assertEquals("taskAfterTimer", taskAfterTimer.getTaskDefinitionKey());
    taskService.complete(taskAfterTimer.getId());
    assertProcessEnded(procId);
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.