@Test
  public void taskTypeVarietyProcessTest() {
    this.ksession = this.createKnowledgeSession();

    // BEGIN: REGISTER EVENT LISTENER TO FIRE RULES FOR BUSINESS RULE TASK TO WORK
    final org.drools.event.AgendaEventListener agendaEventListener =
        new org.drools.event.AgendaEventListener() {
          public void activationCreated(ActivationCreatedEvent event, WorkingMemory workingMemory) {
            ksession.fireAllRules();
          }

          public void afterRuleFlowGroupActivated(
              RuleFlowGroupActivatedEvent event, WorkingMemory workingMemory) {
            workingMemory.fireAllRules();
          }

          public void activationCancelled(
              ActivationCancelledEvent event, WorkingMemory workingMemory) {}

          public void beforeActivationFired(
              BeforeActivationFiredEvent event, WorkingMemory workingMemory) {}

          public void afterActivationFired(
              AfterActivationFiredEvent event, WorkingMemory workingMemory) {}

          public void agendaGroupPopped(
              AgendaGroupPoppedEvent event, WorkingMemory workingMemory) {}

          public void agendaGroupPushed(
              AgendaGroupPushedEvent event, WorkingMemory workingMemory) {}

          public void beforeRuleFlowGroupActivated(
              RuleFlowGroupActivatedEvent event, WorkingMemory workingMemory) {}

          public void beforeRuleFlowGroupDeactivated(
              RuleFlowGroupDeactivatedEvent event, WorkingMemory workingMemory) {}

          public void afterRuleFlowGroupDeactivated(
              RuleFlowGroupDeactivatedEvent event, WorkingMemory workingMemory) {}
        };
    // adding it is a bit dirty for the time being, but it works:
    ((StatefulKnowledgeSessionImpl) ksession).session.addEventListener(agendaEventListener);
    // END: REGISTER EVENT LISTENER TO FIRE RULES FOR BUSINESS RULE TASK TO WORK

    // Register WorkItemManagers for all the generic tasks in the process
    HumanTaskMockHandler taskHandler1 = new HumanTaskMockHandler();
    TestAsyncWorkItemHandler taskHandler2 = new TestAsyncWorkItemHandler();
    ksession.getWorkItemManager().registerWorkItemHandler("Human Task", taskHandler1);
    ksession.getWorkItemManager().registerWorkItemHandler("mySpecialTaskType", taskHandler2);

    // Start the process using its id
    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put("input", "222");
    ProcessInstance process =
        ksession.startProcess("com.plugtree.training.taskTypeVarietyProcess", variables);

    Assert.assertEquals(ProcessInstance.STATE_ACTIVE, process.getState());
    taskHandler1.completeWorkItem();

    Assert.assertEquals(ProcessInstance.STATE_ACTIVE, process.getState());
    // we see the parameter in the last task
    Object param = taskHandler2.getWorkItemParameter("ruleExecution");
    Assert.assertNotNull(param);
    Assert.assertEquals("message", param);
    taskHandler2.complete();

    // after completing the last task, we finish the process
    Assert.assertEquals(ProcessInstance.STATE_COMPLETED, process.getState());
  }