def flow_invalid_case_1(): start = EmptyStartEvent(id=start_event_id) act_1 = ServiceActivity(id=act_id(1)) pg = ParallelGateway(id=parallel_gw_id(1)) act_2 = ServiceActivity(id=act_id(2)) act_3 = ServiceActivity(id=act_id(3)) eg = ExclusiveGateway(id=exclusive_gw_id(1), conditions={ 0: '123', 1: '456' }) act_4 = ServiceActivity(id=act_id(4)) cg = ConvergeGateway(id=converge_gw_id(1)) end = EmptyEndEvent(id=end_event_id) start.extend(act_1).extend(pg).connect( act_2, act_3, eg ).to(eg).connect( act_3, act_4 ) act_2.connect(cg) act_3.connect(cg) act_4.connect(cg) cg.extend(end) return build_tree(start)
def flow_valid_edge_case_1(): start = EmptyStartEvent(id=start_event_id) act_1 = ServiceActivity(id=act_id(1)) act_2 = ServiceActivity(id=act_id(2)) eg = ExclusiveGateway(id=exclusive_gw_id(1), conditions={ 0: '123', 1: '456', 2: '789' }) act_3 = ServiceActivity(id=act_id(3)) end = EmptyEndEvent(id=end_event_id) start.extend(act_1).extend(act_2).extend(eg).connect( act_1, act_2, act_3).to(act_3).extend(end) return build_tree(start)
def flow_valid_case(testcase): def _(num): return num - 1 def out_assert_case(length, out_set): return {'len': length, 'outgoing': out_set} outgoing_assert = { start_event_id: out_assert_case(1, {act_id(1)}), act_id(1): out_assert_case(1, {parallel_gw_id(1)}), parallel_gw_id(1): out_assert_case(3, {parallel_gw_id(2), act_id(5), act_id(6)}), parallel_gw_id(2): out_assert_case(3, {act_id(2), act_id(3), act_id(4)}), act_id(2): out_assert_case(1, {converge_gw_id(1)}), act_id(3): out_assert_case(1, {converge_gw_id(1)}), act_id(4): out_assert_case(1, {converge_gw_id(1)}), converge_gw_id(1): out_assert_case(1, {act_id(7)}), act_id(7): out_assert_case(1, {exclusive_gw_id(1)}), exclusive_gw_id(1): out_assert_case( 2, {parallel_gw_id(2), converge_gw_id(3)}), act_id(5): out_assert_case(1, {exclusive_gw_id(7)}), exclusive_gw_id(7): out_assert_case(2, {act_id(8), converge_gw_id(3)}), act_id(8): out_assert_case(1, {exclusive_gw_id(8)}), exclusive_gw_id(8): out_assert_case(2, {act_id(8), act_id(11)}), act_id(11): out_assert_case(1, {converge_gw_id(3)}), act_id(6): out_assert_case(1, {exclusive_gw_id(2)}), exclusive_gw_id(2): out_assert_case( 3, {act_id(6), act_id(9), act_id(10)}), act_id(9): out_assert_case(1, {converge_gw_id(2)}), act_id(10): out_assert_case(1, {converge_gw_id(2)}), converge_gw_id(2): out_assert_case(1, {act_id(12)}), act_id(12): out_assert_case(1, {exclusive_gw_id(6)}), exclusive_gw_id(6): out_assert_case( 3, {act_id(6), converge_gw_id(3), converge_gw_id(2)}), converge_gw_id(3): out_assert_case(1, {act_id(13)}), act_id(13): out_assert_case(1, {exclusive_gw_id(3)}), exclusive_gw_id(3): out_assert_case( 4, {end_event_id, act_id(14), parallel_gw_id(3), act_id(1)}), act_id(14): out_assert_case(1, {exclusive_gw_id(4)}), exclusive_gw_id(4): out_assert_case(2, {act_id(13), converge_gw_id(4)}), parallel_gw_id(3): out_assert_case( 3, {act_id(15), act_id(16), act_id(17)}), act_id(15): out_assert_case(1, {act_id(18)}), act_id(18): out_assert_case(1, {converge_gw_id(4)}), act_id(16): out_assert_case(1, {converge_gw_id(4)}), act_id(17): out_assert_case(1, {exclusive_gw_id(5)}), exclusive_gw_id(5): out_assert_case(2, {act_id(19), act_id(20)}), act_id(19): out_assert_case(1, {converge_gw_id(4)}), act_id(20): out_assert_case(1, {converge_gw_id(4)}), converge_gw_id(4): out_assert_case(1, {end_event_id}), end_event_id: out_assert_case(0, set()) } stream_assert = { start_event_id: MAIN_STREAM, act_id(1): MAIN_STREAM, parallel_gw_id(1): MAIN_STREAM, parallel_gw_id(2): 'pg_1_0', act_id(2): 'pg_2_0', act_id(3): 'pg_2_1', act_id(4): 'pg_2_2', converge_gw_id(1): 'pg_1_0', act_id(7): 'pg_1_0', exclusive_gw_id(1): 'pg_1_0', act_id(5): 'pg_1_1', exclusive_gw_id(7): 'pg_1_1', act_id(8): 'pg_1_1', exclusive_gw_id(8): 'pg_1_1', act_id(11): 'pg_1_1', act_id(6): 'pg_1_2', exclusive_gw_id(2): 'pg_1_2', act_id(9): 'pg_1_2', act_id(10): 'pg_1_2', converge_gw_id(2): 'pg_1_2', act_id(12): 'pg_1_2', exclusive_gw_id(6): 'pg_1_2', converge_gw_id(3): MAIN_STREAM, act_id(13): MAIN_STREAM, exclusive_gw_id(3): MAIN_STREAM, act_id(14): MAIN_STREAM, exclusive_gw_id(4): MAIN_STREAM, parallel_gw_id(3): MAIN_STREAM, act_id(15): 'pg_3_0', act_id(18): 'pg_3_0', act_id(16): 'pg_3_1', act_id(17): 'pg_3_2', exclusive_gw_id(5): 'pg_3_2', act_id(19): 'pg_3_2', act_id(20): 'pg_3_2', converge_gw_id(4): MAIN_STREAM, end_event_id: MAIN_STREAM, } gateway_validation_assert = { converge_gw_id(1): { 'match': None, 'match_assert': None, 'converge_end': None, 'converge_end_assert': None, 'converged_len': 1, 'converged': {parallel_gw_id(2)}, 'distance': 5 }, converge_gw_id(2): { 'match': None, 'match_assert': None, 'converge_end': None, 'converge_end_assert': None, 'converged_len': 1, 'converged': {exclusive_gw_id(2)}, 'distance': 6 }, converge_gw_id(3): { 'match': None, 'match_assert': None, 'converge_end': None, 'converge_end_assert': None, 'converged_len': 5, 'converged': { parallel_gw_id(1), exclusive_gw_id(1), exclusive_gw_id(7), exclusive_gw_id(8), exclusive_gw_id(6) }, 'distance': 9 }, converge_gw_id(4): { 'match': None, 'match_assert': None, 'converge_end': None, 'converge_end_assert': None, 'converged_len': 4, 'converged': { parallel_gw_id(3), exclusive_gw_id(3), exclusive_gw_id(4), exclusive_gw_id(5), }, 'distance': 16 }, exclusive_gw_id(1): { 'match': None, 'match_assert': converge_gw_id(3), 'converge_end': None, 'converge_end_assert': False, 'distance': 7 }, exclusive_gw_id(2): { 'match': None, 'match_assert': converge_gw_id(2), 'converge_end': None, 'converge_end_assert': False, 'distance': 4 }, exclusive_gw_id(3): { 'match': None, 'match_assert': converge_gw_id(4), 'converge_end': None, 'converge_end_assert': True, 'distance': 11 }, exclusive_gw_id(4): { 'match': None, 'match_assert': converge_gw_id(4), 'converge_end': None, 'converge_end_assert': False, 'distance': 13 }, exclusive_gw_id(5): { 'match': None, 'match_assert': converge_gw_id(4), 'converge_end': None, 'converge_end_assert': False, 'distance': 14 }, exclusive_gw_id(6): { 'match': None, 'match_assert': converge_gw_id(3), 'converge_end': None, 'converge_end_assert': False, 'distance': 8 }, exclusive_gw_id(7): { 'match': None, 'match_assert': converge_gw_id(3), 'converge_end': None, 'converge_end_assert': False, 'distance': 4 }, exclusive_gw_id(8): { 'match': None, 'match_assert': converge_gw_id(3), 'converge_end': None, 'converge_end_assert': False, 'distance': 6 }, parallel_gw_id(1): { 'match': None, 'match_assert': converge_gw_id(3), 'converge_end': None, 'converge_end_assert': False, 'distance': 2 }, parallel_gw_id(2): { 'match': None, 'match_assert': converge_gw_id(1), 'converge_end': None, 'converge_end_assert': False, 'distance': 3 }, parallel_gw_id(3): { 'match': None, 'match_assert': converge_gw_id(4), 'converge_end': None, 'converge_end_assert': False, 'distance': 12 } } start = EmptyStartEvent(id=start_event_id) acts = [ServiceActivity(id=act_id(i)) for i in range(1, 21)] pgs = [ParallelGateway(id=parallel_gw_id(i)) for i in range(1, 3)] pgs.append( ConditionalParallelGateway(id=parallel_gw_id(3), conditions={ 0: '123', 1: '456', 2: '789', })) egs = [ ExclusiveGateway(id=exclusive_gw_id(i), conditions={ 0: '123', 1: '456', 2: '789', 3: '101112' }) for i in range(1, 9) ] cgs = [ConvergeGateway(id=converge_gw_id(i)) for i in range(1, 5)] end = EmptyEndEvent(id=end_event_id) nodes = [start, end] nodes.extend(acts) nodes.extend(pgs) nodes.extend(egs) nodes.extend(cgs) start.extend(acts[_(1)]).extend(pgs[_(1)]).connect(pgs[_(2)], acts[_(5)], acts[_(6)]) pgs[_(2)].connect(acts[_(2)], acts[_(3)], acts[_(4)]).converge( cgs[_(1)]).extend(acts[_(7)]).extend(egs[_(1)]).connect( pgs[_(2)], cgs[_(3)]) acts[_(5)].extend(egs[_(7)]).connect( cgs[_(3)], acts[_(8)]).to(acts[_(8)]).extend(egs[_(8)]).connect( acts[_(8)], acts[_(11)]).to(acts[_(11)]).extend(cgs[_(3)]) acts[_(6)].extend(egs[_(2)]).connect( acts[_(9)], acts[_(10)], ).converge(cgs[_(2)]).extend(acts[_(12)]).extend(egs[_(6)]).connect( acts[_(6)], cgs[_(3)], cgs[_(2)]).to(egs[_(2)]).connect(acts[_(6)]) cgs[_(3)].extend(acts[_(13)]).extend(egs[_(3)]).connect( end, acts[_(14)], pgs[_(3)], acts[_(1)]) acts[_(14)].extend(egs[_(4)]).connect(acts[_(13)], cgs[_(4)]) pgs[_(3)].connect( acts[_(15)], acts[_(16)], acts[_(17)] ).to(acts[_(15)]).extend(acts[_(18)]).extend(cgs[_(4)]) \ .to(acts[_(17)]).extend(egs[_(5)]).connect( acts[_(19)], acts[_(20)] ).to(acts[_(19)]).extend(cgs[_(4)]).to(acts[_(20)]).extend(cgs[_(4)]) \ .to(acts[_(16)]).extend(cgs[_(4)]).extend(end) for node in nodes: a = outgoing_assert[node.id] out = {out.id for out in node.outgoing} testcase.assertEqual(a['len'], len(node.outgoing), msg='{id} actual: {a}, expect: {e}'.format( id=node.id, a=len(node.outgoing), e=a['len'])) testcase.assertEqual(a['outgoing'], out, msg='{id} actual: {a}, expect: {e}'.format( id=node.id, a=out, e=a['outgoing'])) return build_tree(start), gateway_validation_assert, stream_assert