2022-10-12 10:19:53 -04:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
from SpiffWorkflow.task import TaskState
|
|
|
|
from SpiffWorkflow.bpmn.workflow import BpmnWorkflow
|
|
|
|
from SpiffWorkflow.bpmn.specs.events.event_definitions import MessageEventDefinition
|
|
|
|
from tests.SpiffWorkflow.bpmn.BpmnWorkflowTestCase import BpmnWorkflowTestCase
|
|
|
|
|
|
|
|
__author__ = 'matth'
|
|
|
|
|
|
|
|
|
|
|
|
class MessageNonInterruptsSpTest(BpmnWorkflowTestCase):
|
|
|
|
|
|
|
|
def setUp(self):
|
2022-10-27 10:50:48 -04:00
|
|
|
self.spec, self.subprocesses = self.load_workflow_spec('Test-Workflows/*.bpmn20.xml', 'Message Non Interrupt SP', False)
|
2022-10-12 10:19:53 -04:00
|
|
|
|
|
|
|
def testRunThroughHappySaveAndRestore(self):
|
|
|
|
|
|
|
|
self.workflow = BpmnWorkflow(self.spec, self.subprocesses)
|
|
|
|
self.save_restore()
|
|
|
|
|
|
|
|
self.workflow.do_engine_steps()
|
|
|
|
self.save_restore()
|
|
|
|
|
|
|
|
self.assertEqual(1, len(self.workflow.get_tasks(TaskState.READY)))
|
|
|
|
self.assertEqual(2, len(self.workflow.get_tasks(TaskState.WAITING)))
|
|
|
|
|
|
|
|
self.do_next_exclusive_step('Do Something In a Subprocess')
|
|
|
|
self.workflow.do_engine_steps()
|
|
|
|
self.save_restore()
|
|
|
|
|
|
|
|
self.do_next_exclusive_step('Ack Subprocess Done')
|
|
|
|
self.workflow.do_engine_steps()
|
|
|
|
self.save_restore()
|
|
|
|
|
|
|
|
self.workflow.do_engine_steps()
|
|
|
|
self.assertEqual(
|
|
|
|
0, len(self.workflow.get_tasks(TaskState.READY | TaskState.WAITING)))
|
|
|
|
|
|
|
|
def testRunThroughMessageSaveAndRestore(self):
|
|
|
|
|
|
|
|
self.workflow = BpmnWorkflow(self.spec, self.subprocesses)
|
|
|
|
self.save_restore()
|
|
|
|
|
|
|
|
self.workflow.do_engine_steps()
|
|
|
|
self.save_restore()
|
|
|
|
|
|
|
|
self.assertEqual(1, len(self.workflow.get_tasks(TaskState.READY)))
|
|
|
|
self.assertEqual(2, len(self.workflow.get_tasks(TaskState.WAITING)))
|
|
|
|
|
|
|
|
self.workflow.catch(MessageEventDefinition('Test Message'))
|
|
|
|
|
|
|
|
self.do_next_named_step('Do Something In a Subprocess')
|
|
|
|
self.workflow.do_engine_steps()
|
|
|
|
self.save_restore()
|
|
|
|
|
|
|
|
self.do_next_named_step('Ack Subprocess Done')
|
|
|
|
self.workflow.do_engine_steps()
|
|
|
|
self.save_restore()
|
|
|
|
|
|
|
|
self.do_next_named_step('Acknowledge SP Parallel Message')
|
|
|
|
self.workflow.do_engine_steps()
|
|
|
|
self.save_restore()
|
|
|
|
|
|
|
|
self.workflow.do_engine_steps()
|
|
|
|
self.assertEqual(
|
|
|
|
0, len(self.workflow.get_tasks(TaskState.READY | TaskState.WAITING)))
|
|
|
|
|
|
|
|
def testRunThroughMessageOrder2SaveAndRestore(self):
|
|
|
|
|
|
|
|
self.workflow = BpmnWorkflow(self.spec, self.subprocesses)
|
|
|
|
self.save_restore()
|
|
|
|
|
|
|
|
self.workflow.do_engine_steps()
|
|
|
|
self.save_restore()
|
|
|
|
|
|
|
|
self.assertEqual(1, len(self.workflow.get_tasks(TaskState.READY)))
|
|
|
|
self.assertEqual(2, len(self.workflow.get_tasks(TaskState.WAITING)))
|
|
|
|
|
|
|
|
self.workflow.catch(MessageEventDefinition('Test Message'))
|
|
|
|
self.do_next_named_step('Do Something In a Subprocess')
|
|
|
|
self.workflow.do_engine_steps()
|
|
|
|
self.save_restore()
|
|
|
|
|
|
|
|
self.do_next_named_step('Acknowledge SP Parallel Message')
|
|
|
|
self.workflow.do_engine_steps()
|
|
|
|
self.save_restore()
|
|
|
|
|
|
|
|
self.do_next_named_step('Ack Subprocess Done')
|
|
|
|
self.workflow.do_engine_steps()
|
|
|
|
self.save_restore()
|
|
|
|
|
|
|
|
self.workflow.do_engine_steps()
|
|
|
|
self.assertEqual(
|
|
|
|
0, len(self.workflow.get_tasks(TaskState.READY | TaskState.WAITING)))
|
|
|
|
|
|
|
|
def testRunThroughMessageOrder3SaveAndRestore(self):
|
|
|
|
|
|
|
|
self.workflow = BpmnWorkflow(self.spec, self.subprocesses)
|
|
|
|
self.save_restore()
|
|
|
|
|
|
|
|
self.workflow.do_engine_steps()
|
|
|
|
self.save_restore()
|
|
|
|
|
|
|
|
self.assertEqual(1, len(self.workflow.get_tasks(TaskState.READY)))
|
|
|
|
self.assertEqual(2, len(self.workflow.get_tasks(TaskState.WAITING)))
|
|
|
|
|
|
|
|
self.workflow.catch(MessageEventDefinition('Test Message'))
|
|
|
|
|
|
|
|
self.do_next_named_step('Acknowledge SP Parallel Message')
|
|
|
|
self.workflow.do_engine_steps()
|
|
|
|
self.save_restore()
|
|
|
|
|
|
|
|
self.do_next_named_step('Do Something In a Subprocess')
|
|
|
|
self.workflow.do_engine_steps()
|
|
|
|
self.save_restore()
|
|
|
|
|
|
|
|
self.do_next_named_step('Ack Subprocess Done')
|
|
|
|
self.workflow.do_engine_steps()
|
|
|
|
self.save_restore()
|
|
|
|
|
|
|
|
self.workflow.do_engine_steps()
|
|
|
|
self.assertEqual(
|
|
|
|
0, len(self.workflow.get_tasks(TaskState.READY | TaskState.WAITING)))
|
|
|
|
|
|
|
|
|
|
|
|
def suite():
|
|
|
|
return unittest.TestLoader().loadTestsFromTestCase(MessageNonInterruptsSpTest)
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.TextTestRunner(verbosity=2).run(suite())
|