-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[2203] add Junit for Wrong CDO generation of derived features on non
Capella Elements - add condition on Eannotation derived and description Bug:2203 Change-Id: Ic709f24da0da41f4c95be419a719b16fbca411ae Signed-off-by: Joacquim Esabe <joacquim.esabe@laposte.net>
- Loading branch information
Joacquim Esabe
committed
Sep 27, 2018
1 parent
f542965
commit 75cb25b
Showing
2 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
...org/polarsys/capella/test/platform/ju/testcases/CapellaCDOGenerationOfDerivedFeature.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,73 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2018 THALES GLOBAL SERVICES. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Thales - initial API and implementation | ||
*******************************************************************************/ | ||
package org.polarsys.capella.test.platform.ju.testcases; | ||
|
||
import java.util.Set; | ||
import org.eclipse.emf.ecore.EClass; | ||
import org.eclipse.emf.ecore.EClassifier; | ||
import org.eclipse.emf.ecore.EObject; | ||
import org.eclipse.emf.ecore.EPackage; | ||
import org.eclipse.emf.ecore.EPackage.Registry; | ||
import org.eclipse.emf.ecore.EReference; | ||
import org.eclipse.emf.transaction.RecordingCommand; | ||
import org.eclipse.emf.transaction.TransactionalEditingDomain; | ||
import org.polarsys.capella.common.ef.ExecutionManager; | ||
import org.polarsys.capella.common.ef.ExecutionManagerRegistry; | ||
import org.polarsys.capella.common.model.helpers.IModelConstants; | ||
import org.polarsys.capella.core.model.handler.helpers.HoldingResourceHelper; | ||
import org.polarsys.capella.test.framework.api.BasicTestCase; | ||
import com.google.common.collect.Sets; | ||
|
||
/** | ||
* This class test the generating model EPackage for all Capella package, if catch exception | ||
* UnsupportedOperationException Assertion failed error is thrown | ||
*/ | ||
public class CapellaCDOGenerationOfDerivedFeature extends BasicTestCase { | ||
|
||
@Override | ||
public void test() throws Exception { | ||
|
||
Registry registry = EPackage.Registry.INSTANCE; | ||
Set<String> uris = Sets.newHashSet(registry.keySet()); | ||
for (String uri : uris) { | ||
EPackage ePackage = registry.getEPackage(uri); | ||
if (uri.contains("capella")) { | ||
for (EClassifier c : ePackage.getEClassifiers()) { | ||
if (c instanceof EClass) { | ||
EClass eclass = (EClass) c; | ||
if (!eclass.isAbstract()) { | ||
EObject object = eclass.getEPackage().getEFactoryInstance().create(eclass); | ||
ExecutionManager executionManager = ExecutionManagerRegistry.getInstance().addNewManager(); | ||
TransactionalEditingDomain domainTransaction = executionManager.getEditingDomain(); | ||
domainTransaction.getCommandStack().execute(new RecordingCommand(domainTransaction) { | ||
|
||
@Override | ||
protected void doExecute() { | ||
HoldingResourceHelper.getHoldingResource(domainTransaction).getContents().add(object); | ||
for (EReference reference : eclass.getEAllReferences()) { | ||
if (reference.isDerived() | ||
&& reference.getEAnnotation(IModelConstants.HELPER_ANNOTATION_SOURCE) != null) { | ||
try { | ||
object.eGet(reference); | ||
} catch (UnsupportedOperationException e) { | ||
assertTrue(e.getMessage(), false); | ||
} | ||
} | ||
} | ||
} | ||
}); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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