lutaml-uml 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/macos.yml +36 -0
  3. data/.github/workflows/ubuntu.yml +38 -0
  4. data/.github/workflows/windows.yml +41 -0
  5. data/.gitignore +1 -0
  6. data/Gemfile +2 -1
  7. data/LUTAML.adoc +314 -0
  8. data/{README.md → README.adoc} +15 -16
  9. data/Rakefile +3 -1
  10. data/bin/console +1 -0
  11. data/bin/lutaml2dotpng +23 -0
  12. data/bin/yaml2lutaml +108 -0
  13. data/exe/lutaml-uml +4 -3
  14. data/lib/lutaml/layout/engine.rb +15 -0
  15. data/lib/lutaml/layout/graph_viz_engine.rb +16 -0
  16. data/lib/lutaml/uml.rb +3 -0
  17. data/lib/lutaml/uml/abstraction.rb +7 -5
  18. data/lib/lutaml/uml/activity.rb +7 -5
  19. data/lib/lutaml/uml/actor.rb +14 -12
  20. data/lib/lutaml/uml/association.rb +40 -14
  21. data/lib/lutaml/uml/behavior.rb +7 -5
  22. data/lib/lutaml/uml/class.rb +56 -16
  23. data/lib/lutaml/uml/classifier.rb +9 -6
  24. data/lib/lutaml/uml/connector.rb +16 -12
  25. data/lib/lutaml/uml/constraint.rb +8 -7
  26. data/lib/lutaml/uml/constructor_end.rb +11 -8
  27. data/lib/lutaml/uml/data_type.rb +9 -4
  28. data/lib/lutaml/uml/dependency.rb +16 -13
  29. data/lib/lutaml/uml/document.rb +71 -0
  30. data/lib/lutaml/uml/enum.rb +33 -0
  31. data/lib/lutaml/uml/event.rb +7 -5
  32. data/lib/lutaml/uml/final_state.rb +7 -5
  33. data/lib/lutaml/uml/formatter.rb +21 -0
  34. data/lib/lutaml/uml/formatter/base.rb +67 -0
  35. data/lib/lutaml/uml/formatter/graphviz.rb +335 -0
  36. data/lib/lutaml/uml/has_attributes.rb +14 -0
  37. data/lib/lutaml/uml/has_members.rb +30 -0
  38. data/lib/lutaml/uml/instance.rb +15 -10
  39. data/lib/lutaml/uml/interface/base.rb +28 -0
  40. data/lib/lutaml/uml/interface/command_line.rb +265 -0
  41. data/lib/lutaml/uml/model.rb +11 -8
  42. data/lib/lutaml/uml/node/base.rb +21 -0
  43. data/lib/lutaml/uml/node/class_node.rb +57 -0
  44. data/lib/lutaml/uml/node/class_relationship.rb +14 -0
  45. data/lib/lutaml/uml/node/document.rb +18 -0
  46. data/lib/lutaml/uml/node/field.rb +34 -0
  47. data/lib/lutaml/uml/node/has_name.rb +15 -0
  48. data/lib/lutaml/uml/node/has_type.rb +15 -0
  49. data/lib/lutaml/uml/node/method.rb +29 -0
  50. data/lib/lutaml/uml/node/method_argument.rb +16 -0
  51. data/lib/lutaml/uml/node/relationship.rb +28 -0
  52. data/lib/lutaml/uml/opaque_behavior.rb +7 -6
  53. data/lib/lutaml/uml/package.rb +16 -13
  54. data/lib/lutaml/uml/parsers/attribute.rb +70 -0
  55. data/lib/lutaml/uml/parsers/dsl.rb +375 -0
  56. data/lib/lutaml/uml/parsers/dsl_preprocessor.rb +44 -0
  57. data/lib/lutaml/uml/parsers/dsl_transform.rb +27 -0
  58. data/lib/lutaml/uml/parsers/yaml.rb +46 -0
  59. data/lib/lutaml/uml/port.rb +6 -4
  60. data/lib/lutaml/uml/primitive_type.rb +9 -4
  61. data/lib/lutaml/uml/property.rb +25 -15
  62. data/lib/lutaml/uml/pseudostate.rb +7 -6
  63. data/lib/lutaml/uml/realization.rb +7 -5
  64. data/lib/lutaml/uml/region.rb +7 -6
  65. data/lib/lutaml/uml/serializers/association.rb +58 -0
  66. data/lib/lutaml/uml/serializers/base.rb +16 -0
  67. data/lib/lutaml/uml/serializers/class.rb +29 -0
  68. data/lib/lutaml/uml/serializers/top_element_attribute.rb +14 -0
  69. data/lib/lutaml/uml/serializers/yaml_view.rb +18 -0
  70. data/lib/lutaml/uml/state.rb +8 -6
  71. data/lib/lutaml/uml/state_machine.rb +7 -5
  72. data/lib/lutaml/uml/top_element.rb +45 -35
  73. data/lib/lutaml/uml/top_element_attribute.rb +25 -0
  74. data/lib/lutaml/uml/transition.rb +8 -6
  75. data/lib/lutaml/uml/trigger.rb +8 -6
  76. data/lib/lutaml/uml/version.rb +3 -1
  77. data/lib/lutaml/uml/vertex.rb +7 -5
  78. data/lutaml-uml.gemspec +9 -2
  79. data/spec/fixtures/datamodel/models/AddressClassProfile.yml +90 -0
  80. data/spec/fixtures/datamodel/models/AddressComponentProfile.yml +63 -0
  81. data/spec/fixtures/datamodel/models/AddressComponentSpecification.yml +15 -0
  82. data/spec/fixtures/datamodel/models/AddressProfile.yml +36 -0
  83. data/spec/fixtures/datamodel/models/AttributeProfile.yml +32 -0
  84. data/spec/fixtures/datamodel/models/InterchangeAddressClassProfile.yml +79 -0
  85. data/spec/fixtures/datamodel/models/Localization copy.yml +23 -0
  86. data/spec/fixtures/datamodel/models/Localization.yml +23 -0
  87. data/spec/fixtures/datamodel/models/ProfileCompliantAddress.yml +36 -0
  88. data/spec/fixtures/datamodel/models/ProfileCompliantAddressComponent.yml +15 -0
  89. data/spec/fixtures/datamodel/models/Signature.yml +20 -0
  90. data/spec/fixtures/datamodel/models/SignatureBlankDefinition.yml +20 -0
  91. data/spec/fixtures/datamodel/models/TextDirectionCode copy.yml +16 -0
  92. data/spec/fixtures/datamodel/models/TextDirectionCode.yml +16 -0
  93. data/spec/fixtures/datamodel/models/Validity.yml +14 -0
  94. data/spec/fixtures/datamodel/models/iso19160-1/Address.yml +22 -0
  95. data/spec/fixtures/datamodel/models/iso19160-1/AddressComponent.yml +2 -0
  96. data/spec/fixtures/datamodel/style.uml.inc +37 -0
  97. data/spec/fixtures/datamodel/views/AddressClassProfile.yml +12 -0
  98. data/spec/fixtures/datamodel/views/AddressProfile.yml +3 -0
  99. data/spec/fixtures/datamodel/views/CommonModels.yml +9 -0
  100. data/spec/fixtures/datamodel/views/TopDown.yml +62 -0
  101. data/spec/fixtures/dsl/diagram.lutaml +3 -0
  102. data/spec/fixtures/dsl/diagram_attributes.lutaml +5 -0
  103. data/spec/fixtures/dsl/diagram_class_assocation.lutaml +29 -0
  104. data/spec/fixtures/dsl/diagram_class_fields.lutaml +19 -0
  105. data/spec/fixtures/dsl/diagram_comments.lutaml +28 -0
  106. data/spec/fixtures/dsl/diagram_concept_model.lutaml +132 -0
  107. data/spec/fixtures/dsl/diagram_data_types.lutaml +24 -0
  108. data/spec/fixtures/dsl/diagram_includes.lutaml +6 -0
  109. data/spec/fixtures/dsl/diagram_multiply_classes.lutaml +7 -0
  110. data/spec/fixtures/dsl/shared.lutaml +3 -0
  111. data/spec/fixtures/dsl/shared1.lutaml +4 -0
  112. data/spec/fixtures/generated_dot/AddressClassProfile.dot +170 -0
  113. data/spec/fixtures/generated_dot/AddressProfile.dot +34 -0
  114. data/spec/lutaml/uml/formatter/graphviz_spec.rb +41 -0
  115. data/spec/lutaml/uml/parsers/dsl_spec.rb +252 -0
  116. data/spec/lutaml/uml/parsers/yaml_spec.rb +18 -0
  117. data/spec/lutaml/uml/serializers/yaml_view_spec.rb +20 -0
  118. data/spec/lutaml/uml_spec.rb +2 -4
  119. data/spec/spec_helper.rb +11 -0
  120. metadata +161 -13
@@ -0,0 +1,24 @@
1
+ diagram MyView {
2
+ title "my diagram"
3
+
4
+ enum MyEnum {}
5
+
6
+ enum AddressClassProfile {
7
+ +addressClassProfile: CharacterString
8
+ }
9
+
10
+ data_type "Banking Information" {
11
+ "art code"
12
+ "CCT Number"
13
+ }
14
+
15
+ primitive Integer
16
+
17
+ enum Profile {
18
+ imlicistAttributeProfile: CharacterString
19
+ +attributeProfile: CharacterString
20
+ -privateAttributeProfile: CharacterString
21
+ ~friendlyAttributeProfile: CharacterString
22
+ #protectedAttributeProfile: CharacterString
23
+ }
24
+ }
@@ -0,0 +1,6 @@
1
+ diagram MyView {
2
+ fontname "Arial"
3
+ title "my diagram"
4
+ include shared.lutaml
5
+ include shared1.lutaml
6
+ }
@@ -0,0 +1,7 @@
1
+ diagram MyView {
2
+ title "my diagram"
3
+ class Foo {}
4
+ class Doo {}
5
+ class Koo {}
6
+ class NamespacedClass <<MyNamespace>> {}
7
+ }
@@ -0,0 +1,3 @@
1
+ class Foo {}
2
+ class Doo {}
3
+ class Koo {}
@@ -0,0 +1,4 @@
1
+ class AttributeProfile {
2
+ imlicistAttributeProfile: CharacterString [0..1]
3
+ +attributeProfile: <<BasicDocument>> LocalizedString [0..1]
4
+ }
@@ -0,0 +1,170 @@
1
+ digraph G {
2
+ graph [splines="ortho" pad=0.5 ranksep="1.2.equally" nodesep="1.2.equally"]
3
+ edge [color="gray50"]
4
+ node [shape="box" fontname="Helvetica-bold"]
5
+
6
+ AddressProfile [
7
+ shape="plain"
8
+ fontname="Helvetica"
9
+ label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="10">
10
+ <TR>
11
+ <TD><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
12
+ <TR><TD ALIGN="CENTER"><B>AddressProfile</B></TD></TR>
13
+ </TABLE>
14
+ </TD>
15
+ </TR>
16
+
17
+ <TR>
18
+ <TD><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
19
+ <TR><TD ALIGN="LEFT"></TD></TR>
20
+ </TABLE></TD>
21
+ </TR>
22
+
23
+ <TR>
24
+ <TD><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
25
+ <TR><TD ALIGN="LEFT"></TD></TR>
26
+ </TABLE></TD>
27
+ </TR>
28
+
29
+ </TABLE>>]
30
+
31
+ AddressClassProfile [
32
+ shape="plain"
33
+ fontname="Helvetica"
34
+ label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="10">
35
+ <TR>
36
+ <TD><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
37
+ <TR><TD ALIGN="CENTER"><B>AddressClassProfile</B></TD></TR>
38
+ </TABLE>
39
+ </TD>
40
+ </TR>
41
+
42
+ <TR>
43
+ <TD><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
44
+ <TR><TD ALIGN="LEFT"></TD></TR>
45
+ </TABLE></TD>
46
+ </TR>
47
+
48
+ <TR>
49
+ <TD><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
50
+ <TR><TD ALIGN="LEFT"></TD></TR>
51
+ </TABLE></TD>
52
+ </TR>
53
+
54
+ </TABLE>>]
55
+
56
+ AddressComponentProfile [
57
+ shape="plain"
58
+ fontname="Helvetica"
59
+ label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="10">
60
+ <TR>
61
+ <TD><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
62
+ <TR><TD ALIGN="CENTER"><B>AddressComponentProfile</B></TD></TR>
63
+ </TABLE>
64
+ </TD>
65
+ </TR>
66
+
67
+ <TR>
68
+ <TD><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
69
+ <TR><TD ALIGN="LEFT"></TD></TR>
70
+ </TABLE></TD>
71
+ </TR>
72
+
73
+ <TR>
74
+ <TD><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
75
+ <TR><TD ALIGN="LEFT"></TD></TR>
76
+ </TABLE></TD>
77
+ </TR>
78
+
79
+ </TABLE>>]
80
+
81
+ AttributeProfile [
82
+ shape="plain"
83
+ fontname="Helvetica"
84
+ label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="10">
85
+ <TR>
86
+ <TD><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
87
+ <TR><TD ALIGN="CENTER"><B>AttributeProfile</B></TD></TR>
88
+ </TABLE>
89
+ </TD>
90
+ </TR>
91
+
92
+ <TR>
93
+ <TD><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
94
+ <TR><TD ALIGN="LEFT"></TD></TR>
95
+ </TABLE></TD>
96
+ </TR>
97
+
98
+ <TR>
99
+ <TD><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
100
+ <TR><TD ALIGN="LEFT"></TD></TR>
101
+ </TABLE></TD>
102
+ </TR>
103
+
104
+ </TABLE>>]
105
+
106
+ ProfileCompliantAddress [
107
+ shape="plain"
108
+ fontname="Helvetica"
109
+ label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="10">
110
+ <TR>
111
+ <TD><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
112
+ <TR><TD ALIGN="CENTER"><B>ProfileCompliantAddress</B></TD></TR>
113
+ </TABLE>
114
+ </TD>
115
+ </TR>
116
+
117
+ <TR>
118
+ <TD><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
119
+ <TR><TD ALIGN="LEFT"></TD></TR>
120
+ </TABLE></TD>
121
+ </TR>
122
+
123
+ <TR>
124
+ <TD><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
125
+ <TR><TD ALIGN="LEFT"></TD></TR>
126
+ </TABLE></TD>
127
+ </TR>
128
+
129
+ </TABLE>>]
130
+
131
+ InterchangeAddressClassProfile [
132
+ shape="plain"
133
+ fontname="Helvetica"
134
+ label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="10">
135
+ <TR>
136
+ <TD><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
137
+ <TR><TD ALIGN="CENTER"><B>InterchangeAddressClassProfile</B></TD></TR>
138
+ </TABLE>
139
+ </TD>
140
+ </TR>
141
+
142
+ <TR>
143
+ <TD><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
144
+ <TR><TD ALIGN="LEFT"></TD></TR>
145
+ </TABLE></TD>
146
+ </TR>
147
+
148
+ <TR>
149
+ <TD><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
150
+ <TR><TD ALIGN="LEFT"></TD></TR>
151
+ </TABLE></TD>
152
+ </TR>
153
+
154
+ </TABLE>>]
155
+
156
+ AddressProfile -> AddressComponentProfile [dir="back" label="defines ▶" arrowtail="onormal" arrowhead="odiamond" taillabel="+componentProfile 0..*"]
157
+ AddressProfile -> AddressClassProfile [dir="back" label="defines ▶" arrowtail="onormal" arrowhead="odiamond" taillabel="+addressProfile 0..*"]
158
+ AddressClassProfile -> AttributeProfile [dir="both" headlabel="+addressClassProfile" taillabel="+attributeProfile" arrowtail="odiamond" arrowhead="vee"]
159
+ AddressClassProfile -> ProfileCompliantAddress [dir="direct" label="◀ compliesWith" headlabel="+profile 1..1" arrowtail="onormal" arrowhead="vee"]
160
+ AddressComponentProfile -> AddressClassProfile [dir="direct" label="◀ uses" taillabel="+componentProfile" arrowtail="onormal" arrowhead="odiamond"]
161
+ AddressComponentProfile -> AttributeProfile [dir="both" headlabel="+addressClassProfile" taillabel="+attributeProfile" arrowtail="odiamond" arrowhead="vee"]
162
+
163
+
164
+
165
+ InterchangeAddressClassProfile -> AddressClassProfile [dir="direct" arrowtail="onormal" arrowhead="onormal"]
166
+
167
+
168
+
169
+
170
+ }
@@ -0,0 +1,34 @@
1
+ digraph G {
2
+ graph [splines="ortho" pad=0.5 ranksep="1.2.equally" nodesep="1.2.equally"]
3
+ edge [color="gray50"]
4
+ node [shape="box" fontname="Helvetica-bold"]
5
+
6
+ AddressProfile [
7
+ shape="plain"
8
+ fontname="Helvetica"
9
+ label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="10">
10
+ <TR>
11
+ <TD><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
12
+ <TR><TD ALIGN="CENTER"><B>AddressProfile</B></TD></TR>
13
+ </TABLE>
14
+ </TD>
15
+ </TR>
16
+
17
+ <TR>
18
+ <TD><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
19
+ <TR><TD ALIGN="LEFT">+country : iso3166Code&#91;0..*&#93;</TD></TR>
20
+ </TABLE>
21
+ </TD>
22
+ </TR>
23
+
24
+ <TR>
25
+ <TD><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
26
+ <TR><TD ALIGN="LEFT"></TD></TR>
27
+ </TABLE></TD>
28
+ </TR>
29
+
30
+ </TABLE>>]
31
+
32
+ AddressProfile -> AddressComponentProfile [dir="back" label="defines ▶" arrowtail="onormal" arrowhead="odiamond" taillabel="+componentProfile 0..*"]
33
+ AddressProfile -> AddressClassProfile [dir="back" label="defines ▶" arrowtail="onormal" arrowhead="odiamond" taillabel="+addressProfile 0..*"]
34
+ }
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ RSpec.describe Lutaml::Uml::Formatter::Graphviz do
6
+ describe ".format_document" do
7
+ subject(:format_document) do
8
+ described_class.new.format_document(input_document)
9
+ end
10
+
11
+ context "when simple aggregation" do
12
+ let(:input_document) do
13
+ Lutaml::Uml::Parsers::Yaml
14
+ .parse(fixtures_path("datamodel/views/AddressProfile.yml"))
15
+ end
16
+
17
+ let(:formatted_dot_content) do
18
+ File.read(fixtures_path("generated_dot/AddressProfile.dot"))
19
+ end
20
+
21
+ it "generates the correct relationship graph" do
22
+ expect(format_document).to eq(formatted_dot_content)
23
+ end
24
+ end
25
+
26
+ context "when aggregation with inheritance" do
27
+ let(:input_document) do
28
+ Lutaml::Uml::Parsers::Yaml
29
+ .parse(fixtures_path("datamodel/views/AddressClassProfile.yml"))
30
+ end
31
+
32
+ let(:formatted_dot_content) do
33
+ File.read(fixtures_path("generated_dot/AddressClassProfile.dot"))
34
+ end
35
+
36
+ it "generates the correct relationship graph" do
37
+ expect(format_document).to eq(formatted_dot_content)
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,252 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ RSpec.describe Lutaml::Uml::Parsers::Dsl do
6
+ describe ".parse" do
7
+ subject(:parse) { described_class.parse(content) }
8
+ subject(:format_parsed_document) do
9
+ Lutaml::Uml::Formatter::Graphviz.new.format_document(parse)
10
+ end
11
+
12
+ shared_examples "the correct graphviz formatting" do
13
+ it "does not raise error on graphviz formatting" do
14
+ expect { format_parsed_document }.to_not raise_error
15
+ end
16
+ end
17
+
18
+ context "when simple diagram without attributes" do
19
+ let(:content) do
20
+ File.new(fixtures_path("dsl/diagram.lutaml"))
21
+ end
22
+
23
+ it "creates Lutaml::Uml::Document object from supplied dsl" do
24
+ expect(parse).to be_instance_of(Lutaml::Uml::Document)
25
+ end
26
+
27
+ it_behaves_like "the correct graphviz formatting"
28
+ end
29
+
30
+ context "when diagram with attributes" do
31
+ let(:content) do
32
+ File.new(fixtures_path("dsl/diagram_attributes.lutaml"))
33
+ end
34
+
35
+ it "creates Lutaml::Uml::Document object and sets its attributes" do
36
+ expect(parse).to be_instance_of(Lutaml::Uml::Document)
37
+ expect(parse.title).to eq("my diagram")
38
+ expect(parse.fontname).to eq("Arial")
39
+ end
40
+
41
+ it_behaves_like "the correct graphviz formatting"
42
+ end
43
+
44
+ context "when multiply classes entries" do
45
+ let(:content) do
46
+ File.new(fixtures_path("dsl/diagram_multiply_classes.lutaml"))
47
+ end
48
+
49
+ it "creates Lutaml::Uml::Document object and creates dependent classes" do
50
+ classes = parse.classes
51
+ expect(parse).to be_instance_of(Lutaml::Uml::Document)
52
+ expect(parse.classes.length).to eq(4)
53
+ expect(by_name(classes, "NamespacedClass").keyword).to eq("MyNamespace")
54
+ end
55
+
56
+ it_behaves_like "the correct graphviz formatting"
57
+ end
58
+
59
+ context "when class with fields" do
60
+ let(:content) do
61
+ File.new(fixtures_path("dsl/diagram_class_fields.lutaml"))
62
+ end
63
+
64
+ it "creates the correct classes and sets the \
65
+ correct number of attributes" do
66
+ classes = parse.classes
67
+ expect(by_name(classes, "Component").attributes).to be_nil
68
+ expect(by_name(classes, "AddressClassProfile")
69
+ .attributes.length).to eq(1)
70
+ expect(by_name(classes, "AttributeProfile")
71
+ .attributes.length).to eq(7)
72
+ end
73
+
74
+ it "creates the correct attributes with the correct visibility" do
75
+ attributes = by_name(parse.classes, "AttributeProfile").attributes
76
+ expect(by_name(attributes, "imlicistAttributeProfile").visibility)
77
+ .to be_nil
78
+ expect(by_name(attributes, "imlicistAttributeProfile").keyword)
79
+ .to be_nil
80
+ expect(by_name(attributes, "attributeProfile").visibility)
81
+ .to eq("public")
82
+ expect(by_name(attributes, "attributeProfile").keyword)
83
+ .to eq("BasicDocument")
84
+ expect(by_name(attributes, "attributeProfile1").visibility)
85
+ .to eq("public")
86
+ expect(by_name(attributes, "attributeProfile1").keyword)
87
+ .to eq("BasicDocument")
88
+ expect(by_name(attributes, "privateAttributeProfile").visibility)
89
+ .to eq("private")
90
+ expect(by_name(attributes, "friendlyAttributeProfile").visibility)
91
+ .to eq("friendly")
92
+ expect(by_name(attributes, "friendlyAttributeProfile").keyword)
93
+ .to eq("Type")
94
+ expect(by_name(attributes, "protectedAttributeProfile").visibility)
95
+ .to eq("protected")
96
+ end
97
+
98
+ it_behaves_like "the correct graphviz formatting"
99
+ end
100
+
101
+ context "when association blocks exists" do
102
+ let(:content) do
103
+ File.new(fixtures_path("dsl/diagram_class_assocation.lutaml"))
104
+ end
105
+
106
+ it "creates the correct number of associations" do
107
+ expect(parse.associations.length).to eq(3)
108
+ end
109
+
110
+ context "when bidirectional asscoiation syntax " do
111
+ subject(:association) do
112
+ by_name(parse.associations, "BidirectionalAsscoiation")
113
+ end
114
+
115
+ it "creates associations with the correct attributes" do
116
+ expect(association.owner_end_type).to(eq("aggregation"))
117
+ expect(association.member_end_type).to(eq("direct"))
118
+ expect(association.owner_end).to(eq("AddressClassProfile"))
119
+ expect(association.owner_end_attribute_name)
120
+ .to(eq("addressClassProfile"))
121
+ expect(association.member_end).to(eq("AttributeProfile"))
122
+ expect(association.member_end_attribute_name)
123
+ .to(eq("attributeProfile"))
124
+ expect(association.member_end_cardinality).to(eq(min: "0", max: "*"))
125
+ end
126
+ end
127
+
128
+ context "when direct asscoiation syntax " do
129
+ subject(:association) do
130
+ by_name(parse.associations, "DirectAsscoiation")
131
+ end
132
+
133
+ it "creates associations with the correct attributes" do
134
+ expect(association.owner_end_type).to(be_nil)
135
+ expect(association.member_end_type).to(eq("direct"))
136
+ expect(association.owner_end).to(eq("AddressClassProfile"))
137
+ expect(association.owner_end_attribute_name).to(be_nil)
138
+ expect(association.member_end).to(eq("AttributeProfile"))
139
+ expect(association.member_end_attribute_name)
140
+ .to(eq("attributeProfile"))
141
+ expect(association.member_end_cardinality).to(be_nil)
142
+ end
143
+ end
144
+
145
+ context "when reverse asscoiation syntax " do
146
+ subject(:association) do
147
+ by_name(parse.associations, "ReverseAsscoiation")
148
+ end
149
+
150
+ it "creates associations with the correct attributes" do
151
+ expect(association.owner_end_type).to(eq("aggregation"))
152
+ expect(association.member_end_type).to(be_nil)
153
+ expect(association.owner_end).to(eq("AddressClassProfile"))
154
+ expect(association.owner_end_attribute_name)
155
+ .to(eq("addressClassProfile"))
156
+ expect(association.member_end).to(eq("AttributeProfile"))
157
+ expect(association.member_end_attribute_name).to(be_nil)
158
+ expect(association.member_end_cardinality).to(be_nil)
159
+ end
160
+ end
161
+ end
162
+
163
+ context "when data_types entries" do
164
+ let(:content) do
165
+ File.new(fixtures_path("dsl/diagram_data_types.lutaml"))
166
+ end
167
+
168
+ it "Generates the correct nodes for enums" do
169
+ enums = parse.enums
170
+ expect(by_name(enums, "MyEnum").attributes).to be_nil
171
+ expect(by_name(enums, "AddressClassProfile")
172
+ .attributes.length).to eq(1)
173
+ expect(by_name(enums, "Profile")
174
+ .attributes.length).to eq(5)
175
+ end
176
+
177
+ it "Generates the correct nodes for data_types" do
178
+ data_types = parse.data_types
179
+ expect(by_name(data_types, "Banking Information")
180
+ .attributes.map(&:name))
181
+ .to(eq(["art code", "CCT Number"]))
182
+ end
183
+
184
+ it "Generates the correct nodes for primitives" do
185
+ data_types = parse.primitives
186
+ expect(by_name(data_types, "Integer")).to_not be_nil
187
+ end
188
+
189
+ it_behaves_like "the correct graphviz formatting"
190
+ end
191
+
192
+ context "when concept model generated lutaml file" do
193
+ let(:content) do
194
+ File.new(fixtures_path("dsl/diagram_concept_model.lutaml"))
195
+ end
196
+
197
+ it "Generates the correct class/enums/associations list" do
198
+ document = parse
199
+ expect(document.classes.length).to(eq(9))
200
+ expect(document.enums.length).to(eq(3))
201
+ expect(document.associations.length).to(eq(16))
202
+ end
203
+
204
+ it "Generates the correct attributes list" do
205
+ attributes = by_name(parse.classes, "ExpressionDesignation").attributes
206
+ expect(attributes.length).to(eq(5))
207
+ expect(attributes.map(&:name))
208
+ .to(eq(%w[text language script pronunciation grammarInfo]))
209
+ expect(attributes.map(&:type))
210
+ .to(eq(["GlossaristTextElementType",
211
+ "Iso639ThreeCharCode",
212
+ "Iso15924Code",
213
+ "LocalizedString",
214
+ "GrammarInfo"]))
215
+ end
216
+
217
+ it_behaves_like "the correct graphviz formatting"
218
+ end
219
+
220
+ context "when include directives is used" do
221
+ let(:content) do
222
+ File.new(fixtures_path("dsl/diagram_includes.lutaml"))
223
+ end
224
+
225
+ it "includes supplied files into the document" do
226
+ expect(parse.classes.map(&:name))
227
+ .to(eq(%w[Foo Doo Koo AttributeProfile]))
228
+ expect(by_name(parse.classes, "AttributeProfile")
229
+ .attributes.map(&:name))
230
+ .to eq(["imlicistAttributeProfile", "attributeProfile"])
231
+ end
232
+
233
+ it_behaves_like "the correct graphviz formatting"
234
+ end
235
+
236
+ context "when include directives is used" do
237
+ let(:content) do
238
+ File.new(fixtures_path("dsl/diagram_comments.lutaml"))
239
+ end
240
+
241
+ it "create comments for document and classes" do
242
+ expect(parse.comments).to(eq(["My comment",
243
+ "this is multiline\n comment with {} special\n chars/\n\n +-|/"]))
244
+ expect(parse.classes.last.comments)
245
+ .to(eq(["this is attribute comment",
246
+ "this is another comment line\n with multiply lines"]))
247
+ end
248
+
249
+ it_behaves_like "the correct graphviz formatting"
250
+ end
251
+ end
252
+ end