-
Notifications
You must be signed in to change notification settings - Fork 67
[1838] Fix computation of Feature.getType #1845
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+336
−39
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
...test/java/org/eclipse/syson/metamodel/helper/ElementInitializerSwitchIntegrationTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| /******************************************************************************* | ||
| * Copyright (c) 2026 Obeo. | ||
| * This program and the accompanying materials | ||
| * are made available under the terms of the Eclipse Public License v2.0 | ||
| * which accompanies this distribution, and is available at | ||
| * https://www.eclipse.org/legal/epl-2.0/ | ||
| * | ||
| * SPDX-License-Identifier: EPL-2.0 | ||
| * | ||
| * Contributors: | ||
| * Obeo - initial API and implementation | ||
| *******************************************************************************/ | ||
| package org.eclipse.syson.metamodel.helper; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| import java.time.Duration; | ||
| import java.util.UUID; | ||
|
|
||
| import org.eclipse.sirius.components.collaborative.diagrams.dto.DiagramEventInput; | ||
| import org.eclipse.sirius.components.collaborative.diagrams.dto.DiagramRefreshedEventPayload; | ||
| import org.eclipse.sirius.components.core.api.IObjectSearchService; | ||
| import org.eclipse.sirius.web.tests.services.api.IGivenInitialServerState; | ||
| import org.eclipse.syson.AbstractIntegrationTests; | ||
| import org.eclipse.syson.application.controller.editingContext.checkers.ISemanticChecker; | ||
| import org.eclipse.syson.application.controller.editingContext.checkers.SemanticCheckerService; | ||
| import org.eclipse.syson.application.data.GeneralViewWithTopNodesTestProjectData; | ||
| import org.eclipse.syson.services.SemanticRunnableFactory; | ||
| import org.eclipse.syson.services.diagrams.api.IGivenDiagramSubscription; | ||
| import org.eclipse.syson.sysml.Package; | ||
| import org.eclipse.syson.sysml.SysmlFactory; | ||
| import org.eclipse.syson.sysml.ViewDefinition; | ||
| import org.eclipse.syson.sysml.ViewUsage; | ||
| import org.eclipse.syson.sysml.metamodel.services.ElementInitializerSwitch; | ||
| import org.eclipse.syson.sysml.metamodel.services.MetamodelMutationElementService; | ||
| import org.eclipse.syson.sysml.util.ElementUtil; | ||
| import org.junit.jupiter.api.AfterEach; | ||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.api.DisplayName; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.boot.test.context.SpringBootTest; | ||
| import org.springframework.test.context.jdbc.Sql; | ||
| import org.springframework.test.context.jdbc.SqlConfig; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| import reactor.test.StepVerifier; | ||
|
|
||
| /** | ||
| * Integration test for {@link org.eclipse.syson.sysml.metamodel.services.ElementInitializerSwitch}. Mostly used to test element initialization in a context where the standard libraries are required. | ||
| * | ||
| * @author Arthur Daussy | ||
| */ | ||
| @Transactional | ||
| @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) | ||
| public class ElementInitializerSwitchIntegrationTest extends AbstractIntegrationTests { | ||
|
|
||
| @Autowired | ||
| private IGivenInitialServerState givenInitialServerState; | ||
|
|
||
| @Autowired | ||
| private IGivenDiagramSubscription givenDiagramSubscription; | ||
|
|
||
| @Autowired | ||
| private IObjectSearchService objectSearchService; | ||
|
|
||
| @Autowired | ||
| private SemanticRunnableFactory semanticRunnableFactory; | ||
|
|
||
| private StepVerifier.Step<DiagramRefreshedEventPayload> verifier; | ||
|
|
||
| private SemanticCheckerService semanticCheckerService; | ||
|
|
||
| private ElementInitializerSwitch elementInitializerSwitch; | ||
|
|
||
| private ElementUtil elementUtil; | ||
|
|
||
AxelRICHARD marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| @BeforeEach | ||
| public void setUp() { | ||
| this.elementInitializerSwitch = new ElementInitializerSwitch(); | ||
| this.elementUtil = new ElementUtil(); | ||
| this.givenInitialServerState.initialize(); | ||
| var diagramEventInput = new DiagramEventInput(UUID.randomUUID(), | ||
| GeneralViewWithTopNodesTestProjectData.EDITING_CONTEXT_ID, | ||
| GeneralViewWithTopNodesTestProjectData.GraphicalIds.DIAGRAM_ID); | ||
| var flux = this.givenDiagramSubscription.subscribe(diagramEventInput); | ||
| this.verifier = StepVerifier.create(flux); | ||
| this.semanticCheckerService = new SemanticCheckerService(this.semanticRunnableFactory, this.objectSearchService, GeneralViewWithTopNodesTestProjectData.EDITING_CONTEXT_ID, | ||
| GeneralViewWithTopNodesTestProjectData.SemanticIds.PACKAGE_1_ID); | ||
| } | ||
|
|
||
| @AfterEach | ||
| public void tearDown() { | ||
| if (this.verifier != null) { | ||
| this.verifier.thenCancel() | ||
| .verify(Duration.ofSeconds(10)); | ||
| } | ||
| } | ||
|
|
||
| @DisplayName("GIVEN a ViewUsage, WHEN it is initialized, THEN it's typed by default with the GeneralView ViewDefinition") | ||
| @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 testViewUsageDefaultType() { | ||
| ISemanticChecker semanticChecker = (editingContext) -> { | ||
| Package semanticRootObject = (Package) this.objectSearchService.getObject(editingContext, GeneralViewWithTopNodesTestProjectData.SemanticIds.PACKAGE_1_ID).orElseThrow(); | ||
| var view1 = SysmlFactory.eINSTANCE.createViewUsage(); | ||
| new MetamodelMutationElementService().addChildInParent(semanticRootObject, view1); | ||
| var initializedView1 = this.elementInitializerSwitch.doSwitch(view1); | ||
| var generalViewViewDef = this.elementUtil.findByNameAndType(view1, "StandardViewDefinitions::GeneralView", ViewDefinition.class); | ||
| assertThat(((ViewUsage) initializedView1).getType()).contains(generalViewViewDef); | ||
| }; | ||
| this.semanticCheckerService.checkEditingContext(semanticChecker, this.verifier); | ||
| } | ||
|
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.