Skip to content

Commit

Permalink
[843] Implement export of AllocationDefinition and basic export of Al…
Browse files Browse the repository at this point in the history
…locationUsage

Bug: eclipse-syson#843
Signed-off-by: Étienne Bausson <[email protected]>
  • Loading branch information
ebausson-obeo committed Nov 8, 2024
1 parent bba895d commit 6464b4a
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -55,6 +57,8 @@ public class SysMLKeywordSwitch extends SysmlSwitch<String> {

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";
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 6464b4a

Please sign in to comment.