rgen 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. data/CHANGELOG +20 -1
  2. data/MIT-LICENSE +1 -1
  3. data/README +12 -9
  4. data/lib/instantiators/ea_instantiator.rb +36 -0
  5. data/lib/metamodels/uml13_metamodel.rb +559 -0
  6. data/lib/metamodels/uml13_metamodel_ext.rb +26 -0
  7. data/lib/mmgen/metamodel_generator.rb +5 -5
  8. data/lib/mmgen/mm_ext/ecore_ext.rb +95 -0
  9. data/lib/mmgen/mmgen.rb +6 -4
  10. data/lib/mmgen/templates/annotations.tpl +37 -0
  11. data/lib/mmgen/templates/metamodel_generator.tpl +171 -0
  12. data/lib/rgen/ecore/ecore.rb +190 -0
  13. data/lib/rgen/ecore/ecore_instantiator.rb +25 -0
  14. data/lib/rgen/ecore/ecore_transformer.rb +85 -0
  15. data/lib/rgen/environment.rb +9 -24
  16. data/lib/rgen/find_helper.rb +68 -0
  17. data/lib/rgen/{instantiator.rb → instantiator/abstract_instantiator.rb} +6 -2
  18. data/lib/rgen/instantiator/abstract_xml_instantiator.rb +59 -0
  19. data/lib/rgen/instantiator/default_xml_instantiator.rb +117 -0
  20. data/lib/rgen/instantiator/ecore_xml_instantiator.rb +144 -0
  21. data/lib/rgen/instantiator/nodebased_xml_instantiator.rb +157 -0
  22. data/lib/rgen/instantiator/xmi11_instantiator.rb +164 -0
  23. data/lib/rgen/metamodel_builder.rb +103 -9
  24. data/lib/rgen/metamodel_builder/build_helper.rb +26 -4
  25. data/lib/rgen/metamodel_builder/builder_extensions.rb +285 -88
  26. data/lib/rgen/metamodel_builder/builder_runtime.rb +7 -1
  27. data/lib/rgen/metamodel_builder/data_types.rb +67 -0
  28. data/lib/rgen/metamodel_builder/intermediate/annotation.rb +30 -0
  29. data/lib/rgen/metamodel_builder/metamodel_description.rb +232 -0
  30. data/lib/rgen/metamodel_builder/mm_multiple.rb +23 -0
  31. data/lib/rgen/metamodel_builder/module_extension.rb +33 -0
  32. data/lib/rgen/model_comparator.rb +56 -0
  33. data/lib/rgen/model_dumper.rb +5 -5
  34. data/lib/rgen/name_helper.rb +17 -1
  35. data/lib/rgen/template_language.rb +148 -28
  36. data/lib/rgen/template_language/directory_template_container.rb +56 -38
  37. data/lib/rgen/template_language/output_handler.rb +93 -77
  38. data/lib/rgen/template_language/template_container.rb +186 -143
  39. data/lib/rgen/transformer.rb +19 -14
  40. data/lib/transformers/uml13_to_ecore.rb +75 -0
  41. data/redist/xmlscan/ChangeLog +1301 -0
  42. data/redist/xmlscan/README +34 -0
  43. data/redist/xmlscan/THANKS +11 -0
  44. data/redist/xmlscan/doc/changes.html +74 -0
  45. data/redist/xmlscan/doc/changes.rd +80 -0
  46. data/redist/xmlscan/doc/en/conformance.html +136 -0
  47. data/redist/xmlscan/doc/en/conformance.rd +152 -0
  48. data/redist/xmlscan/doc/en/manual.html +356 -0
  49. data/redist/xmlscan/doc/en/manual.rd +402 -0
  50. data/redist/xmlscan/doc/ja/conformance.ja.html +118 -0
  51. data/redist/xmlscan/doc/ja/conformance.ja.rd +134 -0
  52. data/redist/xmlscan/doc/ja/manual.ja.html +325 -0
  53. data/redist/xmlscan/doc/ja/manual.ja.rd +370 -0
  54. data/redist/xmlscan/doc/src/Makefile +41 -0
  55. data/redist/xmlscan/doc/src/conformance.rd.src +256 -0
  56. data/redist/xmlscan/doc/src/langsplit.rb +110 -0
  57. data/redist/xmlscan/doc/src/manual.rd.src +614 -0
  58. data/redist/xmlscan/install.rb +41 -0
  59. data/redist/xmlscan/lib/xmlscan/encoding.rb +311 -0
  60. data/redist/xmlscan/lib/xmlscan/htmlscan.rb +289 -0
  61. data/redist/xmlscan/lib/xmlscan/namespace.rb +352 -0
  62. data/redist/xmlscan/lib/xmlscan/parser.rb +299 -0
  63. data/redist/xmlscan/lib/xmlscan/scanner.rb +1109 -0
  64. data/redist/xmlscan/lib/xmlscan/version.rb +22 -0
  65. data/redist/xmlscan/lib/xmlscan/visitor.rb +158 -0
  66. data/redist/xmlscan/lib/xmlscan/xmlchar.rb +441 -0
  67. data/redist/xmlscan/memo/CONFORMANCE +1249 -0
  68. data/redist/xmlscan/memo/PRODUCTIONS +195 -0
  69. data/redist/xmlscan/memo/contentspec.ry +335 -0
  70. data/redist/xmlscan/samples/chibixml.rb +105 -0
  71. data/redist/xmlscan/samples/getxmlchar.rb +122 -0
  72. data/redist/xmlscan/samples/rexml.rb +159 -0
  73. data/redist/xmlscan/samples/xmlbench.rb +88 -0
  74. data/redist/xmlscan/samples/xmlbench/parser/chibixml.rb +22 -0
  75. data/redist/xmlscan/samples/xmlbench/parser/nqxml.rb +29 -0
  76. data/redist/xmlscan/samples/xmlbench/parser/rexml.rb +62 -0
  77. data/redist/xmlscan/samples/xmlbench/parser/xmlparser.rb +22 -0
  78. data/redist/xmlscan/samples/xmlbench/parser/xmlscan-0.0.10.rb +62 -0
  79. data/redist/xmlscan/samples/xmlbench/parser/xmlscan-chibixml.rb +22 -0
  80. data/redist/xmlscan/samples/xmlbench/parser/xmlscan-rexml.rb +22 -0
  81. data/redist/xmlscan/samples/xmlbench/parser/xmlscan.rb +99 -0
  82. data/redist/xmlscan/samples/xmlbench/xmlbench-lib.rb +116 -0
  83. data/redist/xmlscan/samples/xmlconftest.rb +200 -0
  84. data/redist/xmlscan/test.rb +7 -0
  85. data/redist/xmlscan/tests/deftestcase.rb +73 -0
  86. data/redist/xmlscan/tests/runtest.rb +47 -0
  87. data/redist/xmlscan/tests/testall.rb +14 -0
  88. data/redist/xmlscan/tests/testencoding.rb +438 -0
  89. data/redist/xmlscan/tests/testhtmlscan.rb +752 -0
  90. data/redist/xmlscan/tests/testnamespace.rb +457 -0
  91. data/redist/xmlscan/tests/testparser.rb +591 -0
  92. data/redist/xmlscan/tests/testscanner.rb +1749 -0
  93. data/redist/xmlscan/tests/testxmlchar.rb +143 -0
  94. data/redist/xmlscan/tests/visitor.rb +34 -0
  95. data/test/array_extensions_test.rb +2 -2
  96. data/test/ea_instantiator_test.rb +41 -0
  97. data/test/ecore_self_test.rb +53 -0
  98. data/test/environment_test.rb +11 -6
  99. data/test/metamodel_builder_test.rb +404 -245
  100. data/test/metamodel_roundtrip_test.rb +52 -0
  101. data/test/metamodel_roundtrip_test/TestModel.rb +65 -0
  102. data/test/metamodel_roundtrip_test/TestModel_Regenerated.rb +64 -0
  103. data/test/metamodel_roundtrip_test/houseMetamodel.ecore +32 -0
  104. data/test/metamodel_roundtrip_test/houseMetamodel_from_ecore.rb +39 -0
  105. data/test/rgen_test.rb +3 -3
  106. data/test/template_language_test.rb +65 -39
  107. data/test/template_language_test/expected_result.txt +24 -3
  108. data/test/template_language_test/templates/code/array.tpl +11 -0
  109. data/test/template_language_test/templates/content/author.tpl +7 -0
  110. data/test/template_language_test/templates/content/chapter.tpl +1 -1
  111. data/test/template_language_test/templates/root.tpl +17 -8
  112. data/test/template_language_test/testout.txt +24 -3
  113. data/test/testmodel/class_model_checker.rb +119 -0
  114. data/test/{xmi_instantiator_test/testmodel.eap → testmodel/ea_testmodel.eap} +0 -0
  115. data/test/{xmi_instantiator_test/testmodel.xml → testmodel/ea_testmodel.xml} +81 -14
  116. data/test/testmodel/ea_testmodel_partial.xml +317 -0
  117. data/test/testmodel/ecore_model_checker.rb +101 -0
  118. data/test/testmodel/manual_testmodel.xml +22 -0
  119. data/test/testmodel/object_model_checker.rb +67 -0
  120. data/test/transformer_test.rb +18 -10
  121. data/test/xml_instantiator_test.rb +81 -8
  122. data/test/xml_instantiator_test/simple_ecore_model_checker.rb +94 -0
  123. data/test/xml_instantiator_test/simple_xmi_ecore_instantiator.rb +53 -0
  124. data/test/xml_instantiator_test/simple_xmi_metamodel.rb +49 -0
  125. data/test/xml_instantiator_test/simple_xmi_to_ecore.rb +75 -0
  126. metadata +126 -28
  127. data/lib/ea/xmi_class_instantiator.rb +0 -46
  128. data/lib/ea/xmi_helper.rb +0 -26
  129. data/lib/ea/xmi_metamodel.rb +0 -34
  130. data/lib/ea/xmi_object_instantiator.rb +0 -46
  131. data/lib/ea/xmi_to_classmodel.rb +0 -78
  132. data/lib/ea/xmi_to_objectmodel.rb +0 -92
  133. data/lib/mmgen/mm_ext/uml_classmodel_ext.rb +0 -71
  134. data/lib/mmgen/templates/uml_classmodel.tpl +0 -63
  135. data/lib/rgen/xml_instantiator.rb +0 -132
  136. data/lib/uml/objectmodel_instantiator.rb +0 -53
  137. data/lib/uml/uml_classmodel.rb +0 -92
  138. data/lib/uml/uml_objectmodel.rb +0 -65
  139. data/test/metamodel_generator_test.rb +0 -44
  140. data/test/metamodel_generator_test/TestModel.rb +0 -40
  141. data/test/metamodel_generator_test/expected_result.txt +0 -40
  142. data/test/xmi_class_instantiator_test.rb +0 -24
  143. data/test/xmi_instantiator_test/class_model_checker.rb +0 -97
  144. data/test/xmi_object_instantiator_test.rb +0 -65
  145. data/test/xml_instantiator_test/testmodel.xml +0 -7
@@ -1,53 +0,0 @@
1
- module ObjectmodelInstantiator
2
-
3
- def instantiateObjectModel(env_in, env_out, metamodel)
4
- objectMap = {}
5
- env_in.find(:class => UMLObjectModel::UMLObject).each do |o_in|
6
- o_out = env_out.new metamodel.const_get(o_in.classname)
7
- objectMap[o_in] = o_out
8
- o_out.name = o_in.name
9
- o_in.attributeSettings.each { |as|
10
- conversions = ["to_s", "to_i", "to_f"]
11
- conv = conversions.first
12
- begin
13
- o_out.send(as.name+"=",as.value.send(conv))
14
- rescue StandardError
15
- conv = conversions[conversions.index(conv)+1]
16
- retry if conv
17
- raise
18
- end
19
- }
20
- end
21
- env_in.find(:class => UMLObjectModel::UMLAssociation).each do |a_in|
22
- begin
23
- if a_in.roleA
24
- begin
25
- o_out = objectMap[a_in.objectB]
26
- es = o_out.send(a_in.roleA)
27
- rescue NoMethodError
28
- raise StandardError.new("In #{o_out.class.name}(#{o_out.name}): method not found #{a_in.roleA}")
29
- end
30
- if es.is_a? RGen::MetamodelBuilder::ElementSet
31
- es << objectMap[a_in.objectA]
32
- else
33
- objectMap[a_in.objectB].send(a_in.roleA+"=", objectMap[a_in.objectA])
34
- end
35
- elsif a_in.roleB
36
- begin
37
- o_out = objectMap[a_in.objectA]
38
- es = o_out.send(a_in.roleB)
39
- rescue NoMethodError
40
- raise StandardError.new("In #{o_out.class.name}(#{o_out.name}): method not found #{a_in.roleB}")
41
- end
42
- if es.is_a? RGen::MetamodelBuilder::ElementSet
43
- es << objectMap[a_in.objectB]
44
- else
45
- objectMap[a_in.objectA].send(a_in.roleB+"=", objectMap[a_in.objectB])
46
- end
47
- end
48
- rescue StandardError => e
49
- puts e.message
50
- end
51
- end
52
- end
53
- end
@@ -1,92 +0,0 @@
1
- require 'rgen/metamodel_builder'
2
-
3
- module UMLClassModel
4
-
5
- include RGen::MetamodelBuilder
6
-
7
- class UMLPackage < MMBase
8
- has_one 'name', String
9
- def allClasses
10
- subpackages.inject(classes) {|r,p| r.concat(p.allClasses) }
11
- end
12
- end
13
-
14
- class UMLClass < MMBase
15
- has_one 'name', String
16
- has_many 'stereotypes', String
17
- def remoteNavigableEnds
18
- assocEnds.otherEnd.select{|e| e.navigable}
19
- end
20
- def localNavigableEnds
21
- assocEnds.select{|e| e.navigable}
22
- end
23
- def localCompositeEnds
24
- assocEnds.select{|e| e.composite}
25
- end
26
- def remoteCompositeEnds
27
- assocEnds.otherEnd.select{|e| e.composite}
28
- # put constraint check here and return the container directly ?
29
- end
30
- end
31
-
32
- class UMLOperation < MMBase
33
- has_one 'name', String
34
- end
35
-
36
- class UMLAttribute < MMBase
37
- has_one 'name', String
38
- has_one 'type', String
39
- end
40
-
41
- class UMLTaggedValue < MMBase
42
- has_one 'tag'
43
- has_one 'value'
44
- end
45
-
46
- class UMLAssociation < MMBase
47
- end
48
-
49
- class UMLAggregation < UMLAssociation
50
- end
51
-
52
- class UMLAssociationEnd < MMBase
53
- has_one 'multiplicity', String
54
- has_one 'navigable' # boolean
55
- has_one 'composite' # boolean
56
- has_one 'role', String
57
- def assoc
58
- assocA || assocB
59
- end
60
- def otherEnd
61
- return unless assoc
62
- assoc.endA == self ? assoc.endB : assoc.endA
63
- end
64
- def lowerMult
65
- return unless multiplicity
66
- stringToMult(multiplicity.split("..")[0])
67
- end
68
- def upperMult
69
- return unless multiplicity
70
- ma = multiplicity.split("..")
71
- stringToMult(ma[1] || ma[0])
72
- end
73
- private
74
- def stringToMult(s)
75
- return :many if s == "*"
76
- return s.to_i
77
- end
78
- end
79
-
80
- UMLPackage.one_to_many 'subpackages', UMLPackage, 'superpackage'
81
- UMLPackage.one_to_many 'classes', UMLClass, 'package'
82
-
83
- UMLClass.many_to_many 'superclasses', UMLClass, 'subclasses'
84
- UMLClass.one_to_many 'assocEnds', UMLAssociationEnd, 'clazz'
85
- UMLClass.one_to_many 'attributes', UMLAttribute, 'clazz'
86
- UMLClass.one_to_many 'operations', UMLOperation, 'clazz'
87
- UMLClass.one_to_many 'taggedvalues', UMLTaggedValue, 'clazz'
88
-
89
- UMLAssociation.one_to_one 'endA', UMLAssociationEnd, 'assocA'
90
- UMLAssociation.one_to_one 'endB', UMLAssociationEnd, 'assocB'
91
-
92
- end
@@ -1,65 +0,0 @@
1
- require 'rgen/metamodel_builder'
2
-
3
- module UMLObjectModel
4
-
5
- include RGen::MetamodelBuilder
6
-
7
- class UMLPackage < MMBase
8
- has_one 'name', String
9
- def allObjects
10
- subpackages.inject(objects) {|r,p| r.concat(p.allObjects) }
11
- end
12
- end
13
-
14
- class UMLObject < MMBase
15
- has_one 'name', String
16
- has_one 'classname', String
17
- def remoteNavigableEnds
18
- assocEnds.otherEnd.select{|e| e.navigable}
19
- end
20
- def localNavigableEnds
21
- assocEnds.select{|e| e.navigable}
22
- end
23
- def localCompositeEnds
24
- assocEnds.select{|e| e.composite}
25
- end
26
- def remoteCompositeEnds
27
- assocEnds.otherEnd.select{|e| e.composite}
28
- # put constraint check here and return the container directly ?
29
- end
30
- end
31
-
32
- class UMLAttributeSetting < MMBase
33
- has_one 'name', String
34
- has_one 'value', String
35
- end
36
-
37
- class UMLAssociation < MMBase
38
- end
39
-
40
- class UMLAggregation < UMLAssociation
41
- end
42
-
43
- class UMLAssociationEnd < MMBase
44
- has_one 'navigable' # boolean
45
- has_one 'composite' # boolean
46
- has_one 'role', String
47
- def assoc
48
- assocA || assocB
49
- end
50
- def otherEnd
51
- return unless assoc
52
- assoc.endA == self ? assoc.endB : assoc.endA
53
- end
54
- end
55
-
56
- UMLPackage.one_to_many 'subpackages', UMLPackage, 'superpackage'
57
- UMLPackage.one_to_many 'objects', UMLObject, 'package'
58
-
59
- UMLObject.one_to_many 'assocEnds', UMLAssociationEnd, 'object'
60
- UMLObject.one_to_many 'attributeSettings', UMLAttributeSetting, 'object'
61
-
62
- UMLAssociation.one_to_one 'endA', UMLAssociationEnd, 'assocA'
63
- UMLAssociation.one_to_one 'endB', UMLAssociationEnd, 'assocB'
64
-
65
- end
@@ -1,44 +0,0 @@
1
- $:.unshift File.join(File.dirname(__FILE__),"..","lib")
2
-
3
- require 'test/unit'
4
- require 'ea/xmi_class_instantiator'
5
- require 'mmgen/metamodel_generator'
6
-
7
- class MetamodelGeneratorTest < Test::Unit::TestCase
8
-
9
- MODEL_DIR = File.join(File.dirname(__FILE__),"xmi_instantiator_test")
10
- OUTPUT_DIR = File.dirname(__FILE__)+"/metamodel_generator_test"
11
- MM_FILE = OUTPUT_DIR+"/TestModel.rb"
12
-
13
- include MMGen::MetamodelGenerator
14
-
15
- def test_generator
16
- envUML = RGen::Environment.new
17
- File.open(MODEL_DIR+"/testmodel.xml") { |f|
18
- XMIClassInstantiator.new.instantiateUMLClassModel(envUML, f.read)
19
- }
20
-
21
- rootPackage = envUML.find(:class => UMLClassModel::UMLPackage).select{|p| p.name == "HouseMetamodel"}.first
22
- assert_not_nil rootPackage
23
-
24
- assert_raise StandardError do
25
- # this will raise an exception because multiple inheritance is not resolved
26
- generateMetamodel(rootPackage, MM_FILE)
27
- end
28
-
29
- # resolve multiple inheritance by specifying which class should be a module
30
- modules = ['MeetingPlace']
31
- generateMetamodel(rootPackage, MM_FILE, modules)
32
-
33
- # try to use the generated metamodel
34
- File.open(MM_FILE) { |f|
35
- eval(f.read)
36
- }
37
- assert HouseMetamodel::House.new
38
-
39
- result = expected = ""
40
- File.open(MM_FILE) {|f| result = f.read}
41
- File.open(OUTPUT_DIR+"/expected_result.txt") {|f| expected = f.read}
42
- assert_equal expected, result
43
- end
44
- end
@@ -1,40 +0,0 @@
1
- require 'rgen/metamodel_builder'
2
- module HouseMetamodel
3
-
4
- class Person < RGen::MetamodelBuilder::MMBase
5
- has_one 'name', String
6
- end
7
-
8
- class House < RGen::MetamodelBuilder::MMBase
9
- has_one 'name', String
10
- has_one 'address', String
11
- end
12
-
13
- module MeetingPlace
14
- extend RGen::MetamodelBuilder::BuilderExtensions
15
- has_one 'name', String
16
- end
17
-
18
-
19
- module Rooms
20
-
21
- class Room < RGen::MetamodelBuilder::MMBase
22
- has_one 'name', String
23
- end
24
-
25
- class Bathroom < Room
26
- has_one 'name', String
27
- end
28
-
29
- class Kitchen < Room
30
- include MeetingPlace
31
- has_one 'name', String
32
- end
33
-
34
- end
35
- end
36
-
37
- HouseMetamodel::Person.one_to_many 'home', HouseMetamodel::House, 'person'
38
- HouseMetamodel::House.one_to_one 'bathroom', HouseMetamodel::Rooms::Bathroom, 'house'
39
- HouseMetamodel::Rooms::Kitchen.one_to_one 'house', HouseMetamodel::House, 'kitchen'
40
- HouseMetamodel::House.one_to_many 'room', HouseMetamodel::Rooms::Room, 'house'
@@ -1,40 +0,0 @@
1
- require 'rgen/metamodel_builder'
2
- module HouseMetamodel
3
-
4
- class Person < RGen::MetamodelBuilder::MMBase
5
- has_one 'name', String
6
- end
7
-
8
- class House < RGen::MetamodelBuilder::MMBase
9
- has_one 'name', String
10
- has_one 'address', String
11
- end
12
-
13
- module MeetingPlace
14
- extend RGen::MetamodelBuilder::BuilderExtensions
15
- has_one 'name', String
16
- end
17
-
18
-
19
- module Rooms
20
-
21
- class Room < RGen::MetamodelBuilder::MMBase
22
- has_one 'name', String
23
- end
24
-
25
- class Bathroom < Room
26
- has_one 'name', String
27
- end
28
-
29
- class Kitchen < Room
30
- include MeetingPlace
31
- has_one 'name', String
32
- end
33
-
34
- end
35
- end
36
-
37
- HouseMetamodel::Person.one_to_many 'home', HouseMetamodel::House, 'person'
38
- HouseMetamodel::House.one_to_one 'bathroom', HouseMetamodel::Rooms::Bathroom, 'house'
39
- HouseMetamodel::Rooms::Kitchen.one_to_one 'house', HouseMetamodel::House, 'kitchen'
40
- HouseMetamodel::House.one_to_many 'room', HouseMetamodel::Rooms::Room, 'house'
@@ -1,24 +0,0 @@
1
- $:.unshift File.join(File.dirname(__FILE__),"..","lib")
2
- $:.unshift File.join(File.dirname(__FILE__),"..","test")
3
-
4
- require 'test/unit'
5
- require 'ea/xmi_class_instantiator'
6
- require 'rgen/transformer'
7
- require 'xmi_instantiator_test/class_model_checker'
8
-
9
- class XmiClassInstantiatorTest < Test::Unit::TestCase
10
-
11
- MODEL_DIR = File.join(File.dirname(__FILE__),"xmi_instantiator_test")
12
-
13
- include ClassModelChecker
14
-
15
- def test_model
16
- envUML = RGen::Environment.new
17
- File.open(MODEL_DIR+"/testmodel.xml") { |f|
18
- XMIClassInstantiator.new.instantiateUMLClassModel(envUML, f.read)
19
- }
20
- checkClassModel(envUML)
21
- end
22
-
23
-
24
- end
@@ -1,97 +0,0 @@
1
- require 'uml/uml_classmodel'
2
-
3
- module ClassModelChecker
4
- include UMLClassModel
5
-
6
- def checkClassModel(envUML)
7
-
8
- # check main package
9
- mainPackage = envUML.elements.select {|e| e.is_a? UMLPackage and e.name == "HouseMetamodel"}.first
10
- assert_not_nil mainPackage
11
-
12
- # check Rooms package
13
- assert mainPackage.subpackages.is_a?(Array)
14
- assert_equal 1, mainPackage.subpackages.size
15
- assert mainPackage.subpackages[0].is_a?(UMLPackage)
16
- roomsPackage = mainPackage.subpackages[0]
17
- assert_equal "Rooms", roomsPackage.name
18
-
19
- # check main package classes
20
- assert mainPackage.classes.is_a?(Array)
21
- assert_equal 3, mainPackage.classes.size
22
- assert mainPackage.classes.all?{|c| c.is_a?(UMLClass)}
23
- houseClass = mainPackage.classes.select{|c| c.name == "House"}.first
24
- personClass = mainPackage.classes.select{|c| c.name == "Person"}.first
25
- meetingPlaceClass = mainPackage.classes.select{|c| c.name == "MeetingPlace"}.first
26
- assert_not_nil houseClass
27
- assert_not_nil personClass
28
- assert_not_nil meetingPlaceClass
29
-
30
- # check Rooms package classes
31
- assert roomsPackage.classes.is_a?(Array)
32
- assert_equal 3, roomsPackage.classes.size
33
- assert roomsPackage.classes.all?{|c| c.is_a?(UMLClass)}
34
- roomClass = roomsPackage.classes.select{|c| c.name == "Room"}.first
35
- kitchenClass = roomsPackage.classes.select{|c| c.name == "Kitchen"}.first
36
- bathroomClass = roomsPackage.classes.select{|c| c.name == "Bathroom"}.first
37
- assert_not_nil roomClass
38
- assert_not_nil kitchenClass
39
- assert_not_nil bathroomClass
40
-
41
- # check Room inheritance
42
- assert roomClass.subclasses.is_a?(Array)
43
- assert_equal 2, roomClass.subclasses.size
44
- assert_not_nil roomClass.subclasses.select{|c| c.name == "Kitchen"}.first
45
- assert_not_nil roomClass.subclasses.select{|c| c.name == "Bathroom"}.first
46
- assert kitchenClass.superclasses.is_a?(Array)
47
- assert_equal 2, kitchenClass.superclasses.size
48
- assert_equal roomClass.object_id, kitchenClass.superclasses.select{|c| c.name == "Room"}.first.object_id
49
- assert_equal meetingPlaceClass.object_id, kitchenClass.superclasses.select{|c| c.name == "MeetingPlace"}.first.object_id
50
- assert bathroomClass.superclasses.is_a?(Array)
51
- assert_equal 1, bathroomClass.superclasses.size
52
- assert_equal roomClass.object_id, bathroomClass.superclasses[0].object_id
53
-
54
- # check House-Room "part of" association
55
- assert houseClass.localCompositeEnds.otherEnd.clazz.is_a?(Array)
56
- assert_equal 1, houseClass.localCompositeEnds.size
57
- roomEnd = houseClass.localCompositeEnds[0].otherEnd
58
- assert_equal UMLAggregation, roomEnd.assoc.class
59
- assert_equal roomClass.object_id, roomEnd.clazz.object_id
60
- assert_equal "room", roomEnd.role
61
- assert_equal "1..*", roomEnd.multiplicity
62
- assert_equal 1, roomEnd.lowerMult
63
- assert_equal :many, roomEnd.upperMult
64
-
65
- assert roomClass.remoteCompositeEnds.clazz.is_a?(Array)
66
- assert_equal 1, roomClass.remoteCompositeEnds.size
67
- assert_equal houseClass.object_id, roomClass.remoteCompositeEnds[0].clazz.object_id
68
- assert_equal "house", roomClass.remoteCompositeEnds[0].role
69
-
70
- # check House OUT associations
71
- assert houseClass.remoteNavigableEnds.is_a?(Array)
72
- assert_equal 2, houseClass.remoteNavigableEnds.size
73
- bathEnd = houseClass.remoteNavigableEnds.select{|e| e.role == "bathroom"}.first
74
- kitchenEnd = houseClass.remoteNavigableEnds.select{|e| e.role == "kitchen"}.first
75
- assert_not_nil bathEnd
76
- assert_not_nil kitchenEnd
77
- assert_equal UMLAssociation, bathEnd.assoc.class
78
- assert_equal UMLAssociation, kitchenEnd.assoc.class
79
- assert_equal "1", kitchenEnd.multiplicity
80
- assert_equal 1, kitchenEnd.lowerMult
81
- assert_equal 1, kitchenEnd.upperMult
82
-
83
- # check House IN associations
84
- assert houseClass.localNavigableEnds.is_a?(Array)
85
- assert_equal 3, houseClass.localNavigableEnds.size
86
- homeEnd = houseClass.localNavigableEnds.select{|e| e.role == "home"}.first
87
- assert_not_nil homeEnd
88
- assert_equal UMLAssociation, homeEnd.assoc.class
89
- assert_equal "0..*", homeEnd.multiplicity
90
- assert_equal 0, homeEnd.lowerMult
91
- assert_equal :many, homeEnd.upperMult
92
-
93
- # check House all associations
94
- assert houseClass.assocEnds.is_a?(Array)
95
- assert_equal 4, houseClass.assocEnds.size
96
- end
97
- end