|
1 | 1 | /******************************************************************************* |
2 | 2 | * SysML 2 Pilot Implementation |
3 | 3 | * Copyright (c) 2026 Obeo |
| 4 | + * Copyright (c) 2026 Model Driven Solutions, Inc. |
4 | 5 | * |
5 | 6 | * This program and the accompanying materials are made available under the |
6 | 7 | * terms of the Eclipse Public License 2.0 which is available at |
|
19 | 20 |
|
20 | 21 | import java.io.ByteArrayInputStream; |
21 | 22 | import java.io.ByteArrayOutputStream; |
22 | | -import java.nio.file.Path; |
23 | | -import java.util.Collections; |
24 | 23 | import java.util.List; |
25 | 24 | import java.util.Map; |
26 | 25 |
|
|
29 | 28 | import org.eclipse.emf.ecore.resource.Resource; |
30 | 29 | import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl; |
31 | 30 | import org.eclipse.xtext.EcoreUtil2; |
32 | | -import org.junit.After; |
33 | | -import org.junit.BeforeClass; |
34 | 31 | import org.junit.Test; |
35 | | -import org.omg.sysml.interactive.SysMLInteractive; |
36 | | -import org.omg.sysml.interactive.SysMLInteractiveResult; |
37 | 32 | import org.omg.sysml.lang.sysml.ConstructorExpression; |
38 | 33 | import org.omg.sysml.lang.sysml.Element; |
39 | 34 | import org.omg.sysml.lang.sysml.Expression; |
|
54 | 49 | import org.omg.sysml.xtext.postprocessing.SysMLParserPostProcessorFactory; |
55 | 50 |
|
56 | 51 | /** Tests the semantic contract of expression results across consultation and explicit transformation. */ |
57 | | -public class ExpressionResultConsultationTest { |
58 | | - |
59 | | - protected static SysMLInteractive interactive; |
60 | | - |
61 | | - /** Loads and resolves the standard library once for the textual scenarios. */ |
62 | | - @BeforeClass |
63 | | - public static void loadLibraries() { |
64 | | - interactive = SysMLInteractive.createInstance(); |
65 | | - interactive.setVerbose(false); |
66 | | - interactive.loadLibrary(Path.of(System.getProperty("libraryPath")).toAbsolutePath().toString()); |
67 | | - } |
68 | | - |
69 | | - /** Removes each test model while retaining the shared resolved libraries. */ |
70 | | - @After |
71 | | - public void removeModels() { |
72 | | - interactive.removeResource(); |
73 | | - } |
74 | | - |
75 | | - private Resource parse(String name, String text) throws Exception { |
76 | | - interactive.setResource(name); |
77 | | - interactive.parse(text); |
78 | | - Element rootElement = interactive.getRootElement(); |
79 | | - SysMLInteractiveResult result = new SysMLInteractiveResult(rootElement, Collections.emptyList()); |
80 | | - assertTrue("'" + text + "':\n" + result.formatIssues(), result.getIssues().isEmpty()); |
81 | | - return interactive.getResource(); |
82 | | - } |
83 | | - |
84 | | - private static <T extends Type> T findByName(Resource resource, String name, Class<T> kind) { |
85 | | - for (var contents = resource.getAllContents(); contents.hasNext();) { |
86 | | - var object = contents.next(); |
87 | | - if (kind.isInstance(object) && name.equals(kind.cast(object).getDeclaredName())) { |
88 | | - return kind.cast(object); |
89 | | - } |
90 | | - } |
91 | | - throw new AssertionError("Missing " + name); |
92 | | - } |
| 52 | +public class ExpressionResultConsultationTest extends SysMLInteractiveTest { |
93 | 53 |
|
94 | 54 | private static <T> T findSingle(Resource resource, Class<T> kind) { |
95 | 55 | T found = null; |
|
0 commit comments