Skip to content

Commit 31d1280

Browse files
committed
ST6RI-919 Created test for crossFeature property derivation.
1 parent d422e10 commit 31d1280

1 file changed

Lines changed: 34 additions & 1 deletion

File tree

org.omg.sysml.interactive.tests/src/org/omg/sysml/interactive/tests/DerivedPropertyAndOperationTest.java

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*******************************************************************************
22
* 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.
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU Lesser General Public License as published by
@@ -24,6 +24,7 @@
2424
import static org.junit.Assert.assertArrayEquals;
2525
import static org.junit.Assert.assertEquals;
2626
import static org.junit.Assert.assertFalse;
27+
import static org.junit.Assert.assertNotNull;
2728
import static org.junit.Assert.assertNull;
2829
import static org.junit.Assert.assertTrue;
2930

@@ -36,6 +37,7 @@
3637
import org.omg.sysml.lang.sysml.ActionUsage;
3738
import org.omg.sysml.lang.sysml.AttributeUsage;
3839
import org.omg.sysml.lang.sysml.Comment;
40+
import org.omg.sysml.lang.sysml.ConnectionDefinition;
3941
import org.omg.sysml.lang.sysml.Definition;
4042
import org.omg.sysml.lang.sysml.Documentation;
4143
import org.omg.sysml.lang.sysml.Element;
@@ -351,4 +353,35 @@ public void testLocale() throws Exception {
351353
assertEquals("comment.locale", "en_US", comment.getLocale());
352354
assertEquals("doc.locale", "en_US", doc.getLocale());
353355
}
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+
}
354387
}

0 commit comments

Comments
 (0)