|
1 | 1 | /******************************************************************************* |
2 | 2 | * SysML 2 Pilot Implementation |
3 | | - * Copyright (c) 2021-2022, 2025 Model Driven Solutions, Inc. |
| 3 | + * Copyright (c) 2021-2022, 2025, 2026 Model Driven Solutions, Inc. |
4 | 4 | * |
5 | 5 | * This program is free software: you can redistribute it and/or modify |
6 | 6 | * it under the terms of the GNU Lesser General Public License as published by |
|
24 | 24 | import static org.junit.Assert.assertArrayEquals; |
25 | 25 | import static org.junit.Assert.assertEquals; |
26 | 26 | import static org.junit.Assert.assertFalse; |
| 27 | +import static org.junit.Assert.assertNotNull; |
27 | 28 | import static org.junit.Assert.assertNull; |
28 | 29 | import static org.junit.Assert.assertTrue; |
29 | 30 |
|
|
36 | 37 | import org.omg.sysml.lang.sysml.ActionUsage; |
37 | 38 | import org.omg.sysml.lang.sysml.AttributeUsage; |
38 | 39 | import org.omg.sysml.lang.sysml.Comment; |
| 40 | +import org.omg.sysml.lang.sysml.ConnectionDefinition; |
39 | 41 | import org.omg.sysml.lang.sysml.Definition; |
40 | 42 | import org.omg.sysml.lang.sysml.Documentation; |
41 | 43 | import org.omg.sysml.lang.sysml.Element; |
@@ -351,4 +353,35 @@ public void testLocale() throws Exception { |
351 | 353 | assertEquals("comment.locale", "en_US", comment.getLocale()); |
352 | 354 | assertEquals("doc.locale", "en_US", doc.getLocale()); |
353 | 355 | } |
| 356 | + |
| 357 | + public final String crossFeatureTest = |
| 358 | + "package Test {" |
| 359 | + + " part def A {" |
| 360 | + + " ref b : B;" |
| 361 | + + " }" |
| 362 | + + " part def B;" |
| 363 | + + " connection def C {" |
| 364 | + + " end [0..1] ref end1 : A;" |
| 365 | + + " end ref end2 : B crosses end1.b;" |
| 366 | + + " }" |
| 367 | + + "}"; |
| 368 | + |
| 369 | + @Test |
| 370 | + public void testCrossFeature() throws Exception { |
| 371 | + SysMLInteractive instance = getSysMLInteractiveInstance(); |
| 372 | + SysMLInteractiveResult result = instance.process(crossFeatureTest); |
| 373 | + Element root = result.getRootElement(); |
| 374 | + Namespace test = (Namespace)((Namespace)root).getOwnedMember().get(0); |
| 375 | + Definition a = (Definition)test.getOwnedMember().get(0); |
| 376 | + Usage a_b = a.getOwnedUsage().get(0); |
| 377 | + ConnectionDefinition c = (ConnectionDefinition)test.getOwnedMember().get(2); |
| 378 | + List<Feature> ends = c.getAssociationEnd(); |
| 379 | + Usage end1 = (Usage)ends.get(0); |
| 380 | + Usage end2 = (Usage)ends.get(1); |
| 381 | + Feature ownedCrossFeature = end1.ownedCrossFeature(); |
| 382 | + |
| 383 | + assertNotNull("end1 owned cross feature", ownedCrossFeature); |
| 384 | + assertEquals("end1 cross feature", end1.ownedCrossFeature(), end1.getCrossFeature()); |
| 385 | + assertEquals("end2 cross feature", a_b, end2.getCrossFeature().getFeatureTarget()); |
| 386 | + } |
354 | 387 | } |
0 commit comments