Class JobHandler

java.lang.Object
org.camunda.community.bpmndt.api.JobHandler

public class JobHandler extends Object
Fluent API to handle jobs (asynchronous continuation and timer catch events).
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    Possible job cardinalities.
  • Constructor Summary

    Constructors
    Constructor
    Description
    JobHandler(org.camunda.bpm.engine.ProcessEngine processEngine, String activityId)
     
    JobHandler(org.camunda.bpm.engine.ProcessEngine processEngine, String activityId, JobHandler.Cardinality cardinality)
    Creates a new job handler.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    apply(org.camunda.bpm.engine.runtime.ProcessInstance pi)
     
    Customizes the handler, using the given Consumer function.
    void
    Executes the job with an action that calls executeJob, when the process instance is waiting at the corresponding activity.
    void
    execute(Consumer<org.camunda.bpm.engine.runtime.Job> action)
    Executes a custom action that handles the job, when the process instance is waiting at the corresponding activity.
    protected void
    execute(org.camunda.bpm.engine.runtime.Job job)
     
    verify(BiConsumer<org.camunda.bpm.engine.test.assertions.bpmn.ProcessInstanceAssert,org.camunda.bpm.engine.test.assertions.bpmn.JobAssert> verifier)
    Verifies the job's waiting state.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • JobHandler

      public JobHandler(org.camunda.bpm.engine.ProcessEngine processEngine, String activityId)
    • JobHandler

      public JobHandler(org.camunda.bpm.engine.ProcessEngine processEngine, String activityId, JobHandler.Cardinality cardinality)
      Creates a new job handler. This constructor is used in the context of multi instance activities.
      Parameters:
      processEngine - The used process engine.
      activityId - The ID of the related activity.
      cardinality - Expected job cardinality.
  • Method Details

    • apply

      protected void apply(org.camunda.bpm.engine.runtime.ProcessInstance pi)
    • customize

      public JobHandler customize(Consumer<JobHandler> customizer)
      Customizes the handler, using the given Consumer function. This method can be used to apply a common customization needed for different test cases.
       tc.handleJob().customize(this::prepareJob);
       
      Parameters:
      customizer - A function that accepts a JobHandler.
      Returns:
      The handler.
    • execute

      public void execute()
      Executes the job with an action that calls executeJob, when the process instance is waiting at the corresponding activity. Please note: this is the default behavior.
      See Also:
      • ManagementService.executeJob(String)
    • execute

      public void execute(Consumer<org.camunda.bpm.engine.runtime.Job> action)
      Executes a custom action that handles the job, when the process instance is waiting at the corresponding activity.
      Parameters:
      action - A specific action that accepts the related Job.
      Throws:
      IllegalArgumentException - if action is null.
    • execute

      protected void execute(org.camunda.bpm.engine.runtime.Job job)
    • verify

      public JobHandler verify(BiConsumer<org.camunda.bpm.engine.test.assertions.bpmn.ProcessInstanceAssert,org.camunda.bpm.engine.test.assertions.bpmn.JobAssert> verifier)
      Verifies the job's waiting state.
      Parameters:
      verifier - Verifier that accepts an ProcessInstanceAssert and an JobAssert instance.
      Returns:
      The handler.