Skip to content

Commit b6674f5

Browse files
committed
Merge pull request #791 from Systems-Modeling/ST6RI-964
ST6RI-964 The operation Type.getOwnedDisjoining() always returns the empty list
2 parents 9e962f7 + 63afd14 commit b6674f5

4 files changed

Lines changed: 90 additions & 2 deletions

File tree

Binary file not shown.

org.omg.sysml.logic/src/main/java/org/omg/sysml/delegate/setting/Type_ownedDisjoining_SettingDelegate.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*******************************************************************************
22
* SysML 2 Pilot Implementation
33
* Copyright (c) 2022 Siemens AG
4-
* Copyright (c) 2022 Model Driven Solutions, Inc.
4+
* Copyright (c) 2022, 2026 Model Driven Solutions, Inc.
55
*
66
* This program is free software: you can redistribute it and/or modify
77
* it under the terms of the Eclipse Public License as published by
@@ -40,7 +40,7 @@ protected EList<?> basicGet(InternalEObject owner) {
4040
((Type)owner).getOwnedRelationship().stream().
4141
filter(Disjoining.class::isInstance).
4242
map(Disjoining.class::cast).
43-
filter(gen->gen.getTypeDisjoined() == this).
43+
filter(gen->gen.getTypeDisjoined() == owner).
4444
forEachOrdered(disjoinings::add);
4545
return disjoinings;
4646
}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/*******************************************************************************
2+
* SysML 2 Pilot Implementation
3+
* Copyright (c) 2026 Model Driven Solutions, Inc.
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU Lesser General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Lesser General Public License
16+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
*
18+
* @license LGPL-3.0-or-later <http://spdx.org/licenses/LGPL-3.0-or-later>
19+
*
20+
*******************************************************************************/
21+
22+
package org.omg.sysml.logic;
23+
24+
import static org.junit.Assert.assertEquals;
25+
import static org.junit.Assert.assertNotNull;
26+
27+
import java.util.List;
28+
29+
import org.junit.BeforeClass;
30+
import org.junit.Test;
31+
import org.omg.sysml.lang.sysml.Classifier;
32+
import org.omg.sysml.lang.sysml.Disjoining;
33+
import org.omg.sysml.lang.sysml.SysMLFactory;
34+
import org.omg.sysml.util.NamespaceUtil;
35+
36+
public class ST6RI_964_Type_getOwnedDisjoining_Test {
37+
38+
@BeforeClass
39+
public static void setUp() {
40+
SysMLLogicStandaloneSetup.doSetup();
41+
}
42+
43+
@Test
44+
public void testType_getOwnedDisjoining_size() {
45+
/*
46+
* package DisjoiningTest {
47+
* classifier A;
48+
* classifier B disjoint from A;
49+
* classifier C disjoint from A, B;
50+
* }
51+
*/
52+
53+
org.omg.sysml.lang.sysml.Package pkg = SysMLFactory.eINSTANCE.createPackage();
54+
pkg.setDeclaredName("DisjoiningTest");
55+
56+
Classifier A = SysMLFactory.eINSTANCE.createClassifier();
57+
A.setDeclaredName("A");
58+
NamespaceUtil.addOwnedMemberTo(pkg, A);
59+
60+
Classifier B = SysMLFactory.eINSTANCE.createClassifier();
61+
B.setDeclaredName("B");
62+
NamespaceUtil.addOwnedMemberTo(pkg, B);
63+
Disjoining D = SysMLFactory.eINSTANCE.createDisjoining();
64+
D.setDisjoiningType(A);
65+
D.setTypeDisjoined(B);
66+
B.getOwnedRelationship().add(D);
67+
68+
Classifier C = SysMLFactory.eINSTANCE.createClassifier();
69+
C.setDeclaredName("C");
70+
NamespaceUtil.addOwnedMemberTo(pkg, C);
71+
D = SysMLFactory.eINSTANCE.createDisjoining();
72+
D.setDisjoiningType(A);
73+
D.setTypeDisjoined(C);
74+
C.getOwnedRelationship().add(D);
75+
D = SysMLFactory.eINSTANCE.createDisjoining();
76+
D.setDisjoiningType(B);
77+
D.setTypeDisjoined(C);
78+
C.getOwnedRelationship().add(D);
79+
80+
List<Disjoining> B_ownedDisjoining = B.getOwnedDisjoining();
81+
assertNotNull("B.ownedDisjoining not null", B_ownedDisjoining);
82+
assertEquals("B.ownedDisjoining.size == 1", 1, B_ownedDisjoining.size());
83+
84+
List<Disjoining> C_ownedDisjoining = C.getOwnedDisjoining();
85+
assertNotNull("C.ownedDisjoining not null", C_ownedDisjoining);
86+
assertEquals("C.ownedDisjoining.size == 2", 2, C_ownedDisjoining.size());
87+
}
88+
}
Binary file not shown.

0 commit comments

Comments
 (0)