Skip to content

Commit 2c5dc83

Browse files
adaussyAxelRICHARD
authored andcommitted
[1028] Improve SuccessionAsUsage with implicit source
Bug: #1028 Signed-off-by: Arthur Daussy <arthur.daussy@obeo.fr>
1 parent f3a5785 commit 2c5dc83

File tree

10 files changed

+444
-78
lines changed

10 files changed

+444
-78
lines changed

CHANGELOG.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- https://github.com/eclipse-syson/syson/issues/1007[#1007] Improve direct edit on Feature elements to be able to set the `isDefault` and `isInitial` properties
1919
- https://github.com/eclipse-syson/syson/issues/1033[#1033] [explorer] Make it possible to create a diagram representation directly under a `root Namespace` element
2020
- https://github.com/eclipse-syson/syson/issues/960[#960] [general-view] In the selection dialog of the `subject` creation tool, display possible `Usage` candidates in a tree instead of a list.
21+
- https://github.com/eclipse-syson/syson/issues/1028[#1028] [import] Improve handling of `SuccessionAsUsage` with implicit source feature.
2122

2223
=== New features
2324

@@ -82,6 +83,7 @@ The changes are:
8283
- https://github.com/eclipse-syson/syson/issues/1018[#1018] [libraries] Make customizing the default metamodels and libraries available in SysML projects easier by making default implementation `SysONDefaultLibrariesConfiguration.java` more extensible.
8384
To do so, create a `@Primary @Configuration` component that extend `SysMLDefaultLibrariesConfiguration`, and optionally redefine `getDefaultLibraries()` method and/or `getDefaultEPackages()`.
8485

86+
8587
=== New features
8688

8789
- https://github.com/eclipse-syson/syson/issues/977[#977] [validation] SysON now implements the constraints (a.k.a. validation rules) from the SysMLv2 specification.

backend/application/syson-application/src/test/java/org/eclipse/syson/application/export/ImportExportTests.java

Lines changed: 60 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,64 @@ public void setUp() {
5555
this.checker = new SysmlImportExportChecker(this.sysmlLoader, this.editingDomainFactory, this.exporter, this.sysMLEditingContextProcessor);
5656
}
5757

58+
@Test
59+
@DisplayName("Given a SuccessionAsUsage with an implicit source feature, when importing and exporting the model, then the exported text file should be the same as the imported one.")
60+
public void checkSuccessionAsUsageImplicitSourceTest() throws IOException {
61+
var input = """
62+
action def ActionDef1 {
63+
action a0;
64+
action a1;
65+
action a2;
66+
then a1;
67+
then a0;
68+
}""";
69+
70+
this.checker.check(input, input);
71+
}
72+
73+
@Test
74+
@DisplayName("Given a SuccessionAsUsage with an implicit source feature targeting the 'start' standard library element, when importing and exporting the model, then the exported text file should be semantically equal.")
75+
public void checkSuccessionAsUsageImplicitSourceToStartTest() throws IOException {
76+
var input = """
77+
action def ActionDef1 {
78+
action a2;
79+
first start;
80+
then a2;
81+
}""";
82+
/**
83+
* Here we have differences here because :
84+
*
85+
* <ul>
86+
* <li>The strange construction of the Membership referencing 'start' is hard to detect so we chose to use the
87+
* complete syntax "first source then target;"</li>
88+
* <li>The current implementation of implicit specialization causes some issues during name de-resolution see
89+
* https://github.com/eclipse-syson/syson/issues/1029</li>
90+
* <ul>
91+
*/
92+
var expected = """
93+
action def ActionDef1 {
94+
action a2;
95+
first Actions::Action::start then a2;
96+
}""";
97+
98+
this.checker.check(input, expected);
99+
}
100+
101+
@Test
102+
@DisplayName("Given a SuccessionAsUsage with an explicit source feature, when importing and exporting the model, then the exported text file should be the same as the imported one.")
103+
public void checkSuccessionAsUsageExplicitSourceTest() throws IOException {
104+
var input = """
105+
action def ActionDef1 {
106+
action a0;
107+
action a1;
108+
action a2;
109+
first a0 then a1;
110+
first a1 then a2;
111+
}""";
112+
113+
this.checker.check(input, input);
114+
}
115+
58116
/**
59117
* Test import/export on test file UseCaseTest.sysml. The content of UseCaseTest.sysml that have been copied below
60118
* is under LGPL-3.0-only license. The LGPL-3.0-only license is accessible at the root of this repository, in the
@@ -142,16 +200,15 @@ public void checkUseCaseTest() throws IOException {
142200
}""";
143201

144202
this.checker.check(input, expected);
145-
146203
}
147204

148205
/**
149206
* Test import/export simple PortDef and PortUsage.
150207
*
151208
* @throws IOException
152209
*/
153-
@DisplayName("Given a model with PortDefinition and PortUsage, when importing and exporting the model, then the exported text file should be the same as the imported one.")
154210
@Test
211+
@DisplayName("Given a model with PortDefinition and PortUsage, when importing and exporting the model, then the exported text file should be the same as the imported one.")
155212
public void checkImportPort() throws IOException {
156213
var input = """
157214
port def Port1;
@@ -166,8 +223,8 @@ public void checkImportPort() throws IOException {
166223
*
167224
* @throws IOException
168225
*/
169-
@DisplayName("Given a model with AttributeUsages with default and initial value, when importing and exporting the model, then the exported text file should be the same as the imported one.")
170226
@Test
227+
@DisplayName("Given a model with AttributeUsages with default and initial value, when importing and exporting the model, then the exported text file should be the same as the imported one.")
171228
public void checkScalarValueAttribute() throws IOException {
172229
var input = """
173230
package Occurrences {
@@ -238,7 +295,6 @@ public void checkImportTest() throws IOException {
238295
}""";
239296

240297
this.checker.check(input, expected);
241-
242298
}
243299

244300
/**
@@ -344,7 +400,5 @@ public void checkOccurrenceTest() throws IOException {
344400
}""";
345401

346402
this.checker.check(input, expected);
347-
348403
}
349-
350404
}

0 commit comments

Comments
 (0)