diff --git a/backend/application/syson-sysml-export/src/main/java/org/eclipse/syson/sysml/export/utils/SysMLKeywordSwitch.java b/backend/application/syson-sysml-export/src/main/java/org/eclipse/syson/sysml/export/utils/SysMLKeywordSwitch.java index 3f9a3114f..6707439d4 100644 --- a/backend/application/syson-sysml-export/src/main/java/org/eclipse/syson/sysml/export/utils/SysMLKeywordSwitch.java +++ b/backend/application/syson-sysml-export/src/main/java/org/eclipse/syson/sysml/export/utils/SysMLKeywordSwitch.java @@ -18,6 +18,8 @@ import org.eclipse.syson.sysml.ActionDefinition; import org.eclipse.syson.sysml.ActionUsage; import org.eclipse.syson.sysml.ActorMembership; +import org.eclipse.syson.sysml.AllocationDefinition; +import org.eclipse.syson.sysml.AllocationUsage; import org.eclipse.syson.sysml.AssertConstraintUsage; import org.eclipse.syson.sysml.AttributeDefinition; import org.eclipse.syson.sysml.AttributeUsage; @@ -55,6 +57,8 @@ public class SysMLKeywordSwitch extends SysmlSwitch { private static final String PART_KEYWORD = "part"; + private static final String ALLOCATION_KEYWORD = "allocation"; + private static final String PORT_KEYWORD = "port"; private static final String INTERFACE_KEYWORD = "interface"; @@ -168,6 +172,16 @@ public String casePartUsage(PartUsage object) { return PART_KEYWORD; } + @Override + public String caseAllocationDefinition(AllocationDefinition object) { + return ALLOCATION_KEYWORD; + } + + @Override + public String caseAllocationUsage(AllocationUsage object) { + return ALLOCATION_KEYWORD; + } + @Override public String caseReferenceUsage(ReferenceUsage object) { if (object.getOwningMembership() instanceof SubjectMembership) { diff --git a/backend/application/syson-sysml-export/src/test/java/org/eclipse/syson/sysml/export/SysMLElementSerializerTest.java b/backend/application/syson-sysml-export/src/test/java/org/eclipse/syson/sysml/export/SysMLElementSerializerTest.java index 3badbfa2f..7c6e3179d 100644 --- a/backend/application/syson-sysml-export/src/test/java/org/eclipse/syson/sysml/export/SysMLElementSerializerTest.java +++ b/backend/application/syson-sysml-export/src/test/java/org/eclipse/syson/sysml/export/SysMLElementSerializerTest.java @@ -21,6 +21,8 @@ import org.eclipse.syson.sysml.ActionDefinition; import org.eclipse.syson.sysml.ActionUsage; import org.eclipse.syson.sysml.ActorMembership; +import org.eclipse.syson.sysml.AllocationDefinition; +import org.eclipse.syson.sysml.AllocationUsage; import org.eclipse.syson.sysml.Annotation; import org.eclipse.syson.sysml.AttributeDefinition; import org.eclipse.syson.sysml.AttributeUsage; @@ -1256,6 +1258,38 @@ public void useCaseDefinition() { } + @DisplayName("AllocationDefinition") + @Test + public void allocationDefinition() { + AllocationDefinition allocationDefinition = this.builder.createWithName(AllocationDefinition.class, "ad_1"); + + this.assertTextualFormEquals("allocation def ad_1;", allocationDefinition); + } + + @DisplayName("AllocationDefinition containing a part") + @Test + public void allocationDefinitionWithContainedEnd() { + AllocationDefinition allocationDefinition = this.builder.createWithName(AllocationDefinition.class, "ad_1"); + this.builder.createInWithName(PartUsage.class, allocationDefinition, "part_1"); + + this.assertTextualFormEquals(""" + allocation def ad_1 { + ref part part_1; + }""", allocationDefinition); + } + + @DisplayName("AllocationUsage") + @Test + public void allocationUsage() { + AllocationUsage allocationDefinition = this.builder.createWithName(AllocationUsage.class, "au_1"); + this.builder.createInWithName(PartUsage.class, allocationDefinition, "part_1"); + + this.assertTextualFormEquals(""" + ref allocation au_1 { + ref part part_1; + }""", allocationDefinition); + } + @DisplayName("ActionUsage with simple succession with owned sub-actions") @Test public void actionUsageWithSuccessionSimple() {