def test_init(self):
        cpg_1 = ConditionalParallelGateway(
            id=self.id, converge_gateway_id=self.converge_gateway_id)
        self.assertEqual(cpg_1.id, self.id)
        self.assertEqual(cpg_1.converge_gateway_id, self.converge_gateway_id)
        self.assertEqual(cpg_1.conditions, [])
        self.assertIsNone(cpg_1.name)
        self.assertIsNone(cpg_1.data)

        cpg_2 = ConditionalParallelGateway(
            id=self.id,
            converge_gateway_id=self.converge_gateway_id,
            conditions=self.conditions,
            name=self.name,
            data=self.data)
        self.assertEqual(cpg_2.id, self.id)
        self.assertEqual(cpg_2.converge_gateway_id, self.converge_gateway_id)
        self.assertEqual(cpg_2.conditions, self.conditions)
        self.assertEqual(cpg_2.name, self.name)
        self.assertEqual(cpg_2.data, self.data)
示例#2
0
 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_targets_meet_condition__normal(self):
        condition_1 = Condition(evaluate='1 == 1',
                                sequence_flow=SequenceFlow(id=self.id,
                                                           source='1',
                                                           target='1'))
        condition_2 = Condition(evaluate='1 == 0',
                                sequence_flow=SequenceFlow(id=self.id,
                                                           source='2',
                                                           target='2'))
        condition_3 = Condition(evaluate='1 == 1',
                                sequence_flow=SequenceFlow(id=self.id,
                                                           source='3',
                                                           target='3'))
        condition_4 = Condition(evaluate='1 == 0',
                                sequence_flow=SequenceFlow(id=self.id,
                                                           source='4',
                                                           target='4'))
        cpg = ConditionalParallelGateway(
            id=self.id,
            converge_gateway_id=self.converge_gateway_id,
            conditions=[condition_1, condition_2, condition_3, condition_4])

        targets = cpg.targets_meet_condition({})
        self.assertEqual(targets, ['1', '3'])
    def test_targets_meet_condition__raise_exhausted(self):
        condition_1 = Condition(evaluate='1 == 0',
                                sequence_flow=SequenceFlow(id=self.id,
                                                           source='1',
                                                           target='1'))
        condition_2 = Condition(evaluate='1 == 0',
                                sequence_flow=SequenceFlow(id=self.id,
                                                           source='2',
                                                           target='2'))
        condition_3 = Condition(evaluate='1 == 0',
                                sequence_flow=SequenceFlow(id=self.id,
                                                           source='3',
                                                           target='3'))
        condition_4 = Condition(evaluate='1 == 0',
                                sequence_flow=SequenceFlow(id=self.id,
                                                           source='4',
                                                           target='4'))
        cpg = ConditionalParallelGateway(
            id=self.id,
            converge_gateway_id=self.converge_gateway_id,
            conditions=[condition_1, condition_2, condition_3, condition_4])

        self.assertRaises(ConditionExhaustedException,
                          cpg.targets_meet_condition, {})
 def test_add_condition(self):
     cpg = ConditionalParallelGateway(
         id=self.id, converge_gateway_id=self.converge_gateway_id)
     cpg.add_condition('condition_1')
     cpg.add_condition('condition_2')
     self.assertEqual(cpg.conditions, ['condition_1', 'condition_2'])
 def test_skip(self):
     cpg = ConditionalParallelGateway(
         id=self.id, converge_gateway_id=self.converge_gateway_id)
     self.assertRaises(InvalidOperationException, cpg.skip)