|
| 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 | +} |
0 commit comments