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.
- checksums.yaml +4 -4
- data/.github/workflows/macos.yml +36 -0
- data/.github/workflows/ubuntu.yml +38 -0
- data/.github/workflows/windows.yml +41 -0
- data/.gitignore +1 -0
- data/Gemfile +2 -1
- data/LUTAML.adoc +314 -0
- data/{README.md → README.adoc} +15 -16
- data/Rakefile +3 -1
- data/bin/console +1 -0
- data/bin/lutaml2dotpng +23 -0
- data/bin/yaml2lutaml +108 -0
- data/exe/lutaml-uml +4 -3
- data/lib/lutaml/layout/engine.rb +15 -0
- data/lib/lutaml/layout/graph_viz_engine.rb +16 -0
- data/lib/lutaml/uml.rb +3 -0
- data/lib/lutaml/uml/abstraction.rb +7 -5
- data/lib/lutaml/uml/activity.rb +7 -5
- data/lib/lutaml/uml/actor.rb +14 -12
- data/lib/lutaml/uml/association.rb +40 -14
- data/lib/lutaml/uml/behavior.rb +7 -5
- data/lib/lutaml/uml/class.rb +56 -16
- data/lib/lutaml/uml/classifier.rb +9 -6
- data/lib/lutaml/uml/connector.rb +16 -12
- data/lib/lutaml/uml/constraint.rb +8 -7
- data/lib/lutaml/uml/constructor_end.rb +11 -8
- data/lib/lutaml/uml/data_type.rb +9 -4
- data/lib/lutaml/uml/dependency.rb +16 -13
- data/lib/lutaml/uml/document.rb +71 -0
- data/lib/lutaml/uml/enum.rb +33 -0
- data/lib/lutaml/uml/event.rb +7 -5
- data/lib/lutaml/uml/final_state.rb +7 -5
- data/lib/lutaml/uml/formatter.rb +21 -0
- data/lib/lutaml/uml/formatter/base.rb +67 -0
- data/lib/lutaml/uml/formatter/graphviz.rb +335 -0
- data/lib/lutaml/uml/has_attributes.rb +14 -0
- data/lib/lutaml/uml/has_members.rb +30 -0
- data/lib/lutaml/uml/instance.rb +15 -10
- data/lib/lutaml/uml/interface/base.rb +28 -0
- data/lib/lutaml/uml/interface/command_line.rb +265 -0
- data/lib/lutaml/uml/model.rb +11 -8
- data/lib/lutaml/uml/node/base.rb +21 -0
- data/lib/lutaml/uml/node/class_node.rb +57 -0
- data/lib/lutaml/uml/node/class_relationship.rb +14 -0
- data/lib/lutaml/uml/node/document.rb +18 -0
- data/lib/lutaml/uml/node/field.rb +34 -0
- data/lib/lutaml/uml/node/has_name.rb +15 -0
- data/lib/lutaml/uml/node/has_type.rb +15 -0
- data/lib/lutaml/uml/node/method.rb +29 -0
- data/lib/lutaml/uml/node/method_argument.rb +16 -0
- data/lib/lutaml/uml/node/relationship.rb +28 -0
- data/lib/lutaml/uml/opaque_behavior.rb +7 -6
- data/lib/lutaml/uml/package.rb +16 -13
- data/lib/lutaml/uml/parsers/attribute.rb +70 -0
- data/lib/lutaml/uml/parsers/dsl.rb +375 -0
- data/lib/lutaml/uml/parsers/dsl_preprocessor.rb +44 -0
- data/lib/lutaml/uml/parsers/dsl_transform.rb +27 -0
- data/lib/lutaml/uml/parsers/yaml.rb +46 -0
- data/lib/lutaml/uml/port.rb +6 -4
- data/lib/lutaml/uml/primitive_type.rb +9 -4
- data/lib/lutaml/uml/property.rb +25 -15
- data/lib/lutaml/uml/pseudostate.rb +7 -6
- data/lib/lutaml/uml/realization.rb +7 -5
- data/lib/lutaml/uml/region.rb +7 -6
- data/lib/lutaml/uml/serializers/association.rb +58 -0
- data/lib/lutaml/uml/serializers/base.rb +16 -0
- data/lib/lutaml/uml/serializers/class.rb +29 -0
- data/lib/lutaml/uml/serializers/top_element_attribute.rb +14 -0
- data/lib/lutaml/uml/serializers/yaml_view.rb +18 -0
- data/lib/lutaml/uml/state.rb +8 -6
- data/lib/lutaml/uml/state_machine.rb +7 -5
- data/lib/lutaml/uml/top_element.rb +45 -35
- data/lib/lutaml/uml/top_element_attribute.rb +25 -0
- data/lib/lutaml/uml/transition.rb +8 -6
- data/lib/lutaml/uml/trigger.rb +8 -6
- data/lib/lutaml/uml/version.rb +3 -1
- data/lib/lutaml/uml/vertex.rb +7 -5
- data/lutaml-uml.gemspec +9 -2
- data/spec/fixtures/datamodel/models/AddressClassProfile.yml +90 -0
- data/spec/fixtures/datamodel/models/AddressComponentProfile.yml +63 -0
- data/spec/fixtures/datamodel/models/AddressComponentSpecification.yml +15 -0
- data/spec/fixtures/datamodel/models/AddressProfile.yml +36 -0
- data/spec/fixtures/datamodel/models/AttributeProfile.yml +32 -0
- data/spec/fixtures/datamodel/models/InterchangeAddressClassProfile.yml +79 -0
- data/spec/fixtures/datamodel/models/Localization copy.yml +23 -0
- data/spec/fixtures/datamodel/models/Localization.yml +23 -0
- data/spec/fixtures/datamodel/models/ProfileCompliantAddress.yml +36 -0
- data/spec/fixtures/datamodel/models/ProfileCompliantAddressComponent.yml +15 -0
- data/spec/fixtures/datamodel/models/Signature.yml +20 -0
- data/spec/fixtures/datamodel/models/SignatureBlankDefinition.yml +20 -0
- data/spec/fixtures/datamodel/models/TextDirectionCode copy.yml +16 -0
- data/spec/fixtures/datamodel/models/TextDirectionCode.yml +16 -0
- data/spec/fixtures/datamodel/models/Validity.yml +14 -0
- data/spec/fixtures/datamodel/models/iso19160-1/Address.yml +22 -0
- data/spec/fixtures/datamodel/models/iso19160-1/AddressComponent.yml +2 -0
- data/spec/fixtures/datamodel/style.uml.inc +37 -0
- data/spec/fixtures/datamodel/views/AddressClassProfile.yml +12 -0
- data/spec/fixtures/datamodel/views/AddressProfile.yml +3 -0
- data/spec/fixtures/datamodel/views/CommonModels.yml +9 -0
- data/spec/fixtures/datamodel/views/TopDown.yml +62 -0
- data/spec/fixtures/dsl/diagram.lutaml +3 -0
- data/spec/fixtures/dsl/diagram_attributes.lutaml +5 -0
- data/spec/fixtures/dsl/diagram_class_assocation.lutaml +29 -0
- data/spec/fixtures/dsl/diagram_class_fields.lutaml +19 -0
- data/spec/fixtures/dsl/diagram_comments.lutaml +28 -0
- data/spec/fixtures/dsl/diagram_concept_model.lutaml +132 -0
- data/spec/fixtures/dsl/diagram_data_types.lutaml +24 -0
- data/spec/fixtures/dsl/diagram_includes.lutaml +6 -0
- data/spec/fixtures/dsl/diagram_multiply_classes.lutaml +7 -0
- data/spec/fixtures/dsl/shared.lutaml +3 -0
- data/spec/fixtures/dsl/shared1.lutaml +4 -0
- data/spec/fixtures/generated_dot/AddressClassProfile.dot +170 -0
- data/spec/fixtures/generated_dot/AddressProfile.dot +34 -0
- data/spec/lutaml/uml/formatter/graphviz_spec.rb +41 -0
- data/spec/lutaml/uml/parsers/dsl_spec.rb +252 -0
- data/spec/lutaml/uml/parsers/yaml_spec.rb +18 -0
- data/spec/lutaml/uml/serializers/yaml_view_spec.rb +20 -0
- data/spec/lutaml/uml_spec.rb +2 -4
- data/spec/spec_helper.rb +11 -0
- 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,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[0..*]</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
|