Skip to content
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
- https://github.com/eclipse-syson/syson/issues/1581[#1581] [diagrams] Remove rename and delete tools from inherited port palette.
- https://github.com/eclipse-syson/syson/issues/1611[#1611] [services] Fix an issue where the undo of the deletion of a graphical node in a diagram was not restoring the graphical node correctly.
- https://github.com/eclipse-syson/syson/issues/1618[#1618] [rest-apis] Fix an issue where the _eAnnotations_ reference coming from the Ecore metamodel was taking into account by REST APIs serialization.
- https://github.com/eclipse-syson/syson/issues/1621[#1621] [diagrams] Fix an issue where the creation of a _Package_ inside another _Package_ created the _Package_ at the root of the diagram in addition to the inside of the target _Package_.

=== Improvements

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class GVPackageTests extends AbstractIntegrationTests {

private static final String PACKAGE = "Package";

@Autowired
private IGivenInitialServerState givenInitialServerState;

Expand Down Expand Up @@ -113,37 +115,35 @@ public void testCreateSubPartInPackage() {
Consumer<Object> initialDiagramContentConsumer = assertRefreshedDiagramThat(diag -> {
diagramId.set(diag.getId());

var packageNode = new DiagramNavigator(diag).nodeWithLabel("Package").getNode();
var packageNode = new DiagramNavigator(diag).nodeWithLabel(PACKAGE).getNode();
packageNodeId.set(packageNode.getId());

assertThat(packageNode.getChildNodes()).hasSize(0);

assertThat(new DiagramNavigator(diag).findDiagramEdgeCount()).isEqualTo(3);

});

Runnable newPartUsageTool = () -> this.toolTester.invokeTool(GeneralViewWithTopNodesTestProjectData.EDITING_CONTEXT_ID, diagramId.get(), packageNodeId.get(), newPartToolId,
List.of());

Consumer<Object> updatedDiagramContentConsumerAfterNewPart = assertRefreshedDiagramThat(diag -> {
var packageNode = new DiagramNavigator(diag).nodeWithLabel("Package").getNode();
var packageNode = new DiagramNavigator(diag).nodeWithLabel(PACKAGE).getNode();

var partNode = new DiagramNavigator(diag).nodeWithLabel("Package").childNodeWithLabel(LabelConstants.OPEN_QUOTE + "part" + LabelConstants.CLOSE_QUOTE + LabelConstants.CR + "part1")
var partNode = new DiagramNavigator(diag).nodeWithLabel(PACKAGE).childNodeWithLabel(LabelConstants.OPEN_QUOTE + "part" + LabelConstants.CLOSE_QUOTE + LabelConstants.CR + "part1")
.getNode();
partNodeId.set(partNode.getId());

assertThat(packageNode.getChildNodes()).hasSize(1);
assertThat(packageNode.getChildNodes().get(0)).isEqualTo(partNode);

assertThat(new DiagramNavigator(diag).findDiagramEdgeCount()).isEqualTo(3);

});

Runnable newSubPartUsageTool = () -> this.toolTester.invokeTool(GeneralViewWithTopNodesTestProjectData.EDITING_CONTEXT_ID, diagramId.get(), partNodeId.get(), newSubPartToolId,
List.of());

Consumer<Object> updatedDiagramContentConsumerAfterNewSubPart = assertRefreshedDiagramThat(diag -> {
var packageNode = new DiagramNavigator(diag).nodeWithLabel("Package").getNode();
var packageNode = new DiagramNavigator(diag).nodeWithLabel(PACKAGE).getNode();

assertThat(packageNode.getChildNodes()).hasSize(2);

Expand All @@ -160,4 +160,55 @@ public void testCreateSubPartInPackage() {
.thenCancel()
.verify(Duration.ofSeconds(10));
}

@DisplayName("GIVEN a diagram with a Package node, WHEN a sub-Package node is created, THEN the sub-Package node is only visible inside the Package")
@Sql(scripts = { GeneralViewWithTopNodesTestProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD,
config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED))
@Sql(scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED))
@Test
public void testCreatePackageInPackage() {
var flux = this.givenSubscriptionToDiagram();

var diagramDescription = this.givenDiagramDescription.getDiagramDescription(GeneralViewWithTopNodesTestProjectData.EDITING_CONTEXT_ID,
SysONRepresentationDescriptionIdentifiers.GENERAL_VIEW_DIAGRAM_DESCRIPTION_ID);
var diagramDescriptionIdProvider = new DiagramDescriptionIdProvider(diagramDescription, this.diagramIdProvider);

var newPackageToolId = diagramDescriptionIdProvider.getNodeCreationToolId(this.descriptionNameGenerator.getNodeName(SysmlPackage.eINSTANCE.getPackage()), "New Package");
assertThat(newPackageToolId).as("The tool 'New Package' should exist on the Package").isNotNull();

var diagramId = new AtomicReference<String>();
var packageNodeId = new AtomicReference<String>();

Consumer<Object> initialDiagramContentConsumer = assertRefreshedDiagramThat(diag -> {
diagramId.set(diag.getId());

var packageNode = new DiagramNavigator(diag).nodeWithLabel(PACKAGE).getNode();
packageNodeId.set(packageNode.getId());

assertThat(packageNode.getChildNodes()).hasSize(0);

assertThat(new DiagramNavigator(diag).findDiagramEdgeCount()).isEqualTo(3);
});

Runnable newPackageTool = () -> this.toolTester.invokeTool(GeneralViewWithTopNodesTestProjectData.EDITING_CONTEXT_ID, diagramId.get(), packageNodeId.get(), newPackageToolId,
List.of());

Consumer<Object> updatedDiagramContentConsumerAfterNewPart = assertRefreshedDiagramThat(diag -> {
var packageNode = new DiagramNavigator(diag).nodeWithLabel(PACKAGE).getNode();

var subPackageNode = new DiagramNavigator(diag).nodeWithLabel(PACKAGE).childNodeWithLabel("Package1").getNode();

assertThat(packageNode.getChildNodes()).hasSize(1);
assertThat(packageNode.getChildNodes().get(0)).isEqualTo(subPackageNode);

assertThat(new DiagramNavigator(diag).findDiagramEdgeCount()).isEqualTo(3);
});

StepVerifier.create(flux)
.consumeNextWith(initialDiagramContentConsumer)
.then(newPackageTool)
.consumeNextWith(updatedDiagramContentConsumerAfterNewPart)
.thenCancel()
.verify(Duration.ofSeconds(10));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ public Boolean caseDocumentation(Documentation object) {
return owner instanceof Package || owner instanceof NamespaceImport || owner instanceof ViewUsage;
}

@Override
public Boolean casePackage(Package object) {
// For PAckages we don't want nested Nodes, no matter the type of ViewDefinition.
return !this.isIndirectNestedNode(object) && !ViewDefinitionKind.isActionFlowView(this.kind) && !ViewDefinitionKind.isStateTransitionView(this.kind);
}

@Override
public Boolean casePortUsage(PortUsage object) {
// For PortUsages we don't want nested Nodes, no matter the type of ViewDefinition.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ requirement <'SN'> {

- Fix an issue where the undo of the deletion of a graphical node in a diagram was not restoring the graphical node correctly.
- Fix an issue where the _eAnnotations_ reference coming from the Ecore metamodel was taking into account by REST APIs serialization.
- In diagrams, fix an issue where the creation of a _Package_ inside another _Package_ created the _Package_ at the root of the diagram in addition to the inside of the target _Package_.

== Improvements

Expand Down