def test_exclusive_gateway(self): gw_id = '1' conditions = [Condition(None, None), Condition(None, None)] ex_gateway = ExclusiveGateway(id=gw_id, conditions=conditions) self.assertTrue(isinstance(ex_gateway, FlowNode)) self.assertTrue(isinstance(ex_gateway, Gateway)) self.assertEqual(conditions, ex_gateway.conditions)
def setUp(self): self.empty_start_event = EmptyStartEvent(id='1') self.empty_end_event = EmptyEndEvent(id='2') self.service_activity = ServiceActivity(id='3', service=None) self.subprocess = SubProcess(id='4', pipeline=MagicMock()) self.exclusive_gateway = ExclusiveGateway(id='5') self.parallel_gateway = ParallelGateway(id='6', converge_gateway_id=None) self.conditional_parallel_gateway = ConditionalParallelGateway(id='7', converge_gateway_id=None) self.converge_gateway = ConvergeGateway(id='8') self.executable_end_event_1 = CustomEndEventOne(id='9') self.executable_end_event_2 = CustomEndEventTwo(id='9')
def test_skip_exclusive_gateway__fail_with_skip_fail(self): eg = ExclusiveGateway(id=uniqid()) next_node = IdentifyObject() setattr(eg, 'target_for_sequence_flow', MagicMock(return_value=next_node)) top_pipeline = PipelineObject(nodes={self.node_id: eg}) process = MockPipelineProcess(top_pipeline=top_pipeline) with patch(PIPELINE_PROCESS_GET, MagicMock(return_value=process)): act_result = api.skip_exclusive_gateway(self.node_id, uniqid()) Status.objects.skip.assert_called_once_with(process, eg) self.assertFalse(act_result.result)
def setUp(self): ex_gateway1 = ExclusiveGateway(id='1') next_node1 = ParallelGateway(id='1', converge_gateway_id='cvg') next_node2 = ParallelGateway(id='2', converge_gateway_id='cvg') flow1 = SequenceFlow('flow1', ex_gateway1, next_node1) flow2 = SequenceFlow('flow2', ex_gateway1, next_node2) condition1 = Condition('a == 1', flow1) condition2 = Condition('a != 1', flow2) ex_gateway1.add_condition(condition1) ex_gateway1.add_condition(condition2) ex_gateway1.outgoing.add_flow(flow1) ex_gateway1.outgoing.add_flow(flow2) next_node1.incoming.add_flow(flow1) next_node2.incoming.add_flow(flow2) self.gateway_for_test_determine = ex_gateway1 ex_gateway2 = ExclusiveGateway(id='2') next_node3 = ParallelGateway(id='3', converge_gateway_id='cvg') next_node4 = ParallelGateway(id='4', converge_gateway_id='cvg') next_node5 = ParallelGateway(id='5', converge_gateway_id='cvg') flow3 = SequenceFlow('flow3', ex_gateway2, next_node3) flow4 = SequenceFlow('flow4', ex_gateway2, next_node4) flow5 = SequenceFlow('flow5', ex_gateway2, next_node5, is_default=True) condition3 = Condition('a == 1', flow3) condition4 = Condition('a != 1', flow4) ex_gateway2.add_condition(condition3) ex_gateway2.add_condition(condition4) ex_gateway2.outgoing.add_flow(flow3) ex_gateway2.outgoing.add_flow(flow4) ex_gateway2.outgoing.add_flow(flow5) next_node3.incoming.add_flow(flow3) next_node4.incoming.add_flow(flow4) next_node5.incoming.add_flow(flow5) self.gateway_for_test_next = ex_gateway2
def get_exclusive_gateway_pipeline(result): start_event_a_id = node_uniqid() act_b_id = node_uniqid() gateway_c_id = node_uniqid() act_d_id = node_uniqid() act_e_id = node_uniqid() act_f_id = node_uniqid() gateway_g_id = node_uniqid() end_event_h_id = node_uniqid() start_event_a = EmptyStartEvent(start_event_a_id) b_act = ServiceActivity(act_b_id, service=EchoService(), data=DataObject({'a': 3})) c_gateway = ExclusiveGateway(gateway_c_id, gateway_g_id) d_act = ServiceActivity(act_d_id, service=LogService(), data=DataObject({'node': 'd'})) e_act = ServiceActivity(act_e_id, service=EchoService(), data=DataObject({'node': 'e'})) f_act = ServiceActivity(act_f_id, service=TestService(), data=DataObject({'node': 'f'})) g_gateway = ConvergeGateway(gateway_g_id) end_event_h = EmptyEndEvent(end_event_h_id) ab_flow = SequenceFlow('ab', start_event_a, b_act) bc_flow = SequenceFlow('bc', b_act, c_gateway) cd_flow = SequenceFlow('cd', c_gateway, d_act) ce_flow = SequenceFlow('ce', c_gateway, e_act) cf_flow = SequenceFlow('cf', c_gateway, f_act) dg_flow = SequenceFlow('dg', d_act, g_gateway) eg_flow = SequenceFlow('eg', e_act, g_gateway) fg_flow = SequenceFlow('fg', f_act, g_gateway) gh_flow = SequenceFlow('gh', g_gateway, end_event_h) start_event_a.outgoing.add_flow(ab_flow) b_act.incoming.add_flow(ab_flow) b_act.outgoing.add_flow(bc_flow) c_gateway.incoming.add_flow(bc_flow) c_gateway.outgoing.add_flow(cd_flow) c_gateway.outgoing.add_flow(ce_flow) c_gateway.outgoing.add_flow(cf_flow) d_act.incoming.add_flow(cd_flow) d_act.outgoing.add_flow(dg_flow) e_act.incoming.add_flow(ce_flow) e_act.outgoing.add_flow(eg_flow) f_act.incoming.add_flow(cf_flow) f_act.outgoing.add_flow(fg_flow) g_gateway.incoming.add_flow(dg_flow) g_gateway.incoming.add_flow(eg_flow) g_gateway.incoming.add_flow(fg_flow) g_gateway.outgoing.add_flow(gh_flow) end_event_h.incoming.add_flow(gh_flow) c_gateway.add_condition(Condition('result == 1', cd_flow)) c_gateway.add_condition(Condition('result == 2', ce_flow)) c_gateway.add_condition(Condition('result == 3', cf_flow)) spec = PipelineSpec(start_event_a, end_event_h, [ ab_flow, bc_flow, cd_flow, ce_flow, cf_flow, dg_flow, eg_flow, fg_flow, gh_flow ], [b_act, d_act, e_act, f_act], [c_gateway, g_gateway], data=DataObject({}), context=context.Context(act_outputs={}, scope={'result': result})) return Pipeline(node_uniqid(), spec)
def test_add_condition(self): ex_gateway = ExclusiveGateway(id='1') flow1 = SequenceFlow('flow1', ex_gateway, None) self.assertEqual([], ex_gateway.conditions) ex_gateway.add_condition(flow1) self.assertEqual([flow1], ex_gateway.conditions)