Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.emf.eef.modelingbot/src/org/eclipse/emf/eef/modelingBot/swtbot/ComposedEEFBot.java')
-rwxr-xr-x[-rw-r--r--]plugins/org.eclipse.emf.eef.modelingbot/src/org/eclipse/emf/eef/modelingBot/swtbot/ComposedEEFBot.java187
1 files changed, 114 insertions, 73 deletions
diff --git a/plugins/org.eclipse.emf.eef.modelingbot/src/org/eclipse/emf/eef/modelingBot/swtbot/ComposedEEFBot.java b/plugins/org.eclipse.emf.eef.modelingbot/src/org/eclipse/emf/eef/modelingBot/swtbot/ComposedEEFBot.java
index 90b8cfa2c..8afee0a2d 100644..100755
--- a/plugins/org.eclipse.emf.eef.modelingbot/src/org/eclipse/emf/eef/modelingBot/swtbot/ComposedEEFBot.java
+++ b/plugins/org.eclipse.emf.eef.modelingbot/src/org/eclipse/emf/eef/modelingBot/swtbot/ComposedEEFBot.java
@@ -10,8 +10,8 @@
*******************************************************************************/
package org.eclipse.emf.eef.modelingBot.swtbot;
-import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.io.IOException;
import java.util.ArrayList;
@@ -47,20 +47,22 @@ import org.eclipse.emf.eef.runtime.impl.utils.EEFUtils;
* Composed eef bot : SWTEEFbot and BatchModeling bot.
*
* @author <a href="mailto:nathalie.lepine@obeo.fr">Nathalie Lepine</a>
- *
*/
public class ComposedEEFBot implements IModelingBot {
/**
* The ResourceSet where to operate.
*/
- protected EditingDomain editingDomain = new AdapterFactoryEditingDomain(EEFRuntimePlugin.getDefault().getAdapterFactory(), new BasicCommandStack());
+ protected EditingDomain editingDomain = new AdapterFactoryEditingDomain(EEFRuntimePlugin.getDefault()
+ .getAdapterFactory(), new BasicCommandStack());
+
/**
- * Composed eef interpreter
+ * Composed eef interpreter.
*/
private ComposedEEFInterpreter interpreter;
+
/**
- * Bots Collection
+ * Bots Collection.
*/
private Collection<IModelingBot> bots;
@@ -68,160 +70,192 @@ public class ComposedEEFBot implements IModelingBot {
super();
this.bots = bots;
editingDomain.getResourceSet().setURIConverter(new EEFURIConverter());
- List<IModelingBot> list = new ArrayList<IModelingBot>();
+ final List<IModelingBot> list = new ArrayList<IModelingBot>();
list.addAll(bots);
list.add(this);
interpreter = new ComposedEEFInterpreter(list, editingDomain);
}
-/**
- * {@inheritDoc)
+ /**
+ * {@inheritDoc}
+ *
* @see org.eclipse.emf.eef.modelingBot.IModelingBot#runModelingBot(java.lang.String)
*/
public void runModelingBot(String path) throws CoreException, IOException {
interpreter.runModelingBot(path);
}
-/**
- * {@inheritDoc)
+ /**
+ * {@inheritDoc}
+ *
* @see org.eclipse.emf.eef.modelingBot.IModelingBot#createProject(java.lang.String)
*/
public void createProject(String projectName) {
// do nothing
}
-/**
- * {@inheritDoc)
+ /**
+ * {@inheritDoc}
+ *
* @see org.eclipse.emf.eef.modelingBot.IModelingBot#openProject(java.lang.String)
*/
public void openProject(String projectName) {
// do nothing
}
-/**
- * {@inheritDoc)
+ /**
+ * {@inheritDoc}
+ *
* @see org.eclipse.emf.eef.modelingBot.IModelingBot#closeProject(java.lang.String)
*/
public void closeProject(String projectName) {
// do nothing
}
-/**
- * {@inheritDoc)
+ /**
+ * {@inheritDoc}
+ *
* @see org.eclipse.emf.eef.modelingBot.IModelingBot#removeProject(java.lang.String)
*/
public void removeProject(String projectName) {
// do nothing
}
-/**
- * {@inheritDoc)
+ /**
+ * {@inheritDoc}
+ *
* @see org.eclipse.emf.eef.modelingBot.IModelingBot#openPerspective(java.lang.String)
*/
public void openPerspective(String name) {
// do nothing
}
-/**
- * {@inheritDoc)
+ /**
+ * {@inheritDoc}
+ *
* @see org.eclipse.emf.eef.modelingBot.IModelingBot#openEEFEditor(java.lang.String)
*/
public void openEEFEditor(String path) {
// do nothing
}
-/**
- * {@inheritDoc)
+ /**
+ * {@inheritDoc}
+ *
* @see org.eclipse.emf.eef.modelingBot.IModelingBot#closeEditor(java.lang.String)
*/
public void closeEditor(String path) {
// do nothing
}
-/**
- * {@inheritDoc)
+ /**
+ * {@inheritDoc}
+ *
* @see org.eclipse.emf.eef.modelingBot.IModelingBot#save()
*/
public void save() {
// do nothing
}
-/**
- * {@inheritDoc)
- * @see org.eclipse.emf.eef.modelingBot.IModelingBot#add(org.eclipse.emf.eef.components.PropertiesEditionElement, org.eclipse.emf.eef.extended.editor.ReferenceableObject, org.eclipse.emf.ecore.EStructuralFeature, org.eclipse.emf.ecore.EClass)
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.eef.modelingBot.IModelingBot#add(org.eclipse.emf.eef.components.PropertiesEditionElement,
+ * org.eclipse.emf.eef.extended.editor.ReferenceableObject, org.eclipse.emf.ecore.EStructuralFeature,
+ * org.eclipse.emf.ecore.EClass)
*/
- public EObject add(PropertiesEditionElement propertiesEditionElement, ReferenceableObject referenceableObject, EStructuralFeature eContainingFeature, EClass type) {
+ public EObject add(PropertiesEditionElement propertiesEditionElement, ReferenceableObject referenceableObject,
+ EStructuralFeature eContainingFeature, EClass type) {
// do nothing
return null;
}
-/**
- * {@inheritDoc)
- * @see org.eclipse.emf.eef.modelingBot.IModelingBot#remove(org.eclipse.emf.eef.components.PropertiesEditionElement, org.eclipse.emf.eef.extended.editor.ReferenceableObject)
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.eef.modelingBot.IModelingBot#remove(org.eclipse.emf.eef.components.PropertiesEditionElement,
+ * org.eclipse.emf.eef.extended.editor.ReferenceableObject)
*/
public void remove(PropertiesEditionElement propertiesEditionElement, ReferenceableObject referenceableObject) {
// do nothing
}
-/**
- * {@inheritDoc)
- * @see org.eclipse.emf.eef.modelingBot.IModelingBot#set(org.eclipse.emf.eef.components.PropertiesEditionElement, org.eclipse.emf.eef.extended.editor.ReferenceableObject, org.eclipse.emf.ecore.EStructuralFeature, java.lang.String)
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.eef.modelingBot.IModelingBot#set(org.eclipse.emf.eef.components.PropertiesEditionElement,
+ * org.eclipse.emf.eef.extended.editor.ReferenceableObject, org.eclipse.emf.ecore.EStructuralFeature,
+ * java.lang.String)
*/
- public void set(PropertiesEditionElement propertiesEditionElement, ReferenceableObject referenceableObject, EStructuralFeature eContainingFeature, String value) {
+ public void set(PropertiesEditionElement propertiesEditionElement, ReferenceableObject referenceableObject,
+ EStructuralFeature eContainingFeature, String value) {
// do nothing
}
-/**
- * {@inheritDoc)
- * @see org.eclipse.emf.eef.modelingBot.IModelingBot#set(org.eclipse.emf.eef.components.PropertiesEditionElement, org.eclipse.emf.eef.extended.editor.ReferenceableObject, org.eclipse.emf.ecore.EStructuralFeature, org.eclipse.emf.eef.extended.editor.ReferenceableObject)
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.eef.modelingBot.IModelingBot#set(org.eclipse.emf.eef.components.PropertiesEditionElement,
+ * org.eclipse.emf.eef.extended.editor.ReferenceableObject, org.eclipse.emf.ecore.EStructuralFeature,
+ * org.eclipse.emf.eef.extended.editor.ReferenceableObject)
*/
- public void set(PropertiesEditionElement propertiesEditionElement, ReferenceableObject referenceableObject, EStructuralFeature eContainingFeature, ReferenceableObject value) {
+ public void set(PropertiesEditionElement propertiesEditionElement, ReferenceableObject referenceableObject,
+ EStructuralFeature eContainingFeature, ReferenceableObject value) {
// do nothing
}
-/**
- * {@inheritDoc)
- * @see org.eclipse.emf.eef.modelingBot.IModelingBot#unset(org.eclipse.emf.eef.components.PropertiesEditionElement, org.eclipse.emf.eef.extended.editor.ReferenceableObject, org.eclipse.emf.ecore.EStructuralFeature)
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.eef.modelingBot.IModelingBot#unset(org.eclipse.emf.eef.components.PropertiesEditionElement,
+ * org.eclipse.emf.eef.extended.editor.ReferenceableObject, org.eclipse.emf.ecore.EStructuralFeature)
*/
- public void unset(PropertiesEditionElement propertiesEditionElement, ReferenceableObject referenceableObject, EStructuralFeature eContainingFeature) {
+ public void unset(PropertiesEditionElement propertiesEditionElement, ReferenceableObject referenceableObject,
+ EStructuralFeature eContainingFeature) {
// do nothing
}
-/**
- * {@inheritDoc)
- * @see org.eclipse.emf.eef.modelingBot.IModelingBot#createModel(java.lang.String, java.lang.String, org.eclipse.emf.ecore.EClass)
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.eef.modelingBot.IModelingBot#createModel(java.lang.String, java.lang.String,
+ * org.eclipse.emf.ecore.EClass)
*/
public EObject createModel(String path, String modelName, EClass eClass) {
// do nothing
return null;
}
-/**
- * {@inheritDoc)
+ /**
+ * {@inheritDoc}
+ *
* @see org.eclipse.emf.eef.modelingBot.IModelingBot#cancel()
*/
public void cancel() {
// do nothing
}
-/**
- * {@inheritDoc)
+ /**
+ * {@inheritDoc}
+ *
* @see org.eclipse.emf.eef.modelingBot.IModelingBot#setSequenceType(org.eclipse.emf.eef.modelingBot.SequenceType)
*/
public void setSequenceType(SequenceType sequenceType) {
// do nothing
}
-/**
- * {@inheritDoc)
+ /**
+ * {@inheritDoc}
+ *
* @see org.eclipse.emf.eef.modelingBot.IModelingBot#validateBatchEditing()
*/
public void validateBatchEditing() {
// do nothing
}
-/**
- * {@inheritDoc)
+ /**
+ * {@inheritDoc}
+ *
* @see org.eclipse.emf.eef.modelingBot.IModelingBot#check()
*/
public void check() {
@@ -230,24 +264,27 @@ public class ComposedEEFBot implements IModelingBot {
}
for (int i = 0; i < bots.size(); i++) {
for (int j = i + 1; j < bots.size(); j++) {
- assertExpectedModelReached(((IModelingBot) bots.toArray()[i]).getActiveResource(), ((IModelingBot) bots.toArray()[j]).getActiveResource());
+ try {
+ assertExpectedModelReached(((IModelingBot)bots.toArray()[i]).getActiveResource(),
+ ((IModelingBot)bots.toArray()[j]).getActiveResource());
+ } catch (InterruptedException e) {
+ fail("Error during model comparison.");
+ }
}
}
}
- public void assertExpectedModelReached(Resource expectedModel, Resource batchModel) {
- try {
- Map<String, Object> options = new HashMap<String, Object>();
- options.put(org.eclipse.emf.compare.match.MatchOptions.OPTION_IGNORE_XMI_ID, Boolean.TRUE);
- MatchModel match = MatchService.doResourceMatch(batchModel, expectedModel, options);
- DiffModel diff = DiffService.doDiff(match);
- List<EObject> diffList = EEFUtils.asEObjectList(diff.eAllContents());
- List<EObject> result = filterAbnormalDiffElement(diffList);
- assertEquals("The active model isn't the same that the expected model", result.size(), 0);
- } catch (Exception e) {
- // How to do that ???
- assertTrue("Error during model comparison", false);
+ public void assertExpectedModelReached(Resource expectedModel, Resource batchModel) throws InterruptedException {
+ final Map<String, Object> options = new HashMap<String, Object>();
+ options.put(org.eclipse.emf.compare.match.MatchOptions.OPTION_IGNORE_XMI_ID, Boolean.TRUE);
+ final MatchModel match = MatchService.doResourceMatch(batchModel, expectedModel, options);
+ final DiffModel diff = DiffService.doDiff(match);
+ final List<EObject> diffList = EEFUtils.asEObjectList(diff.eAllContents());
+ final List<EObject> result = filterAbnormalDiffElement(diffList);
+ if (!result.isEmpty()) {
+ System.out.println(result);
}
+ assertTrue("The active model isn't the same that the expected model.", result.isEmpty());
}
/**
@@ -258,24 +295,28 @@ public class ComposedEEFBot implements IModelingBot {
* @return the list of "good" diff
*/
private List<EObject> filterAbnormalDiffElement(List<EObject> diffList) {
- List<EObject> result = new ArrayList<EObject>();
+ final List<EObject> result = new ArrayList<EObject>();
for (EObject object : diffList) {
- if (!(object instanceof DiffGroup) || (((DiffGroup) object).eContents().size() > 0))
+ if (!(object instanceof DiffGroup))
result.add(object);
+ else if (object.eContents().size() > 0)
+ result.addAll(filterAbnormalDiffElement(object.eContents()));
}
return result;
}
-/**
- * {@inheritDoc)
+ /**
+ * {@inheritDoc}
+ *
* @see org.eclipse.emf.eef.modelingBot.IModelingBot#getActiveResource()
*/
public Resource getActiveResource() {
return null;
}
-/**
- * {@inheritDoc)
+ /**
+ * {@inheritDoc}
+ *
* @see org.eclipse.emf.eef.modelingBot.IModelingBot#getModelingBotInterpreter()
*/
public IModelingBotInterpreter getModelingBotInterpreter() {

Back to the top