3 Replies Latest reply on Sep 14, 2009 12:19 PM by kukeltje

    [jBPM4] final state when async node is used

      Hello
      I start playing with sample availbale into 4.1 distribution.
      The EndStateTest is interesting because it test state value at end of workflow.

      I try to reproduce this with intermediary node with continue mode = "async".

      To to that i look at example: AsyncActivityTest and just modify test to add getState() at end of value (end force end note with state="complete") .

      State value is already "async"

      My question is: how do we know that a workfow is ended ?

      Regards
      Christophe

        • 1. Re: [jBPM4] final state when async node is used
          kukeltje

          if you retrieve the processinstance by id and it is null it was either not there to begin with or it is ended. If you are not sure, you can always check in the history. It should be there then.

          • 2. Re: [jBPM4] final state when async node is used

            The pb is not on getting a reference on processinstance.
            The pb is the final state value is not "complete".

            It's a pb because depending of continue mode, you do not have the same final result, and it means you'll have to know the worlflow containe to make some test.

            ex: just add the last assertEquals on provides AsynActivityTest:

            public void testEndStateCompleted() throws Exception {
             ProcessInstance processInstance = executionService
             .startProcessInstanceByKey("helloworld");
             String pid = processInstance.getId();
             System.out.println(processInstance.getState());
             Thread.sleep(500);
            
             Job job = managementService.createJobQuery()
             .processInstanceId(pid)
             .uniqueResult();
             managementService.executeJob(job.getId());
            
             //processInstance = executionService.signalExecutionById(pid, "toHello3");
             Thread.sleep(500);
             assertEquals("completed", processInstance.getState());
             assertTrue(processInstance.isEnded());
             }


            • 3. Re: [jBPM4] final state when async node is used
              kukeltje

              Your original question was:

              My question is: how do we know that a workfow is ended ?


              My answer was:

              if you retrieve the processinstance by id and it is null it was either not there to begin with or it is ended. If you are not sure, you can always check in the history. It should be there then.


              This is valid AND the truth. (Ab) using the getState is not the correct way, since if a process is really ended, the assertTrue(processInstance.isEnded());
              would produce a(n?) NPE since it is directly moved to the history table.

              So your reply seemed not related to me and I did not respond.

              Btw, If you post in the forum and make a Jira issue which is related, you can point that out in the jira issue. There is a specific field for that.

              Regarding tests in general, yes, for tests you have to know the workflow. That is what tests are for. So that is not an issue either (imo)

              If you could refine the test some more so the last statement does throw an NPE and the getState() still is not equal to 'completed', please get back to us.

              Hope this helps to clarify some things.