2022-10-12 10:19:53 -04:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
|
|
|
from SpiffWorkflow.bpmn.parser.ValidationException import ValidationException
|
|
|
|
from SpiffWorkflow.signavio.parser.bpmn import SignavioBpmnParser
|
|
|
|
from tests.SpiffWorkflow.bpmn.BpmnWorkflowTestCase import BpmnWorkflowTestCase
|
|
|
|
|
|
|
|
__author__ = 'matth'
|
|
|
|
|
|
|
|
class InvalidWorkflowsTest(BpmnWorkflowTestCase):
|
|
|
|
|
|
|
|
def testDisconnectedBoundaryEvent(self):
|
|
|
|
|
|
|
|
with self.assertRaises(ValidationException) as exc:
|
|
|
|
parser = SignavioBpmnParser()
|
|
|
|
filename = os.path.join(os.path.dirname(__file__), 'data', 'Invalid-Workflows/Disconnected-Boundary-Event.bpmn20.xml')
|
|
|
|
parser.add_bpmn_file(filename)
|
|
|
|
self.assertIn('Intermediate Catch Event has no incoming sequences', str(exc))
|
|
|
|
self.assertIn('bpmn:intermediateCatchEvent (id:sid-84C7CE67-D0B6-486A-B097-486DA924FF9D)', str(exc))
|
|
|
|
self.assertIn('Invalid-Workflows/Disconnected-Boundary-Event.bpmn20.xml', str(exc))
|
|
|
|
|
|
|
|
def testNoStartEvent(self):
|
|
|
|
try:
|
|
|
|
self.load_workflow_spec(
|
|
|
|
'Invalid-Workflows/No-Start-Event.bpmn20.xml', 'No Start Event')
|
|
|
|
self.fail(
|
|
|
|
"self.load_workflow_spec('Invalid-Workflows/No-Start-Event.bpmn20.xml', 'No Start Event') should fail.")
|
|
|
|
except ValidationException as ex:
|
|
|
|
self.assertTrue('No start event found' in ('%r' % ex),
|
|
|
|
'\'No start event found\' should be a substring of error message: \'%r\'' % ex)
|
2023-01-19 10:47:07 -05:00
|
|
|
self.assertTrue('No-Start-Event.bpmn20.xml' in ex.file_name,
|
2022-10-12 10:19:53 -04:00
|
|
|
'\'No-Start-Event.bpmn20.xml\' should be a substring of error message: \'%r\'' % ex)
|
|
|
|
|
|
|
|
def testSubprocessNotFound(self):
|
2023-01-19 10:47:07 -05:00
|
|
|
|
2022-10-12 10:19:53 -04:00
|
|
|
with self.assertRaises(ValidationException) as exc:
|
|
|
|
self.load_workflow_spec('Invalid-Workflows/Subprocess-Not-Found.bpmn20.xml', 'Subprocess Not Found')
|
|
|
|
self.assertIn("The process 'Missing subprocess' was not found.", str(exc))
|
|
|
|
self.assertIn("bpmn:callActivity (id:sid-617B0E1F-42DB-4D40-9B4C-ED631BF6E43A)", str(exc))
|
|
|
|
self.assertIn("Invalid-Workflows/Subprocess-Not-Found.bpmn20.xml", str(exc))
|
|
|
|
|
|
|
|
def testUnsupportedTask(self):
|
|
|
|
try:
|
|
|
|
self.load_workflow_spec(
|
|
|
|
'Invalid-Workflows/Unsupported-Task.bpmn20.xml', 'Unsupported Task')
|
|
|
|
self.fail(
|
|
|
|
"self.load_workflow_spec('Invalid-Workflows/Unsupported-Task.bpmn20.xml', 'Unsupported Task') should fail.")
|
|
|
|
except ValidationException as ex:
|
|
|
|
self.assertTrue(
|
|
|
|
'There is no support implemented for this task type' in (
|
|
|
|
'%r' % ex),
|
|
|
|
'\'There is no support implemented for this task type\' should be a substring of error message: \'%r\'' % ex)
|
2023-01-19 10:47:07 -05:00
|
|
|
self.assertTrue('Unsupported-Task.bpmn20.xml' in ex.file_name,
|
2022-10-12 10:19:53 -04:00
|
|
|
'\'Unsupported-Task.bpmn20.xml\' should be a substring of error message: \'%r\'' % ex)
|
2023-01-19 10:47:07 -05:00
|
|
|
self.assertTrue('businessRuleTask' in ex.tag,
|
|
|
|
'\'businessRuleTask\' should be a substring of the tag: \'%r\'' % ex)
|
|
|
|
self.assertTrue('Business Rule Task' in ex.name,
|
|
|
|
'\'Business Rule Task\' should be the name: \'%s\'' % ex.name)
|
2022-10-12 10:19:53 -04:00
|
|
|
|
|
|
|
|
|
|
|
def suite():
|
|
|
|
return unittest.TestLoader().loadTestsFromTestCase(InvalidWorkflowsTest)
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.TextTestRunner(verbosity=2).run(suite())
|