Пример #1
0
    def accept_RelateUsingNode(self, node):
        from_inst = self.symtab.find_symbol(node.from_variable_name)
        to_inst = self.symtab.find_symbol(node.to_variable_name)
        using_inst = self.symtab.find_symbol(node.using_variable_name)

        xtuml.relate(from_inst, using_inst, node.rel_id, node.phrase)
        xtuml.relate(using_inst, to_inst, node.rel_id, node.phrase)
Пример #2
0
    def test_relate_two_classes_to_assoc(self):
        cls1 = self.m.new('Class')
        cls2 = self.m.new('Class')
        assoc = self.m.new('Assoc')

        self.assertTrue(relate(cls1, assoc, 1, 'one'))
        self.assertTrue(relate(cls2, assoc, 1, 'other'))
Пример #3
0
    def test_serialize_schema(self):
        schema = '''
            CREATE TABLE X (BOOLEAN BOOLEAN,
                            INTEGER INTEGER,
                            REAL REAL,
                            STRING STRING,
                            UNIQUE_ID UNIQUE_ID,
                            Next UNIQUE_ID);
                            
        CREATE ROP REF_ID R1 FROM 1C X ( Next ) PHRASE 'precedes'
                             TO   1C X ( UNIQUE_ID ) PHRASE 'succeeds';
        '''
        loader = xtuml.ModelLoader()
        loader.input(schema)
        m = loader.build_metamodel()
        x1 = m.new('X', Boolean=True, Integer=4, String='str')
        x2 = m.new('X', Boolean=True, Integer=4, String='str')
        xtuml.relate(x1, x2, 1, 'precedes')

        s = xtuml.serialize_schema(m)
        loader = xtuml.ModelLoader()
        loader.input(s)
        m = loader.build_metamodel()

        self.assertFalse(m.select_any('X'))

        x1 = m.new('X', Boolean=True, Integer=4, String='str')
        x2 = m.new('X', Boolean=True, Integer=4, String='str')
        xtuml.relate(x1, x2, 1, 'succeeds')

        self.assertTrue(xtuml.navigate_one(x1).X[1, 'succeeds']())
    def test_unrelate(self):
        self.metamodel.define_class('A', [('Id', 'unique_id'), ('B_Id', 'unique_id')])
        self.metamodel.define_class('B', [('Id', 'unique_id')])
        self.metamodel.define_association(rel_id='R1',
                                          source_kind='A',
                                          target_kind='B',
                                          source_keys=['B_Id'],
                                          target_keys=['Id'],
                                          source_many=False,
                                          target_many=False,
                                          source_conditional=True,
                                          target_conditional=True,
                                          source_phrase='',
                                          target_phrase='')

        a = self.metamodel.new('A')
        b = self.metamodel.new('B')
        xtuml.relate(a, b, 1)

        text = '''
        .select any a from instances of A
        .select any b from instances of B
        .print "${a}"
        .print "${b}"
        .unrelate a from b across R1
        '''
        self.eval_text(text)
        
        a = self.metamodel.select_any('A')
        b = xtuml.navigate_one(a).B[1]()
        self.assertFalse(b)
    def test_unrelate_reflexive(self):
        self.metamodel.define_class('A', [('Id', 'unique_id'),
                                          ('Next_Id', 'unique_id'),
                                          ('Name', 'string')])
        
        self.metamodel.define_association(rel_id='R1',
                                          source_kind='A',
                                          target_kind='A',
                                          source_keys=['Id'],
                                          target_keys=['Next_Id'],
                                          source_many=False,
                                          target_many=False,
                                          source_conditional=True,
                                          target_conditional=True,
                                          source_phrase='prev',
                                          target_phrase='next')

        first = self.metamodel.new('A', Name="First")
        second = self.metamodel.new('A', Name="Second")
        xtuml.relate(first, second, 1, 'prev')
        
        text = '''
        .select any first_inst from instances of A where (selected.Name == "First")
        .select one second_inst related by first_inst->A[R1.'next']
        .unrelate first_inst from second_inst across R1.'prev'
        '''
        
        self.eval_text(text)
        a1 = self.metamodel.select_any('A', lambda sel: sel.Name == "First")
        a2 = xtuml.navigate_one(a1).A[1, 'next']()
        self.assertFalse(a2)
Пример #6
0
    def test_unrelate(self):
        self.metamodel.define_class('A', [('Id', 'unique_id'),
                                          ('B_Id', 'unique_id')])
        self.metamodel.define_class('B', [('Id', 'unique_id')])
        self.metamodel.define_association(rel_id='R1',
                                          source_kind='A',
                                          target_kind='B',
                                          source_keys=['B_Id'],
                                          target_keys=['Id'],
                                          source_many=False,
                                          target_many=False,
                                          source_conditional=True,
                                          target_conditional=True,
                                          source_phrase='',
                                          target_phrase='')

        a = self.metamodel.new('A')
        b = self.metamodel.new('B')
        xtuml.relate(a, b, 1)

        text = '''
        .select any a from instances of A
        .select any b from instances of B
        .print "${a}"
        .print "${b}"
        .unrelate a from b across R1
        '''
        self.eval_text(text)

        a = self.metamodel.select_any('A')
        b = xtuml.navigate_one(a).B[1]()
        self.assertFalse(b)
Пример #7
0
    def test_select_any_substitution_navigation(self):
        self.metamodel.define_class('A', [('Id', 'unique_id')])
        self.metamodel.define_class('B', [('Id', 'unique_id'), 
                                          ('A_Id', 'unique_id'), 
                                          ('Name', 'string')])
        
        self.metamodel.define_association(rel_id='R1',
                                          source_kind='A',
                                          target_kind='B',
                                          source_keys=[],
                                          target_keys=[],
                                          source_many=False,
                                          target_many=True,
                                          source_conditional=True,
                                          target_conditional=True,
                                          source_phrase='',
                                          target_phrase='')

        a = self.metamodel.new('A')
        b = self.metamodel.new('B', Name='Test')
        xtuml.relate(a, b, 1)
        
        text = '''
        .select any a from instances of A where ("${selected->B[R1].name}" == "Test")
        .exit a.Id
        '''
        
        rc = self.eval_text(text)
        self.assertEqual(a.Id, rc)
Пример #8
0
    def test_select_one_navigation(self):
        self.metamodel.define_class('A', [('Id', 'unique_id')])
        self.metamodel.define_class('B', [('Id', 'unique_id'), ('A_Id', 'unique_id')])
        
        self.metamodel.define_association(rel_id='R1',
                                          source_kind='A',
                                          target_kind='B',
                                          source_keys=['Id'],
                                          target_keys=['A_Id'],
                                          source_many=False,
                                          target_many=False,
                                          source_conditional=True,
                                          target_conditional=True,
                                          source_phrase='',
                                          target_phrase='')
        
        a = self.metamodel.new('A')
        b = self.metamodel.new('B')
        xtuml.relate(a, b, 1)

        text = '''
        .select any a from instances of A
        .select one b related by a->B[R1]
        .exit b.Id
        '''
        rc = self.eval_text(text)
        self.assertEqual(b.Id, rc)
Пример #9
0
    def test_unrelate_reflexive(self):
        self.metamodel.define_class('A', [('Id', 'unique_id'),
                                          ('Next_Id', 'unique_id'),
                                          ('Name', 'string')])

        self.metamodel.define_association(rel_id='R1',
                                          source_kind='A',
                                          target_kind='A',
                                          source_keys=['Id'],
                                          target_keys=['Next_Id'],
                                          source_many=False,
                                          target_many=False,
                                          source_conditional=True,
                                          target_conditional=True,
                                          source_phrase='prev',
                                          target_phrase='next')

        first = self.metamodel.new('A', Name="First")
        second = self.metamodel.new('A', Name="Second")
        xtuml.relate(first, second, 1, 'prev')

        text = '''
        .select any first_inst from instances of A where (selected.Name == "First")
        .select one second_inst related by first_inst->A[R1.'next']
        .unrelate first_inst from second_inst across R1.'prev'
        '''

        self.eval_text(text)
        a1 = self.metamodel.select_any('A', lambda sel: sel.Name == "First")
        a2 = xtuml.navigate_one(a1).A[1, 'next']()
        self.assertFalse(a2)
Пример #10
0
    def test_select_one_navigation(self):
        self.metamodel.define_class('A', [('Id', 'unique_id')])
        self.metamodel.define_class('B', [('Id', 'unique_id'),
                                          ('A_Id', 'unique_id')])

        self.metamodel.define_association(rel_id='R1',
                                          source_kind='A',
                                          target_kind='B',
                                          source_keys=['Id'],
                                          target_keys=['A_Id'],
                                          source_many=False,
                                          target_many=False,
                                          source_conditional=True,
                                          target_conditional=True,
                                          source_phrase='',
                                          target_phrase='')

        a = self.metamodel.new('A')
        b = self.metamodel.new('B')
        xtuml.relate(a, b, 1)

        text = '''
        .select any a from instances of A
        .select one b related by a->B[R1]
        .exit b.Id
        '''
        rc = self.eval_text(text)
        self.assertEqual(b.Id, rc)
Пример #11
0
 def testConsistencyOfNonEmptyModel(self):
     m = self.metamodel
     s_dt = m.select_one('S_DT', where(Name='string'))
     s_bparm = m.new('S_BPARM', Name='My_Parameter')
     s_ee = m.new('S_EE', Name='My_External_Entity', Key_Lett='My_External_Entity')
     pe_pe = m.new('PE_PE', Visibility=True, type=5)
     s_brg = m.new('S_BRG', Name='My_Bridge_Operation')
     
     self.assertFalse(m.is_consistent(22))
     self.assertTrue(xtuml.relate(s_bparm, s_dt, 22))
     self.assertTrue(m.is_consistent(22))
     
     self.assertFalse(m.is_consistent(21))
     self.assertTrue(xtuml.relate(s_bparm, s_brg, 21))
     self.assertTrue(m.is_consistent(21))
     
     self.assertFalse(m.is_consistent(20))
     self.assertTrue(xtuml.relate(s_brg, s_dt, 20))
     self.assertTrue(m.is_consistent(20))
     
     self.assertFalse(m.is_consistent(8001))
     self.assertTrue(xtuml.relate(s_ee, pe_pe, 8001))
     self.assertTrue(m.is_consistent(8001))
     
     self.assertFalse(m.is_consistent(19))
     self.assertTrue(xtuml.relate(s_brg, s_ee, 19))
     self.assertTrue(m.is_consistent(19))
Пример #12
0
 def testRelateInvertedOrder(self):
     s_edt = self.metamodel.new('S_EDT')
     s_dt = self.metamodel.new('S_DT')
     pe_pe = self.metamodel.new('PE_PE')
     self.assertTrue(xtuml.relate(pe_pe, s_dt, 8001))
     self.assertTrue(xtuml.relate(s_edt, s_dt, 17))
     self.assertEqual(s_edt, xtuml.navigate_one(s_dt).S_EDT[17]())
Пример #13
0
    def test_serialize_schema(self):
        schema = '''
            CREATE TABLE X (BOOLEAN BOOLEAN,
                            INTEGER INTEGER,
                            REAL REAL,
                            STRING STRING,
                            UNIQUE_ID UNIQUE_ID,
                            Next UNIQUE_ID);
                            
        CREATE ROP REF_ID R1 FROM 1C X ( Next ) PHRASE 'precedes'
                             TO   1C X ( UNIQUE_ID ) PHRASE 'succeeds';
        '''
        loader = xtuml.ModelLoader()
        loader.input(schema)
        m = loader.build_metamodel()
        x1 = m.new('X', Boolean=True, Integer=4, String='str')
        x2 = m.new('X', Boolean=True, Integer=4, String='str')
        xtuml.relate(x1, x2, 1, 'precedes')
        
        s = xtuml.serialize_schema(m)
        loader = xtuml.ModelLoader()
        loader.input(s)
        m = loader.build_metamodel()

        self.assertFalse(m.select_any('X'))

        x1 = m.new('X', Boolean=True, Integer=4, String='str')
        x2 = m.new('X', Boolean=True, Integer=4, String='str')
        xtuml.relate(x1, x2, 1, 'succeeds')

        self.assertTrue(xtuml.navigate_one(x1).X[1, 'succeeds']())
Пример #14
0
 def accept_RelateUsingNode(self, node):
     from_inst = self.symtab.find_symbol(node.from_variable_name)
     to_inst = self.symtab.find_symbol(node.to_variable_name)
     using_inst = self.symtab.find_symbol(node.using_variable_name)
     
     xtuml.relate(from_inst, using_inst, node.rel_id, node.phrase)
     xtuml.relate(using_inst, to_inst, node.rel_id, node.phrase)
Пример #15
0
    def test_select_any_substitution_navigation(self):
        self.metamodel.define_class('A', [('Id', 'unique_id')])
        self.metamodel.define_class('B', [('Id', 'unique_id'),
                                          ('A_Id', 'unique_id'),
                                          ('Name', 'string')])

        self.metamodel.define_association(rel_id='R1',
                                          source_kind='A',
                                          target_kind='B',
                                          source_keys=[],
                                          target_keys=[],
                                          source_many=False,
                                          target_many=True,
                                          source_conditional=True,
                                          target_conditional=True,
                                          source_phrase='',
                                          target_phrase='')

        a = self.metamodel.new('A')
        b = self.metamodel.new('B', Name='Test')
        xtuml.relate(a, b, 1)

        text = '''
        .select any a from instances of A where ("${selected->B[R1].name}" == "Test")
        .exit a.Id
        '''

        rc = self.eval_text(text)
        self.assertEqual(a.Id, rc)
Пример #16
0
 def test_relate_inverted_order(self):
     s_edt = self.m.new('S_EDT')
     s_dt = self.m.new('S_DT')
     pe_pe = self.m.new('PE_PE')
     self.assertTrue(xtuml.relate(pe_pe, s_dt, 8001))
     self.assertTrue(xtuml.relate(s_edt, s_dt, 17))
     self.assertEqual(s_edt, xtuml.navigate_one(s_dt).S_EDT[17]())
Пример #17
0
 def test_relate(self):
     s_edt = self.m.new('S_EDT')
     s_dt = self.m.new('S_DT')
     pe_pe = self.m.new('PE_PE')
     self.assertFalse(xtuml.navigate_one(s_dt).S_EDT[17]())
     self.assertTrue(xtuml.relate(s_dt, pe_pe, 8001))
     self.assertTrue(xtuml.relate(s_dt, s_edt, 17))
     self.assertEqual(s_edt, xtuml.navigate_one(s_dt).S_EDT[17]())
Пример #18
0
    def setUp(self):
        self.metamodel = self.loader.build_metamodel()
        pe_pe = self.metamodel.new('PE_PE')
        s_sync = self.metamodel.new('S_SYNC')
        xtuml.relate(s_sync, pe_pe, 8001)

        s_dt = self.metamodel.select_any('S_DT',
                                         lambda sel: sel.Name == 'void')
        xtuml.relate(s_dt, s_sync, 25)
Пример #19
0
    def test_relate_reflexive_one_to_other(self):
        inst1 = self.m.new('ACT_SMT')
        inst2 = self.m.new('ACT_SMT')
        act_blk = self.m.new('ACT_BLK')

        self.assertTrue(xtuml.relate(inst1, act_blk, 602))
        self.assertTrue(xtuml.relate(inst2, act_blk, 602))
        self.assertTrue(xtuml.relate(inst1, inst2, 661, 'succeeds'))
        self.assertEqual(inst2, xtuml.navigate_one(inst1).ACT_SMT[661, 'succeeds']())
        self.assertEqual(inst1, xtuml.navigate_one(inst2).ACT_SMT[661, 'precedes']())
Пример #20
0
    def testRelateReflexive2(self):
        inst1 = self.metamodel.new('ACT_SMT')
        inst2 = self.metamodel.new('ACT_SMT')
        act_blk = self.metamodel.new('ACT_BLK')

        self.assertTrue(xtuml.relate(inst1, act_blk, 602))
        self.assertTrue(xtuml.relate(inst2, act_blk, 602))
        self.assertTrue(xtuml.relate(inst2, inst1, 661, 'succeeds'))
        self.assertEqual(inst2, xtuml.navigate_one(inst1).ACT_SMT[661, 'succeeds']())
        self.assertEqual(inst1, xtuml.navigate_one(inst2).ACT_SMT[661, 'precedes']())
Пример #21
0
 def setUp(self):
     PrebuildFunctionTestCase.setUp(self)
     s_sync = self.metamodel.select_any('S_SYNC')
     p1 = self.metamodel.new('S_SPARM', Name='P1')
     p2 = self.metamodel.new('S_SPARM', Name='p2')
     relate(p1, s_sync, 24)
     relate(p2, s_sync, 24)
     relate(p1, p2, 54, 'succeeds')
     
     s_dt = self.metamodel.select_any('S_DT', lambda sel: sel.Name == 'boolean')
     relate(p1, s_dt, 26)
     relate(p2, s_dt, 26)
Пример #22
0
    def test_relate_reflexive_other_to_one(self):
        inst1 = self.m.new('ACT_SMT')
        inst2 = self.m.new('ACT_SMT')
        act_blk = self.m.new('ACT_BLK')

        self.assertTrue(xtuml.relate(inst1, act_blk, 602))
        self.assertTrue(xtuml.relate(inst2, act_blk, 602))
        self.assertTrue(xtuml.relate(inst2, inst1, 661, 'precedes'))
        self.assertEqual(inst2,
                         xtuml.navigate_one(inst1).ACT_SMT[661, 'succeeds']())
        self.assertEqual(inst1,
                         xtuml.navigate_one(inst2).ACT_SMT[661, 'precedes']())
Пример #23
0
 def wrapper(*args):
     m = ooaofooa.empty_model()
     
     pe_pe = m.new('PE_PE')
     s_sync = m.new('S_SYNC', Name=fn.__name__)
     relate(pe_pe, s_sync, 8001)
     
     s_sync.Action_Semantics_internal = translate_text(m, fn.__doc__)
     
     args = list(args)
     args.append(m)
     fn(*args)
Пример #24
0
    def wrapper(*args):
        m = ooaofooa.empty_model()

        pe_pe = m.new('PE_PE')
        s_sync = m.new('S_SYNC', Name=fn.__name__)
        relate(pe_pe, s_sync, 8001)

        s_sync.Action_Semantics_internal = translate_text(m, fn.__doc__)

        args = list(args)
        args.append(m)
        fn(*args)
Пример #25
0
    def setUp(self):
        PrebuildFunctionTestCase.setUp(self)
        s_sync = self.metamodel.select_any('S_SYNC')
        p1 = self.metamodel.new('S_SPARM', Name='P1')
        p2 = self.metamodel.new('S_SPARM', Name='p2')
        relate(p1, s_sync, 24)
        relate(p2, s_sync, 24)
        relate(p1, p2, 54, 'succeeds')

        s_dt = self.metamodel.select_any('S_DT',
                                         lambda sel: sel.Name == 'boolean')
        relate(p1, s_dt, 26)
        relate(p2, s_dt, 26)
Пример #26
0
    def test_relate_assoc_to_two_classes(self):
        cls1 = self.m.new('Class')
        cls2 = self.m.new('Class')
        assoc = self.m.new('Assoc')

        self.assertTrue(relate(assoc, cls1, 1, 'one'))
        self.assertTrue(relate(assoc, cls2, 1, 'other'))

        self.assertTrue(one(cls1).Class[1, 'other']())
        self.assertFalse(one(cls2).Class[1, 'other']())

        self.assertFalse(one(cls1).Class[1, 'one']())
        self.assertTrue(one(cls2).Class[1, 'one']())
def main():
    '''
    Parse argv for options and arguments, and start schema generation.
    '''
    parser = optparse.OptionParser(usage="%prog [options] <model_path> [another_model_path...]",
                                   formatter=optparse.TitledHelpFormatter())
                                   
    parser.set_description(__doc__.strip())
    
    parser.add_option("-f", "--function", dest="function", metavar="NAME",
                      help="append integrity checking actions to functions named NAME (required)",
                      action="store", default=None)
    
    parser.add_option("-o", "--output", dest='output', metavar="PATH",
                      help="save sql model instances to PATH (required)",
                      action="store", default=None)
    
    parser.add_option("-v", "--verbosity", dest='verbosity', action="count",
                      help="increase debug logging level", default=2)

    
    (opts, args) = parser.parse_args()
    if len(args) == 0 or None in [opts.output, opts.function]:
        parser.print_help()
        sys.exit(1)

    levels = {
              0: logging.ERROR,
              1: logging.WARNING,
              2: logging.INFO,
              3: logging.DEBUG,
    }
    logging.basicConfig(level=levels.get(opts.verbosity, logging.DEBUG))

    m = ooaofooa.load_metamodel(args)
    for c_c in m.select_many('C_C'):

        filt = lambda sel: ooaofooa.is_contained_in(sel, c_c) and sel.Name == opts.function
        s_sync = m.select_any('S_SYNC', filt)
        if not s_sync:
            s_sync = m.new('S_SYNC', Name=opts.function)
            pe_pe = m.new('PE_PE')
            s_dt = m.select_any('S_DT', where(Name='boolean'))
            
            relate(pe_pe, s_sync, 8001)
            relate(s_dt, s_sync, 25)

        generate_actions(m, c_c, s_sync)
    
    xtuml.persist_instances(m, opts.output)
Пример #28
0
 def test_relate_bottom_up(self):
     s_dt = self.m.select_one('S_DT', xtuml.where_eq(Name='string'))
     s_bparm = self.m.new('S_BPARM', Name='My_Parameter')
     s_ee = self.m.new('S_EE', Name='My_External_Entity', Key_Lett='My_External_Entity')
     pe_pe = self.m.new('PE_PE', Visibility=True, type=5)
     s_brg = self.m.new('S_BRG', Name='My_Bridge_Operation')
     
     self.assertTrue(xtuml.relate(s_bparm, s_dt, 22))
     self.assertTrue(xtuml.relate(s_bparm, s_brg, 21))
     self.assertTrue(xtuml.relate(s_brg, s_dt, 20))
     self.assertTrue(xtuml.relate(s_ee, pe_pe, 8001))
     self.assertTrue(xtuml.relate(s_brg, s_ee, 19))
     
     inst = xtuml.navigate_any(pe_pe).S_EE[8001].S_BRG[19].S_BPARM[21]()
     self.assertEqual(inst, s_bparm)
Пример #29
0
    def test_clone(self):
        s_ee = self.metamodel.new('S_EE',
                                  Name='Test',
                                  Descrip='test',
                                  Key_Lett='TEST')
        pe_pe = self.metamodel.new('PE_PE')
        self.assertTrue(xtuml.relate(s_ee, pe_pe, 8001))

        m = ooaofooa.empty_model()
        self.assertNotEqual(pe_pe, m.clone(pe_pe))
        self.assertNotEqual(s_ee, m.clone(s_ee))

        s_ee_clone = m.select_any('S_EE', where(Name='Test'))
        self.assertNotEqual(s_ee, s_ee_clone)
        self.assertEqual(s_ee_clone.EE_ID, s_ee.EE_ID)
        self.assertEqual(s_ee_clone.Name, s_ee.Name)
        self.assertEqual(s_ee_clone.Descrip, s_ee.Descrip)
        self.assertEqual(s_ee_clone.Key_Lett, s_ee.Key_Lett)

        pe_pe_clone = xtuml.navigate_one(s_ee_clone).PE_PE[8001]()
        self.assertTrue(pe_pe_clone)
        self.assertNotEqual(pe_pe, pe_pe_clone)
        self.assertEqual(pe_pe_clone.Element_ID, pe_pe.Element_ID)
        self.assertEqual(pe_pe_clone.Visibility, pe_pe.Visibility)
        self.assertEqual(pe_pe_clone.Package_ID, pe_pe.Package_ID)
        self.assertEqual(pe_pe_clone.Component_ID, pe_pe.Component_ID)
        self.assertEqual(pe_pe_clone.type, pe_pe.type)
Пример #30
0
    def test_reflexive(self):
        self.metamodel.define_class('A', [('Id', 'unique_id'),
                                          ('Next_Id', 'unique_id'),
                                          ('Name', 'string')])
        
        ass = self.metamodel.define_association(rel_id='R1', 
                                                source_kind='A', 
                                                source_keys=['Id'], 
                                                source_many=False, 
                                                source_conditional=False,
                                                source_phrase='prev',
                                                target_kind='A',
                                                target_keys=['Next_Id'],
                                                target_many=False,
                                                target_conditional=False,
                                                target_phrase='next')
        ass.formalize()
        
        first = self.metamodel.new('A', Name="First")
        second = self.metamodel.new('A', Name="Second")

        self.assertTrue(xtuml.relate(first, second, 1, 'prev'))

        inst = xtuml.navigate_one(first).A[1, 'prev']()
        self.assertEqual(inst.Name, second.Name)

        inst = xtuml.navigate_one(first).A[1, 'next']()
        self.assertIsNone(inst)
        
        inst = xtuml.navigate_one(second).A[1, 'next']()
        self.assertEqual(inst.Name, first.Name)
        
        inst = xtuml.navigate_one(second).A[1, 'prev']()
        self.assertIsNone(inst)
Пример #31
0
    def test_relate_when_already_related(self):
        act_smt = self.m.new('ACT_SMT')
        act_blk1 = self.m.new('ACT_BLK')
        act_blk2 = self.m.new('ACT_BLK')

        self.assertTrue(xtuml.relate(act_smt, act_blk1, 602))
        self.assertRaises(xtuml.RelateException, xtuml.relate, act_smt, act_blk2, 602)
Пример #32
0
 def test_select_where_after_relate(self):
     s_edt = self.m.new('S_EDT')
     s_dt = self.m.new('S_DT')
     pe_pe = self.m.new('PE_PE')
     
     self.assertFalse(self.m.select_any('S_DT', xtuml.where_eq(DT_ID=pe_pe.Element_ID)))
     
     self.assertTrue(xtuml.relate(s_dt, pe_pe, 8001))
     self.assertTrue(xtuml.relate(s_dt, s_edt, 17))
     
     self.assertTrue(self.m.select_any('S_DT', xtuml.where_eq(DT_ID=pe_pe.Element_ID)))
     
     self.assertTrue(xtuml.unrelate(s_dt, pe_pe, 8001))
     self.assertTrue(xtuml.unrelate(s_dt, s_edt, 17))
     
     self.assertFalse(self.m.select_any('S_DT', xtuml.where_eq(DT_ID=pe_pe.Element_ID)))
Пример #33
0
    def test_relate_assoc_to_two_classes_incorrectly(self):
        cls1 = self.m.new('Class')
        cls2 = self.m.new('Class')
        assoc = self.m.new('Assoc')

        self.assertTrue(relate(assoc, cls1, 1, 'one'))
        self.assertRaises(xtuml.RelateException, relate, assoc, cls2, 1, 'one')
Пример #34
0
    def testReflexive(self):
        self.metamodel.define_class('A', [('Id', 'unique_id'),
                                          ('Next_Id', 'unique_id'),
                                          ('Name', 'string')])
        
        endpint1 = xtuml.SingleAssociationLink('A', ids=['Id'], phrase='prev')
        endpint2 = xtuml.SingleAssociationLink('A', ids=['Next_Id'], phrase='next')
        self.metamodel.define_relation('R1', endpint1, endpint2)
        
        first = self.metamodel.new('A', Name="First")
        second = self.metamodel.new('A', Name="Second")

        self.assertTrue(xtuml.relate(first, second, 1, 'prev'))

        inst = xtuml.navigate_one(first).A[1, 'next']()
        self.assertEqual(inst.Name, second.Name)

        inst = xtuml.navigate_one(first).A[1, 'prev']()
        self.assertIsNone(inst)
        
        inst = xtuml.navigate_one(second).A[1, 'prev']()
        self.assertEqual(inst.Name, first.Name)
        
        inst = xtuml.navigate_one(second).A[1, 'next']()
        self.assertIsNone(inst)
Пример #35
0
 def test_relate_in_wrong_order(self):
     s_ee = self.m.new('S_EE')
     pe_pe = self.m.new('PE_PE')
     EE_ID = s_ee.EE_ID
     Element_ID = pe_pe.Element_ID
     self.assertTrue(xtuml.relate(s_ee, pe_pe, 8001))
     self.assertNotEqual(EE_ID, s_ee.EE_ID)
     self.assertEqual(Element_ID, pe_pe.Element_ID)
Пример #36
0
    def test_relate_bottom_up(self):
        s_dt = self.m.select_one('S_DT', xtuml.where_eq(Name='string'))
        s_bparm = self.m.new('S_BPARM', Name='My_Parameter')
        s_ee = self.m.new('S_EE',
                          Name='My_External_Entity',
                          Key_Lett='My_External_Entity')
        pe_pe = self.m.new('PE_PE', Visibility=True, type=5)
        s_brg = self.m.new('S_BRG', Name='My_Bridge_Operation')

        self.assertTrue(xtuml.relate(s_bparm, s_dt, 22))
        self.assertTrue(xtuml.relate(s_bparm, s_brg, 21))
        self.assertTrue(xtuml.relate(s_brg, s_dt, 20))
        self.assertTrue(xtuml.relate(s_ee, pe_pe, 8001))
        self.assertTrue(xtuml.relate(s_brg, s_ee, 19))

        inst = xtuml.navigate_any(pe_pe).S_EE[8001].S_BRG[19].S_BPARM[21]()
        self.assertEqual(inst, s_bparm)
Пример #37
0
 def testRelateInWrongOrder(self):
     s_ee = self.metamodel.new('S_EE')
     pe_pe = self.metamodel.new('PE_PE')
     EE_ID = s_ee.EE_ID
     Element_ID = pe_pe.Element_ID
     self.assertTrue(xtuml.relate(s_ee, pe_pe, 8001))
     self.assertNotEqual(EE_ID, s_ee.EE_ID)
     self.assertEqual(Element_ID, pe_pe.Element_ID)
Пример #38
0
    def test_relate_when_already_related(self):
        act_smt = self.m.new('ACT_SMT')
        act_blk1 = self.m.new('ACT_BLK')
        act_blk2 = self.m.new('ACT_BLK')

        self.assertTrue(xtuml.relate(act_smt, act_blk1, 602))
        self.assertRaises(xtuml.RelateException, xtuml.relate, act_smt,
                          act_blk2, 602)
Пример #39
0
    def test_recursion(self):
        p1 = self.m.new('S_BPARM', Name='p1')
        p2 = self.m.new('S_BPARM', Name='p2')
        p3 = self.m.new('S_BPARM', Name='p3')
        p4 = self.m.new('S_BPARM', Name='p4')

        self.assertTrue(xtuml.relate(p1, p2, 55, 'precedes'))
        self.assertTrue(xtuml.relate(p2, p3, 55, 'precedes'))
        self.assertTrue(xtuml.relate(p3, p4, 55, 'precedes'))
        self.assertTrue(xtuml.relate(p4, p1, 55, 'precedes'))

        inst_set = self.m.select_many('S_BPARM')
        inst_set = xtuml.sort_reflexive(inst_set, 55, 'succeeds')

        self.assertEqual(len(inst_set), 4)
        for inst1, inst2 in zip(inst_set, [p1, p2, p3, p4]):
            self.assertEqual(inst1, inst2)
Пример #40
0
 def test_relate_in_wrong_order(self):
     s_ee = self.m.new('S_EE')
     pe_pe = self.m.new('PE_PE')
     EE_ID = s_ee.EE_ID
     Element_ID = pe_pe.Element_ID
     self.assertTrue(xtuml.relate(s_ee, pe_pe, 8001))
     self.assertNotEqual(EE_ID, s_ee.EE_ID)
     self.assertEqual(Element_ID, pe_pe.Element_ID)
Пример #41
0
    def test_recursion(self):
        p1 = self.m.new('S_BPARM', Name='p1')
        p2 = self.m.new('S_BPARM', Name='p2')
        p3 = self.m.new('S_BPARM', Name='p3')
        p4 = self.m.new('S_BPARM', Name='p4')
        
        self.assertTrue(xtuml.relate(p1, p2, 55, 'precedes'))
        self.assertTrue(xtuml.relate(p2, p3, 55, 'precedes'))
        self.assertTrue(xtuml.relate(p3, p4, 55, 'precedes'))
        self.assertTrue(xtuml.relate(p4, p1, 55, 'precedes'))
        
        inst_set = self.m.select_many('S_BPARM')
        inst_set = xtuml.sort_reflexive(inst_set, 55, 'succeeds')

        self.assertEqual(len(inst_set), 4)
        for inst1, inst2 in zip(inst_set, [p1, p2, p3, p4]):
            self.assertEqual(inst1, inst2)
Пример #42
0
    def test_unknown_link(self):
        p1 = self.m.new('S_BPARM', Name='p1')
        p2 = self.m.new('S_BPARM', Name='p2')

        self.assertTrue(xtuml.relate(p1, p2, 55, 'precedes'))

        inst_set = self.m.select_many('S_BPARM')
        self.assertRaises(xtuml.UnknownLinkException, xtuml.sort_reflexive,
                          inst_set, 5, 'precedes')
Пример #43
0
 def test_unknown_link(self):
     p1 = self.m.new('S_BPARM', Name='p1')
     p2 = self.m.new('S_BPARM', Name='p2')
     
     self.assertTrue(xtuml.relate(p1, p2, 55, 'precedes'))
     
     inst_set = self.m.select_many('S_BPARM')
     self.assertRaises(xtuml.UnknownLinkException,
                       xtuml.sort_reflexive, inst_set, 5, 'precedes')
Пример #44
0
    def test_select_where_after_relate(self):
        s_edt = self.m.new('S_EDT')
        s_dt = self.m.new('S_DT')
        pe_pe = self.m.new('PE_PE')

        self.assertFalse(
            self.m.select_any('S_DT', xtuml.where_eq(DT_ID=pe_pe.Element_ID)))

        self.assertTrue(xtuml.relate(s_dt, pe_pe, 8001))
        self.assertTrue(xtuml.relate(s_dt, s_edt, 17))

        self.assertTrue(
            self.m.select_any('S_DT', xtuml.where_eq(DT_ID=pe_pe.Element_ID)))

        self.assertTrue(xtuml.unrelate(s_dt, pe_pe, 8001))
        self.assertTrue(xtuml.unrelate(s_dt, s_edt, 17))

        self.assertFalse(
            self.m.select_any('S_DT', xtuml.where_eq(DT_ID=pe_pe.Element_ID)))
Пример #45
0
 def test_sort(self):
     act_blk = self.m.new('ACT_BLK')
     
     prev = None
     for idx in range(10):
         inst = self.m.new('ACT_SMT', LineNumber=idx)
         self.assertTrue(xtuml.relate(inst, act_blk, 602))
         xtuml.relate(prev, inst, 661, 'precedes')
         prev = inst
         
     inst_set = xtuml.navigate_many(act_blk).ACT_SMT[602]()
     inst_set = xtuml.sort_reflexive(inst_set, 661, 'succeeds')
     self.assertEqual(len(inst_set), 10)
     for idx, inst in enumerate(inst_set):
         self.assertEqual(inst.LineNumber, idx)
     
     inst_set = xtuml.navigate_many(act_blk).ACT_SMT[602]()
     inst_set = xtuml.sort_reflexive(inst_set, 661, 'precedes')
     self.assertEqual(len(inst_set), 10)
     for idx, inst in enumerate(inst_set):
         self.assertEqual(inst.LineNumber, 9 - idx)
Пример #46
0
    def test_sort(self):
        act_blk = self.m.new('ACT_BLK')

        prev = None
        for idx in range(10):
            inst = self.m.new('ACT_SMT', LineNumber=idx)
            self.assertTrue(xtuml.relate(inst, act_blk, 602))
            xtuml.relate(prev, inst, 661, 'precedes')
            prev = inst

        inst_set = xtuml.navigate_many(act_blk).ACT_SMT[602]()
        inst_set = xtuml.sort_reflexive(inst_set, 661, 'succeeds')
        self.assertEqual(len(inst_set), 10)
        for idx, inst in enumerate(inst_set):
            self.assertEqual(inst.LineNumber, idx)

        inst_set = xtuml.navigate_many(act_blk).ACT_SMT[602]()
        inst_set = xtuml.sort_reflexive(inst_set, 661, 'precedes')
        self.assertEqual(len(inst_set), 10)
        for idx, inst in enumerate(inst_set):
            self.assertEqual(inst.LineNumber, 9 - idx)
Пример #47
0
 def testOneToMany(self):
     self.metamodel.define_class('A', [('Id', 'unique_id')])
     self.metamodel.define_class('B', [('Id', 'unique_id'), ('A_Id', 'unique_id')])
     a_endpint = xtuml.SingleAssociationLink('A', ids=['Id'])
     b_endpint = xtuml.ManyAssociationLink('B', ids=['A_Id'])
     
     self.metamodel.define_relation(1, a_endpint, b_endpint)
     
     a = self.metamodel.new('A')
     b = self.metamodel.new('B')
     self.assertTrue(xtuml.relate(a, b, 1))
     
     self.assertEqual(a, xtuml.navigate_one(b).A[1]())
Пример #48
0
 def setUp(self):
     PrebuildFunctionTestCase.setUp(self)
     sm_sm = self.metamodel.new('SM_SM')
     o_obj = self.metamodel.new('O_OBJ', Key_Lett='A')
     pe_pe = self.metamodel.new('PE_PE')
     relate(pe_pe, o_obj, 8001)
     
     self.metamodel.new('SM_EVT',
                        SM_ID=sm_sm.SM_ID,
                        SMspd_ID=self.metamodel.id_generator.next(),
                        Numb=2,
                        Drv_Lbl='A2',
                        Mning='my_event')
     
     self.metamodel.new('SM_ASM',
                        Obj_ID=o_obj.Obj_ID,
                        SM_ID=sm_sm.SM_ID)
     
     
     
     sm_sm = self.metamodel.new('SM_SM')       
     o_obj = self.metamodel.new('O_OBJ', Key_Lett='B')
     pe_pe = self.metamodel.new('PE_PE')
     relate(pe_pe, o_obj, 8001)
     
     self.metamodel.new('SM_EVT',
                        SM_ID=sm_sm.SM_ID,
                        SMspd_ID=self.metamodel.id_generator.next(),
                        Numb=2,
                        Drv_Lbl='B2',
                        Mning='my_second_event')
     
     self.metamodel.new('SM_ISM',
                        Obj_ID=o_obj.Obj_ID,
                        SM_ID=sm_sm.SM_ID)
     
     
     sm_sm = self.metamodel.new('SM_SM')       
     o_obj = self.metamodel.new('O_OBJ', Key_Lett='C')
     pe_pe = self.metamodel.new('PE_PE')
     relate(pe_pe, o_obj, 8001)
     sm_evt = self.metamodel.new('SM_EVT',
                                 SM_ID=sm_sm.SM_ID,
                                 SMspd_ID=self.metamodel.id_generator.next(),
                                 Numb=1,
                                 Drv_Lbl='C1',
                                 Mning='my_third_event')
     
     s_dt = self.metamodel.select_any('S_DT', where(Name='boolean'))
     self.metamodel.new('SM_EVTDI',
                        SM_ID=sm_sm.SM_ID,
                        SMevt_ID=sm_evt.SMevt_ID,
                        DT_ID=s_dt.DT_ID,
                        Name='di1')
     
     self.metamodel.new('SM_ISM',
                        Obj_ID=o_obj.Obj_ID,
                        SM_ID=sm_sm.SM_ID)
def mk_parameters(s_sync, **kwargs):
    m = xtuml.get_metamodel(s_sync)
    prev = None
    for name, s_dt in kwargs.items():
        s_sparm = m.new('S_SPARM', Name=name)
        relate(s_sparm, s_sync, 24)
        relate(s_sparm, s_dt, 26)
        relate(s_sparm, prev, 54, 'succeeds')
        prev = s_sparm
Пример #50
0
    def test_select_one_reflexive_navigation(self):
        self.metamodel.define_class('A', [('Id', 'unique_id'),
                                          ('Next_Id', 'unique_id'),
                                          ('Name', 'string')])
        
        self.metamodel.define_association(rel_id='R1',
                                          source_kind='A',
                                          target_kind='A',
                                          source_keys=['Id'],
                                          target_keys=['Next_Id'],
                                          source_many=False,
                                          target_many=False,
                                          source_conditional=True,
                                          target_conditional=True,
                                          source_phrase='prev',
                                          target_phrase='next')

        first = self.metamodel.new('A', Name="First")
        second = self.metamodel.new('A', Name="Second")
        xtuml.relate(first, second, 1, 'prev')
        
        text = '''
        .select any first_inst from instances of A where (selected.Name == "First")
        .select one second_inst related by first_inst->A[R1.'prev']
        .exit second_inst.Name
        '''
        rc = self.eval_text(text)
        self.assertEqual(second.Name, rc)

        text = '''
        .select any second_inst from instances of A where (selected.Name == "Second")
        .select one first_inst related by second_inst->A[R1.'next']
        .exit first_inst.Name
        '''
        rc = self.eval_text(text)
        self.assertEqual(first.Name, rc)
Пример #51
0
    def test_select_one_reflexive_navigation(self):
        self.metamodel.define_class('A', [('Id', 'unique_id'),
                                          ('Next_Id', 'unique_id'),
                                          ('Name', 'string')])

        self.metamodel.define_association(rel_id='R1',
                                          source_kind='A',
                                          target_kind='A',
                                          source_keys=['Id'],
                                          target_keys=['Next_Id'],
                                          source_many=False,
                                          target_many=False,
                                          source_conditional=True,
                                          target_conditional=True,
                                          source_phrase='prev',
                                          target_phrase='next')

        first = self.metamodel.new('A', Name="First")
        second = self.metamodel.new('A', Name="Second")
        xtuml.relate(first, second, 1, 'prev')

        text = '''
        .select any first_inst from instances of A where (selected.Name == "First")
        .select one second_inst related by first_inst->A[R1.'prev']
        .exit second_inst.Name
        '''
        rc = self.eval_text(text)
        self.assertEqual(second.Name, rc)

        text = '''
        .select any second_inst from instances of A where (selected.Name == "Second")
        .select one first_inst related by second_inst->A[R1.'next']
        .exit first_inst.Name
        '''
        rc = self.eval_text(text)
        self.assertEqual(first.Name, rc)
def mk_function(ep_pkg, **kwargs):
    m = xtuml.get_metamodel(ep_pkg)
    s_dt = m.select_any('S_DT', where(Name='void'))
    pe_pe = m.new('PE_PE', Visibility=True, type=1)
    s_sync = m.new('S_SYNC', **kwargs)
    s_sync.Suc_Pars = 1
    relate(pe_pe, s_sync, 8001)
    relate(pe_pe, ep_pkg, 8000)
    relate(s_dt, s_sync, 25)

    return s_sync
Пример #53
0
    def accept_FunctionNode(self, node):
        pe_pe = self.m.new('PE_PE')
        s_sync = self.m.new('S_SYNC', Name=node.name.replace('.', '_'))
        relate(pe_pe, s_sync, 8001)

        prev = None
        for param in node.parameter_list.parameters:
            s_dt = self.m.select_one('S_DT', where(Name=param.type))
            s_sparm = self.m.new('S_SPARM', Name=param.name)
            
            relate(s_sparm, s_sync, 24)
            relate(s_sparm, s_dt, 26)
            relate(s_sparm, prev, 54, 'succeeds')
            
            prev = s_sparm
        
        t = ActionTranslation(self.m)
        strings = t.accept(node.statement_list)
        s_sync.Action_Semantics_internal = ''.join(strings).strip('\n ')
    
        yield ''
Пример #54
0
    def accept_FunctionNode(self, node):
        pe_pe = self.m.new('PE_PE')
        s_sync = self.m.new('S_SYNC', Name=node.name.replace('.', '_'))
        relate(pe_pe, s_sync, 8001)

        prev = None
        for param in node.parameter_list.parameters:
            s_dt = self.m.select_one('S_DT', where(Name=param.type))
            s_sparm = self.m.new('S_SPARM', Name=param.name)

            relate(s_sparm, s_sync, 24)
            relate(s_sparm, s_dt, 26)
            relate(s_sparm, prev, 54, 'succeeds')

            prev = s_sparm

        t = ActionTranslation(self.m)
        strings = t.accept(node.statement_list)
        s_sync.Action_Semantics_internal = ''.join(strings).strip('\n ')

        yield ''
Пример #55
0
    def setUp(self):
        PrebuildFunctionTestCase.setUp(self)
        sm_sm = self.metamodel.new('SM_SM')
        o_obj = self.metamodel.new('O_OBJ', Key_Lett='A')
        pe_pe = self.metamodel.new('PE_PE')
        relate(pe_pe, o_obj, 8001)

        self.metamodel.new('SM_EVT',
                           SM_ID=sm_sm.SM_ID,
                           SMspd_ID=self.metamodel.id_generator.next(),
                           Numb=2,
                           Drv_Lbl='A2',
                           Mning='my_event')

        self.metamodel.new('SM_ASM', Obj_ID=o_obj.Obj_ID, SM_ID=sm_sm.SM_ID)

        sm_sm = self.metamodel.new('SM_SM')
        o_obj = self.metamodel.new('O_OBJ', Key_Lett='B')
        pe_pe = self.metamodel.new('PE_PE')
        relate(pe_pe, o_obj, 8001)

        self.metamodel.new('SM_EVT',
                           SM_ID=sm_sm.SM_ID,
                           SMspd_ID=self.metamodel.id_generator.next(),
                           Numb=2,
                           Drv_Lbl='B2',
                           Mning='my_second_event')

        self.metamodel.new('SM_ISM', Obj_ID=o_obj.Obj_ID, SM_ID=sm_sm.SM_ID)

        sm_sm = self.metamodel.new('SM_SM')
        o_obj = self.metamodel.new('O_OBJ', Key_Lett='C')
        pe_pe = self.metamodel.new('PE_PE')
        relate(pe_pe, o_obj, 8001)
        sm_evt = self.metamodel.new(
            'SM_EVT',
            SM_ID=sm_sm.SM_ID,
            SMspd_ID=self.metamodel.id_generator.next(),
            Numb=1,
            Drv_Lbl='C1',
            Mning='my_third_event')

        s_dt = self.metamodel.select_any('S_DT', where(Name='boolean'))
        self.metamodel.new('SM_EVTDI',
                           SM_ID=sm_sm.SM_ID,
                           SMevt_ID=sm_evt.SMevt_ID,
                           DT_ID=s_dt.DT_ID,
                           Name='di1')

        self.metamodel.new('SM_ISM', Obj_ID=o_obj.Obj_ID, SM_ID=sm_sm.SM_ID)
Пример #56
0
 def test_one_to_many(self):
     self.metamodel.define_class('A', [('Id', 'unique_id')])
     self.metamodel.define_class('B', [('Id', 'unique_id'), ('A_Id', 'unique_id')])
     
     ass = self.metamodel.define_association(rel_id=1, 
                                             source_kind='A', 
                                             source_keys=['Id'], 
                                             source_many=False, 
                                             source_conditional=False,
                                             source_phrase='',
                                             target_kind='B',
                                             target_keys=['A_Id'],
                                             target_many=True,
                                             target_conditional=False,
                                             target_phrase='')
     ass.formalize()
     a = self.metamodel.new('A')
     b = self.metamodel.new('B')
     self.assertTrue(xtuml.relate(a, b, 1))
     
     self.assertEqual(a, xtuml.navigate_one(b).A[1]())
Пример #57
0
 def test_clone(self):
     s_ee = self.metamodel.new('S_EE', Name='Test', Descrip='test', Key_Lett='TEST')
     pe_pe = self.metamodel.new('PE_PE')
     self.assertTrue(xtuml.relate(s_ee, pe_pe, 8001))
     
     m = ooaofooa.empty_model()
     self.assertNotEqual(pe_pe, m.clone(pe_pe))
     self.assertNotEqual(s_ee, m.clone(s_ee))
     
     s_ee_clone = m.select_any('S_EE', where(Name='Test'))
     self.assertNotEqual(s_ee, s_ee_clone)
     self.assertEqual(s_ee_clone.EE_ID, s_ee.EE_ID)
     self.assertEqual(s_ee_clone.Name, s_ee.Name)
     self.assertEqual(s_ee_clone.Descrip, s_ee.Descrip)
     self.assertEqual(s_ee_clone.Key_Lett, s_ee.Key_Lett)
     
     pe_pe_clone = xtuml.navigate_one(s_ee_clone).PE_PE[8001]()
     self.assertTrue(pe_pe_clone)
     self.assertNotEqual(pe_pe, pe_pe_clone)
     self.assertEqual(pe_pe_clone.Element_ID, pe_pe.Element_ID)
     self.assertEqual(pe_pe_clone.Visibility, pe_pe.Visibility)
     self.assertEqual(pe_pe_clone.Package_ID, pe_pe.Package_ID)
     self.assertEqual(pe_pe_clone.Component_ID, pe_pe.Component_ID)
     self.assertEqual(pe_pe_clone.type, pe_pe.type)
Пример #58
0
    def test_select_many_navigation(self):
        '''
        |===================|                |======================|  
        |         A         |                |         B            |
        |-------------------| 1           *  |----------------------|
        | Id: unique_id {I} | -------------- | Id: unique_id    {I} |
        |===================|       R1       | A_Id: unique_id {R1} |
                                             |======================|
        '''
        self.metamodel.define_class('A', [('Id', 'unique_id')])
        self.metamodel.define_class('B', [('Id', 'unique_id'),
                                          ('A_Id', 'unique_id')])

        self.metamodel.define_association(rel_id='R1',
                                          source_kind='B',
                                          target_kind='A',
                                          source_keys=['A_Id'],
                                          target_keys=['Id'],
                                          source_many=True,
                                          target_many=False,
                                          source_conditional=True,
                                          target_conditional=False,
                                          source_phrase='',
                                          target_phrase='')

        a = self.metamodel.new('A')
        xtuml.relate(a, self.metamodel.new('B'), 1)
        xtuml.relate(a, self.metamodel.new('B'), 1)
        xtuml.relate(a, self.metamodel.new('B'), 1)

        text = '''
        .select any a from instances of A
        .select many bs related by a->B[R1]
        .exit cardinality bs
        '''

        rc = self.eval_text(text)
        self.assertEqual(3, rc)