forked from eclipse-capella/capella
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
eclipse-capella#2913 Add test validating fixes for AssociationCDBMigr…
…ation Addition of a test that validates that the migration passes and that the edge with same source and target is still displayed on the migrated diagram. Change-Id: I1bb8c8c685c01c294b8b2fee6ceec96bc4cc343d Signed-off-by: Steve Monnier <[email protected]>
- Loading branch information
1 parent
ef3222b
commit 7880dd7
Showing
8 changed files
with
405,694 additions
and
0 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
...sys.capella.test.migration.ju/model/ECM_Rapid_Implementation/ECM_Rapid_Implementation.afm
This file contains 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,4 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<metadata:Metadata xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:metadata="http://www.polarsys.org/kitalpha/ad/metadata/1.0.0" id="_V3WxwPw1EeyhYpyGVxOiXg"> | ||
<viewpointReferences id="_V36LYPw1EeyhYpyGVxOiXg" vpId="org.polarsys.capella.core.viewpoint" version="6.1.0"/> | ||
</metadata:Metadata> |
167,908 changes: 167,908 additions & 0 deletions
167,908
...ys.capella.test.migration.ju/model/ECM_Rapid_Implementation/ECM_Rapid_Implementation.aird
Large diffs are not rendered by default.
Oops, something went wrong.
34,867 changes: 34,867 additions & 0 deletions
34,867
...capella.test.migration.ju/model/ECM_Rapid_Implementation/ECM_Rapid_Implementation.capella
Large diffs are not rendered by default.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
....ju/model/ECM_Rapid_ImplementationNonRegression/ECM_Rapid_ImplementationNonRegression.afm
This file contains 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,4 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<metadata:Metadata xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:metadata="http://www.polarsys.org/kitalpha/ad/metadata/1.0.0" id="_V3WxwPw1EeyhYpyGVxOiXg"> | ||
<viewpointReferences id="_V36LYPw1EeyhYpyGVxOiXg" vpId="org.polarsys.capella.core.viewpoint" version="7.0.1"/> | ||
</metadata:Metadata> |
167,908 changes: 167,908 additions & 0 deletions
167,908
...ju/model/ECM_Rapid_ImplementationNonRegression/ECM_Rapid_ImplementationNonRegression.aird
Large diffs are not rendered by default.
Oops, something went wrong.
34,867 changes: 34,867 additions & 0 deletions
34,867
...model/ECM_Rapid_ImplementationNonRegression/ECM_Rapid_ImplementationNonRegression.capella
Large diffs are not rendered by default.
Oops, something went wrong.
134 changes: 134 additions & 0 deletions
134
...s/capella/test/migration/ju/testcases/basic/AssociationCDBMigrationNonRegressionTest.java
This file contains 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,134 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2025, THALES GLOBAL SERVICES. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Thales - initial API and implementation | ||
*******************************************************************************/ | ||
package org.polarsys.capella.test.migration.ju.testcases.basic; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collection; | ||
import java.util.LinkedList; | ||
import java.util.List; | ||
|
||
import org.eclipse.core.resources.IFile; | ||
import org.eclipse.core.resources.IProject; | ||
import org.eclipse.core.runtime.NullProgressMonitor; | ||
import org.eclipse.emf.common.util.URI; | ||
import org.eclipse.emf.diffmerge.api.scopes.IEditableModelScope; | ||
import org.eclipse.emf.diffmerge.diffdata.EAttributeValuePresence; | ||
import org.eclipse.emf.diffmerge.diffdata.impl.EComparisonImpl; | ||
import org.eclipse.emf.diffmerge.generic.api.Role; | ||
import org.eclipse.emf.diffmerge.generic.api.diff.IDifference; | ||
import org.eclipse.emf.diffmerge.impl.scopes.FragmentedModelScope; | ||
import org.eclipse.emf.ecore.EObject; | ||
import org.eclipse.emf.ecore.resource.Resource; | ||
import org.eclipse.emf.ecore.resource.ResourceSet; | ||
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; | ||
import org.polarsys.capella.core.compare.CapellaDiffPolicy; | ||
import org.polarsys.capella.core.compare.CapellaMatchPolicy; | ||
import org.polarsys.capella.core.compare.CapellaMergePolicy; | ||
import org.polarsys.capella.core.model.handler.command.CapellaResourceHelper; | ||
import org.polarsys.capella.test.framework.api.BasicTestCase; | ||
import org.polarsys.capella.test.framework.helpers.IResourceHelpers; | ||
import org.polarsys.capella.test.migration.ju.helpers.MigrationHelper; | ||
|
||
public class AssociationCDBMigrationNonRegressionTest extends BasicTestCase { | ||
|
||
private static final String SOURCE_MODELV6 = "ECM_Rapid_Implementation"; | ||
private static final String SOURCE_MODEL = "ECM_Rapid_Implementation"; | ||
|
||
private static final String TARGET_MIGRATED_MODEL = "ECM_Rapid_ImplementationNonRegression"; | ||
|
||
private static final String SOURCE_MODEL_RESOURCE = SOURCE_MODEL + "." | ||
+ CapellaResourceHelper.CAPELLA_MODEL_FILE_EXTENSION; | ||
private static final String TARGET_MIGRATED_MODEL_RESOURCE = TARGET_MIGRATED_MODEL + "." | ||
+ CapellaResourceHelper.CAPELLA_MODEL_FILE_EXTENSION;; | ||
|
||
private IProject sourceModelProjectV6; | ||
|
||
private IProject targetMigratedModelProject; | ||
|
||
private List<String> testModels = new LinkedList<String>(); | ||
|
||
@Override | ||
public List<String> getRequiredTestModels() { | ||
return testModels; | ||
} | ||
|
||
@Override | ||
protected void setUp() throws Exception { | ||
super.setUp(); | ||
|
||
sourceModelProjectV6 = IResourceHelpers.getEclipseProjectInWorkspace(SOURCE_MODELV6); | ||
targetMigratedModelProject = IResourceHelpers.getEclipseProjectInWorkspace(TARGET_MIGRATED_MODEL); | ||
testModels.addAll(Arrays.asList(SOURCE_MODELV6, TARGET_MIGRATED_MODEL)); | ||
} | ||
|
||
|
||
@Override | ||
protected void tearDown() throws Exception { | ||
testModels.clear(); | ||
super.tearDown(); | ||
} | ||
|
||
@Override | ||
public void test() throws Exception { | ||
|
||
if (sourceModelProjectV6.exists() && targetMigratedModelProject.exists()) { | ||
|
||
// migrate the project | ||
MigrationHelper.migrateProject(sourceModelProjectV6); | ||
|
||
Resource targetResource = getResourceToTest(targetMigratedModelProject, TARGET_MIGRATED_MODEL_RESOURCE); | ||
IEditableModelScope targetProjectScope = new FragmentedModelScope(targetResource, true); | ||
|
||
assessExpectedDifferences(sourceModelProjectV6, targetProjectScope); | ||
} | ||
|
||
} | ||
|
||
private void assessExpectedDifferences(IProject sourceModelProject, IEditableModelScope targetProjectScope) { | ||
Resource sourceResource = getResourceToTest(sourceModelProject, SOURCE_MODEL_RESOURCE); | ||
|
||
IEditableModelScope sourceProjectScope = new FragmentedModelScope(sourceResource, true); | ||
|
||
EComparisonImpl comparison = new EComparisonImpl(sourceProjectScope, targetProjectScope); | ||
|
||
// the order of elements for this particular feature is not relevant | ||
comparison.compute(new CapellaMatchPolicy(), new CapellaDiffPolicy() {}, new CapellaMergePolicy(), new NullProgressMonitor()); | ||
|
||
assertOnlyProjectNameDifference(comparison.getDifferences(Role.REFERENCE), TARGET_MIGRATED_MODEL); | ||
} | ||
|
||
/** | ||
* Asserts that the only difference lies in the projects name | ||
* | ||
* @param differences | ||
* the list of differences | ||
* @param projectName | ||
* the project name | ||
*/ | ||
public void assertOnlyProjectNameDifference(Collection<IDifference<EObject>> differences, String projectName) { | ||
assertEquals(1, differences.size()); | ||
|
||
IDifference<EObject> difference = differences.iterator().next(); | ||
assertTrue(difference instanceof EAttributeValuePresence); | ||
assertEquals(((EAttributeValuePresence) difference).getValue(), projectName); | ||
} | ||
|
||
private Resource getResourceToTest(IProject project, String fileName) { | ||
IFile file = project.getFile(fileName); | ||
URI fileURI = URI.createPlatformResourceURI(file.getFullPath().toString(), true); | ||
ResourceSet resourceSet = new ResourceSetImpl(); | ||
|
||
return resourceSet.getResource(fileURI, true); | ||
} | ||
|
||
} |
This file contains 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