Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@
import org.junit.Test;
import org.omg.sysml.lang.sysml.Element;
import org.omg.sysml.lang.sysml.ItemDefinition;
import org.omg.sysml.lang.sysml.OccurrenceDefinition;
import org.omg.sysml.lang.sysml.OccurrenceUsage;
import org.omg.sysml.lang.sysml.PortDefinition;
import org.omg.sysml.lang.sysml.PortUsage;
import org.omg.sysml.lang.sysml.PortionKind;
import org.omg.sysml.lang.sysml.StateUsage;
import org.omg.sysml.lang.sysml.SysMLFactory;
import org.omg.sysml.lang.sysml.SysMLPackage;
Expand Down Expand Up @@ -182,6 +184,58 @@ public void checkFeatureSubobjectSpecialization_PortUsage() {
assertTrue(String.format("OccurrenceUsage specializes subobjects instead of %s", getSpecifics(occurrence)), occurrence.specializes((Type)libraryElement));
}

@Test
public void checkOccurrenceUsageTimesliceSpecialization_OccurrenceUsage() {
//create and add root package
org.omg.sysml.lang.sysml.Package root = SysMLFactory.eINSTANCE.createPackage();
getResource().getContents().add(root);

//check if library element exists
Element libraryElement = SysMLLibraryUtil.getLibraryElement(root, "Occurrences::Occurrence::timeSlices");
assertTrue(libraryElement instanceof Type);

//create owning type
Type owner = (Type) SysMLFactory.eINSTANCE.createOccurrenceDefinition();
NamespaceUtil.addOwnedMemberTo(root, owner);

//create occurrence usage
OccurrenceUsage occurrence = SysMLFactory.eINSTANCE.createOccurrenceUsage();
occurrence.setIsReference(true);
occurrence.setPortionKind(PortionKind.TIMESLICE);
TypeUtil.addOwnedFeatureTo(owner, occurrence);

//run transformation, add implicit elements
ElementUtil.transformAll(root, true);

assertTrue(String.format("OccurrenceUsage specializes timeslices instead of %s", getSpecifics(occurrence)), occurrence.specializes((Type)libraryElement));
}

@Test
public void checkOccurrenceUsageTimesliceSpecialization_PortUsage() {
//create and add root package
org.omg.sysml.lang.sysml.Package root = SysMLFactory.eINSTANCE.createPackage();
getResource().getContents().add(root);

//check if library element exists
Element libraryElement = SysMLLibraryUtil.getLibraryElement(root, "Occurrences::Occurrence::timeSlices");
assertTrue(libraryElement instanceof Type);

//create owning type
Type owner = (Type) SysMLFactory.eINSTANCE.createPortDefinition();
NamespaceUtil.addOwnedMemberTo(root, owner);

//create port usage
PortUsage port = SysMLFactory.eINSTANCE.createPortUsage();
port.setIsReference(true);
port.setPortionKind(PortionKind.TIMESLICE);
TypeUtil.addOwnedFeatureTo(owner, port);

//run transformation, add implicit elements
ElementUtil.transformAll(root, true);

assertTrue(String.format("PortUsage specializes timeslices instead of %s", getSpecifics(port)), port.specializes((Type)libraryElement));
}

@Test
@Ignore("TBD")
public void checkUsageVariationUsageSpecialization() {
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.omg.sysml.lang.sysml.PortUsage;
import org.omg.sysml.lang.sysml.Type;

public class PortUsageAdapter extends UsageAdapter {
public class PortUsageAdapter extends OccurrenceUsageAdapter {

public PortUsageAdapter(PortUsage element) {
super(element);
Expand Down
Binary file not shown.
2 changes: 2 additions & 0 deletions sysml/src/examples/Simple Tests/PartTest.sysml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ package PartTest {
port x: ~C {
port p;
ref port q;
timeslice port x1;
}
timeslice part B1;
package P { }

succession flow x.p to a1.aa.receiver;
Expand Down
Loading