Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre-Charles David2016-01-04 13:15:16 +0000
committerCedric Brun2016-01-05 09:48:51 +0000
commit3564cb840ceb83e35aa8a6ab9d31e8695dc0a6ef (patch)
treeca7314eaf9ddd456c77f40ebaf9886625a532722
parentb57d1f6f89e5888c8bd6afb5dcd0265ee68876db (diff)
downloadorg.eclipse.sirius-3564cb840ceb83e35aa8a6ab9d31e8695dc0a6ef.tar.gz
org.eclipse.sirius-3564cb840ceb83e35aa8a6ab9d31e8695dc0a6ef.tar.xz
org.eclipse.sirius-3564cb840ceb83e35aa8a6ab9d31e8695dc0a6ef.zip
[478878] Remove remaining usages of Query Legacy expressions in Java sources
Bug: 478878 Change-Id: I2e5160454d5c042563d18787a53cbfb6ed97987b Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.sample.interactions.design/src/org/eclipse/sirius/sample/interactions/services/InteractionOrderingServices.java3
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/RequestInterpreterTest.java4
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/table/ContextMenuTableTest.java2
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/table/ReadOnlyColumnTest.java2
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tree/ConditionalTreeItemStyleDescriptionTest.java2
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tree/ContextMenuTreeTest.java2
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tree/TreeItemStyleDescriptionTest.java2
-rw-r--r--plugins/org.eclipse.sirius.tests.tree/src/org/eclipse/sirius/tests/api/tools/TreeItemCreationToolsTest.java72
-rw-r--r--plugins/org.eclipse.sirius.tests.tree/src/org/eclipse/sirius/tests/api/tools/TreeItemDeletionToolsTest.java27
-rw-r--r--plugins/org.eclipse.sirius.tests.tree/src/org/eclipse/sirius/tests/api/tools/TreeItemRefreshTest.java31
-rw-r--r--plugins/org.eclipse.sirius.tests.tree/src/org/eclipse/sirius/tests/api/tools/TreeItemRefreshWithToolsTest.java86
-rw-r--r--plugins/org.eclipse.sirius.tests.tree/src/org/eclipse/sirius/tests/unit/tree/MappingBasedPartitionTests.java4
12 files changed, 117 insertions, 120 deletions
diff --git a/plugins/org.eclipse.sirius.sample.interactions.design/src/org/eclipse/sirius/sample/interactions/services/InteractionOrderingServices.java b/plugins/org.eclipse.sirius.sample.interactions.design/src/org/eclipse/sirius/sample/interactions/services/InteractionOrderingServices.java
index 60d271788e..aceccfeff6 100644
--- a/plugins/org.eclipse.sirius.sample.interactions.design/src/org/eclipse/sirius/sample/interactions/services/InteractionOrderingServices.java
+++ b/plugins/org.eclipse.sirius.sample.interactions.design/src/org/eclipse/sirius/sample/interactions/services/InteractionOrderingServices.java
@@ -111,7 +111,6 @@ public class InteractionOrderingServices {
}
public boolean eolPrecondition(Participant p) {
- // <%eContainer("Interaction").messages.filter("DestroyParticipantMessage").receivingEnd[context == current("Participant")]%>
Interaction i = (Interaction) new EObjectQuery(p).getFirstAncestorOfType(InteractionsPackage.Literals.INTERACTION).get();
for (Message msg : Iterables.filter(i.getMessages(), Predicates.instanceOf(DestroyParticipantMessage.class))) {
if (msg.getReceivingEnd() != null && msg.getReceivingEnd().getContext() == p) {
@@ -122,12 +121,10 @@ public class InteractionOrderingServices {
}
public boolean redimEolPrecondition(Participant p) {
- // <%eContainer("Interaction").messages.filter("DestroyParticipantMessage").receivingEnd[context == current("Participant")].nSize==0%>
return !eolPrecondition(p);
}
public Collection<EObject> lostMessageEndSemanticCandidates(Interaction i) {
- // <%messages[sendingEnd == null && receivingEnd != null || sendingEnd !=null && receivingEnd == null ]%>
Collection<EObject> result = Lists.newArrayList();
for (Message msg : i.getMessages()) {
if ((msg.getSendingEnd() == null && msg.getReceivingEnd() != null) || (msg.getSendingEnd() != null && msg.getReceivingEnd() == null)) {
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/RequestInterpreterTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/RequestInterpreterTest.java
index 00958d3e18..42857c4bfa 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/RequestInterpreterTest.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/RequestInterpreterTest.java
@@ -84,7 +84,7 @@ public class RequestInterpreterTest extends AbstractMMEcoreBasedScenarioTestCase
editor.click("EBigInteger");
final SWTBot requestsInterpreterBot = requestInterpreterView.bot();
- requestsInterpreterBot.text().setText("<%current.target%>");
+ requestsInterpreterBot.text().setText("feature:target");
final SWTBotTree requestInterpreterTree = bot.tree();
@@ -96,7 +96,7 @@ public class RequestInterpreterTest extends AbstractMMEcoreBasedScenarioTestCase
bot.button("OK").click();
- requestsInterpreterBot.text().setText("<%$EBigIntegerVar%>");
+ requestsInterpreterBot.text().setText("var:EBigIntegerVar");
requestsInterpreterBot.button("Set").click();
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/table/ContextMenuTableTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/table/ContextMenuTableTest.java
index 3d543481b6..c82a3d217f 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/table/ContextMenuTableTest.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/table/ContextMenuTableTest.java
@@ -194,7 +194,7 @@ public class ContextMenuTableTest extends AbstractSiriusSwtBotGefTestCase {
// Add change context
ChangeContext changeContext = ToolFactory.eINSTANCE.createChangeContext();
- changeContext.setBrowseExpression("<%$container%>");
+ changeContext.setBrowseExpression("var:container");
tool.setFirstModelOperation(changeContext);
// A complete tool is not needed : it must contains a model operation.
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/table/ReadOnlyColumnTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/table/ReadOnlyColumnTest.java
index e3f4b3042a..5781e54282 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/table/ReadOnlyColumnTest.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/table/ReadOnlyColumnTest.java
@@ -84,7 +84,7 @@ public class ReadOnlyColumnTest extends AbstractSiriusSwtBotGefTestCase {
pressKey(table.getTable(), SWT.SPACE);
// Check the values after: no change expected, the column through which
- // we tried to do the edition has canEdit = <%false%>
+ // we tried to do the edition has canEdit = false
assertEquals("newEReference1 : B0", items[0].cell(0));
assertEquals("false", items[0].cell(1));
assertEquals("false", items[0].cell(2));
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tree/ConditionalTreeItemStyleDescriptionTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tree/ConditionalTreeItemStyleDescriptionTest.java
index 3948b09cf7..03cc78d321 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tree/ConditionalTreeItemStyleDescriptionTest.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tree/ConditionalTreeItemStyleDescriptionTest.java
@@ -413,7 +413,7 @@ public class ConditionalTreeItemStyleDescriptionTest extends AbstractTreeSiriusS
// accesses to tab General
SWTBotSiriusHelper.selectPropertyTabItem(GENERAL);
- changeAndTestPropertyTabGeneral("<%name.length() > 13%>");
+ changeAndTestPropertyTabGeneral("aql:name.size() > 13");
SWTBotSiriusHelper.selectPropertyTabItem("All");
odesignEditor.bot().tree().setFocus();
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tree/ContextMenuTreeTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tree/ContextMenuTreeTest.java
index dcf227009f..99aa53a164 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tree/ContextMenuTreeTest.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tree/ContextMenuTreeTest.java
@@ -197,7 +197,7 @@ public class ContextMenuTreeTest extends AbstractSiriusSwtBotGefTestCase {
tool.setForceRefresh(true);
// Add change context operation
ChangeContext changeContext = (ChangeContext) tool.getFirstModelOperation();
- changeContext.setBrowseExpression("<%$container%>");
+ changeContext.setBrowseExpression("var:container");
changeContext.getSubModelOperations().add(ToolFactory.eINSTANCE.createCreateInstance());
// Add create instance operation
CreateInstance createInstance = (CreateInstance) changeContext.getSubModelOperations().get(0);
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tree/TreeItemStyleDescriptionTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tree/TreeItemStyleDescriptionTest.java
index 31b5cd8361..bf1c66edab 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tree/TreeItemStyleDescriptionTest.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tree/TreeItemStyleDescriptionTest.java
@@ -428,7 +428,7 @@ public class TreeItemStyleDescriptionTest extends AbstractTreeSiriusSWTBotGefTes
// accesses to tab Label
SWTBotSiriusHelper.selectPropertyTabItem(LABEL);
changeShowIcon();
- changeAndTestPropertyTabLabel(8, 12, "feature:name", "Test<%name%>", 0, 1);
+ changeAndTestPropertyTabLabel(8, 12, "feature:name", "aql:'Test' + self.name", 0, 1);
SWTBotUtils.waitAllUiEvents();
// Save odesign
saveViewpointSpecificationModel(VSM);
diff --git a/plugins/org.eclipse.sirius.tests.tree/src/org/eclipse/sirius/tests/api/tools/TreeItemCreationToolsTest.java b/plugins/org.eclipse.sirius.tests.tree/src/org/eclipse/sirius/tests/api/tools/TreeItemCreationToolsTest.java
index 44726a81b2..8c62d79c4a 100644
--- a/plugins/org.eclipse.sirius.tests.tree/src/org/eclipse/sirius/tests/api/tools/TreeItemCreationToolsTest.java
+++ b/plugins/org.eclipse.sirius.tests.tree/src/org/eclipse/sirius/tests/api/tools/TreeItemCreationToolsTest.java
@@ -14,10 +14,16 @@ import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.emf.common.util.TreeIterator;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.sirius.common.tools.api.interpreter.EvaluationException;
import org.eclipse.sirius.tests.support.api.TestsUtil;
+import org.eclipse.sirius.tests.support.api.TreeTestCase;
+import org.eclipse.sirius.tests.unit.common.TreeCommonTest;
+import org.eclipse.sirius.tests.unit.common.TreeEcoreModeler;
import org.eclipse.sirius.tree.DTree;
import org.eclipse.sirius.tree.DTreeElement;
import org.eclipse.sirius.tree.description.DescriptionFactory;
@@ -32,10 +38,6 @@ import org.eclipse.swt.widgets.Tree;
import org.eclipse.ui.IEditorPart;
import org.junit.Assert;
-import org.eclipse.sirius.tests.support.api.TreeTestCase;
-import org.eclipse.sirius.tests.unit.common.TreeCommonTest;
-import org.eclipse.sirius.tests.unit.common.TreeEcoreModeler;
-
/**
* Test Item Creation tool.
*
@@ -43,15 +45,10 @@ import org.eclipse.sirius.tests.unit.common.TreeEcoreModeler;
*/
public class TreeItemCreationToolsTest extends TreeCommonTest implements TreeEcoreModeler {
- private static final String REQUEST = "<%getRootContainer().eAllContents(\"EClass\")[name==\"NewEClassCreationTool\"].nSize()%>";
-
private TreeItemMapping treeItemMapping;
private AbstractDTreeEditor treeEditor;
- /**
- * {@inheritDoc}
- */
@Override
protected void setUp() throws Exception {
super.setUp();
@@ -59,6 +56,20 @@ public class TreeItemCreationToolsTest extends TreeCommonTest implements TreeEco
TestsUtil.synchronizationWithUIThread();
}
+ private int countNamedEClasses(EObject semanticModel) {
+ int count = 0;
+ String name = "NewEClassCreationTool";
+ EObject root = semanticModel.eResource().getContents().get(0);
+ TreeIterator<EObject> iter = root.eAllContents();
+ while (iter.hasNext()) {
+ EObject current = iter.next();
+ if (current instanceof EClass && name.equals(((EClass) current).getName())) {
+ count += 1;
+ }
+ }
+ return count;
+ }
+
/**
* Test add a new tree item creation tool in the VSM.
*
@@ -167,15 +178,8 @@ public class TreeItemCreationToolsTest extends TreeCommonTest implements TreeEco
}
- /**
- * @param newTree
- * @param treeElement
- * @param tree
- * @throws EvaluationException
- */
private void testCreationOnMapping(DTree newTree, final DTreeElement treeElement, Tree tree) throws EvaluationException {
- int instanceCount;
- instanceCount = interpreter.evaluateInteger(semanticModel, REQUEST).intValue();
+ int instanceCount = countNamedEClasses(semanticModel);
// Check that there is the element that will be removed
Assert.assertEquals("Wrong count of element having the wanted value.", 0, instanceCount);
@@ -183,7 +187,7 @@ public class TreeItemCreationToolsTest extends TreeCommonTest implements TreeEco
// Creation element NewEClassCreationTool in tree.
applyCreationTool(newTree, treeElement.getTarget(), treeItemMapping.getCreate().get(0));
- instanceCount = interpreter.evaluateInteger(semanticModel, REQUEST).intValue();
+ instanceCount = countNamedEClasses(semanticModel);
// Check that the element are created.
Assert.assertEquals("Wrong count of elementhaving the wanted value.", 1, instanceCount);
@@ -232,10 +236,6 @@ public class TreeItemCreationToolsTest extends TreeCommonTest implements TreeEco
}
- /**
- * @param tree
- * @return
- */
private void testTreeContent(Tree tree, DTree newTree) {
String currentHtml = TreeUIHelper.toContentHTMl(tree);
Assert.assertEquals("The editor has not the good number element", TreeItemCreationToolsTest.getModelHtml(), currentHtml);
@@ -243,11 +243,6 @@ public class TreeItemCreationToolsTest extends TreeCommonTest implements TreeEco
Assert.assertEquals("We have 8 elements in ecore model, so we should have 8 elements in tree.", ELEMENTS_NUMBER_IN_TREE, newTree.getOwnedTreeItems().size());
}
- /**
- * @param newTree
- * @param tree
- * @throws EvaluationException
- */
private void testRedo(DTree newTree, Tree tree) throws EvaluationException {
String currentHtml;
int instanceCount;
@@ -256,7 +251,7 @@ public class TreeItemCreationToolsTest extends TreeCommonTest implements TreeEco
applyRedo();
applyRedo();
TestsUtil.synchronizationWithUIThread();
- instanceCount = interpreter.evaluateInteger(semanticModel, REQUEST).intValue();
+ instanceCount = countNamedEClasses(semanticModel);
// Check that the element are created
Assert.assertEquals("Wrong count of elementhaving the wanted value.", 1, instanceCount);
@@ -269,11 +264,6 @@ public class TreeItemCreationToolsTest extends TreeCommonTest implements TreeEco
Assert.assertEquals("The creation is not effetive in editor", TreeItemCreationToolsTest.getModelHtmlAfterCreate(), currentHtml);
}
- /**
- * @param newTree
- * @param tree
- * @throws EvaluationException
- */
private void testUndo(DTree newTree, Tree tree) throws EvaluationException {
String currentHtml;
int instanceCount;
@@ -286,7 +276,7 @@ public class TreeItemCreationToolsTest extends TreeCommonTest implements TreeEco
// Check that there is all elements in tree (9)
Assert.assertEquals("We have 9 elements in ecore model, so we should have 9 elements in tree.", ELEMENTS_NUMBER_IN_TREE, newTree.getOwnedTreeItems().size());
- instanceCount = interpreter.evaluateInteger(semanticModel, REQUEST).intValue();
+ instanceCount = countNamedEClasses(semanticModel);
// Check that there is the element Create was remove
Assert.assertEquals("Wrong count of element having the wanted value.", 0, instanceCount);
@@ -297,17 +287,10 @@ public class TreeItemCreationToolsTest extends TreeCommonTest implements TreeEco
Assert.assertTrue("The undo is not effetive visually", TreeItemCreationToolsTest.getModelHtml().length() == currentHtml.length());
}
- /**
- * @param treeDescription
- * @param newTree
- * @param tree
- * @param currentHtml
- * @param instanceCount
- */
private void testCreationToolOnRepresentation(final TreeDescription treeDescription, DTree newTree, Tree tree) throws EvaluationException {
int instanceCount = -1;
String currentHtml = TreeUIHelper.toContentHTMl(tree);
- instanceCount = interpreter.evaluateInteger(semanticModel, REQUEST).intValue();
+ instanceCount = countNamedEClasses(semanticModel);
// Check that there is the element that will be removed
Assert.assertEquals("Wrong count of element having the wanted value.", 0, instanceCount);
@@ -317,7 +300,7 @@ public class TreeItemCreationToolsTest extends TreeCommonTest implements TreeEco
applyCreationTool(newTree, newTree.getTarget(), treeDescription.getCreateTreeItem().get(0));
TestsUtil.synchronizationWithUIThread();
- instanceCount = interpreter.evaluateInteger(semanticModel, REQUEST).intValue();
+ instanceCount = countNamedEClasses(semanticModel);
// Check that the element are created.
Assert.assertEquals("Wrong count of elementhaving the wanted value.", 1, instanceCount);
@@ -394,9 +377,6 @@ public class TreeItemCreationToolsTest extends TreeCommonTest implements TreeEco
return TreeUIHelper.toHTML(expected);
}
- /**
- * {@inheritDoc}
- */
@Override
protected void tearDown() throws Exception {
DialectUIManager.INSTANCE.closeEditor(treeEditor, false);
diff --git a/plugins/org.eclipse.sirius.tests.tree/src/org/eclipse/sirius/tests/api/tools/TreeItemDeletionToolsTest.java b/plugins/org.eclipse.sirius.tests.tree/src/org/eclipse/sirius/tests/api/tools/TreeItemDeletionToolsTest.java
index d3dcb26909..0f41ccb11c 100644
--- a/plugins/org.eclipse.sirius.tests.tree/src/org/eclipse/sirius/tests/api/tools/TreeItemDeletionToolsTest.java
+++ b/plugins/org.eclipse.sirius.tests.tree/src/org/eclipse/sirius/tests/api/tools/TreeItemDeletionToolsTest.java
@@ -14,6 +14,9 @@ import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.emf.common.util.TreeIterator;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.sirius.tests.support.api.TestsUtil;
import org.eclipse.sirius.tests.support.api.TreeTestCase;
@@ -40,8 +43,6 @@ import org.junit.Assert;
*/
public class TreeItemDeletionToolsTest extends TreeCommonTest implements EcoreModeler, TreeEcoreModeler {
- private static final String REQUEST = "<%getRootContainer().eAllContents(\"EClass\")[name==\"EClass1\"].nSize()%>";
-
private AbstractDTreeEditor treeEditor;
@Override
@@ -50,6 +51,20 @@ public class TreeItemDeletionToolsTest extends TreeCommonTest implements EcoreMo
initViewpoint(DESIGN_VIEWPOINT_NAME);
TestsUtil.synchronizationWithUIThread();
}
+
+ private int countNamedEClasses(EObject semanticModel) {
+ int count = 0;
+ String name = "EClass1";
+ EObject root = semanticModel.eResource().getContents().get(0);
+ TreeIterator<EObject> iter = root.eAllContents();
+ while (iter.hasNext()) {
+ EObject current = iter.next();
+ if (current instanceof EClass && name.equals(((EClass) current).getName())) {
+ count += 1;
+ }
+ }
+ return count;
+ }
/**
* Test add a new tree item deletion tool in the VSM.
@@ -110,7 +125,7 @@ public class TreeItemDeletionToolsTest extends TreeCommonTest implements EcoreMo
// Check that there is all elements in tree (8)
Assert.assertEquals("We have 8 elements in ecore model, so we should have 9 elements in tree.", ELEMENTS_NUMBER_IN_TREE, newTree.getOwnedTreeItems().size());
- instanceCount = interpreter.evaluateInteger(semanticModel, REQUEST).intValue();
+ instanceCount = countNamedEClasses(semanticModel);
// Check that there is the element that will be removed
Assert.assertEquals("Wrong count of element having the wanted value.", 1, instanceCount);
@@ -119,7 +134,7 @@ public class TreeItemDeletionToolsTest extends TreeCommonTest implements EcoreMo
applyDeletionTool(treeElement);
TestsUtil.synchronizationWithUIThread();
- instanceCount = interpreter.evaluateInteger(semanticModel, REQUEST).intValue();
+ instanceCount = countNamedEClasses(semanticModel);
// Check that the element are removed
Assert.assertEquals("Wrong count of element having the wanted value.", 0, instanceCount);
@@ -138,7 +153,7 @@ public class TreeItemDeletionToolsTest extends TreeCommonTest implements EcoreMo
// Check that there is all elements in tree (8)
Assert.assertEquals("We have 8 elements in ecore model, so we should have 8 elements in tree.", ELEMENTS_NUMBER_IN_TREE, newTree.getOwnedTreeItems().size());
- instanceCount = interpreter.evaluateInteger(semanticModel, REQUEST).intValue();
+ instanceCount = countNamedEClasses(semanticModel);
// Check that there is the element removed was restored
Assert.assertEquals("Wrong count of element having the wanted value.", 1, instanceCount);
@@ -152,7 +167,7 @@ public class TreeItemDeletionToolsTest extends TreeCommonTest implements EcoreMo
applyRedo();
TestsUtil.synchronizationWithUIThread();
- instanceCount = interpreter.evaluateInteger(semanticModel, REQUEST).intValue();
+ instanceCount = countNamedEClasses(semanticModel);
// Check that the element are removed
Assert.assertEquals("Wrong count of element having the wanted value.", 0, instanceCount);
diff --git a/plugins/org.eclipse.sirius.tests.tree/src/org/eclipse/sirius/tests/api/tools/TreeItemRefreshTest.java b/plugins/org.eclipse.sirius.tests.tree/src/org/eclipse/sirius/tests/api/tools/TreeItemRefreshTest.java
index a726fbd0bc..30623b30ef 100644
--- a/plugins/org.eclipse.sirius.tests.tree/src/org/eclipse/sirius/tests/api/tools/TreeItemRefreshTest.java
+++ b/plugins/org.eclipse.sirius.tests.tree/src/org/eclipse/sirius/tests/api/tools/TreeItemRefreshTest.java
@@ -14,6 +14,9 @@ import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.emf.common.util.TreeIterator;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.sirius.tests.support.api.TestsUtil;
import org.eclipse.sirius.tools.api.command.SiriusCommand;
@@ -25,7 +28,6 @@ import org.eclipse.sirius.ui.business.api.dialect.DialectUIManager;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.ui.IEditorPart;
import org.junit.Assert;
-
import org.eclipse.sirius.tests.SiriusTestsPlugin;
import org.eclipse.sirius.tests.support.api.TreeTestCase;
@@ -56,9 +58,6 @@ public class TreeItemRefreshTest extends TreeTestCase {
private DTreeEditor treeEditor;
- /**
- * {@inheritDoc}
- */
@Override
protected void setUp() throws Exception {
super.setUp();
@@ -66,6 +65,19 @@ public class TreeItemRefreshTest extends TreeTestCase {
genericSetUp(SEMANTIC_MODEL_PATH, MODELER_PATH, SESSION_PATH);
}
+ private int countNamedEClasses(EObject semanticModel, String name) {
+ int count = 0;
+ EObject root = semanticModel.eResource().getContents().get(0);
+ TreeIterator<EObject> iter = root.eAllContents();
+ while (iter.hasNext()) {
+ EObject current = iter.next();
+ if (current instanceof EClass && name.equals(((EClass) current).getName())) {
+ count += 1;
+ }
+ }
+ return count;
+ }
+
/**
* Test the case where all element are the same name in the semantic model.
*
@@ -104,13 +116,13 @@ public class TreeItemRefreshTest extends TreeTestCase {
// Check that there is all elements in tree (13)
Assert.assertEquals("We have 13 elements in ecore model, so we should have 13 elements in tree.", ELEMENTS_NUMBER_IN_TREE, newTree.getOwnedTreeItems().size());
- instanceCount = interpreter.evaluateInteger(semanticModel, "<%getRootContainer().eAllContents(\"EClass\")[name==\"NewEClass\"].nSize()%>").intValue();
+ instanceCount = countNamedEClasses(semanticModel, "NewEClass");
Assert.assertEquals("Wrong count of element having the wanted value.", 4, instanceCount);
applyRefresh(newTree);
- instanceCount = interpreter.evaluateInteger(semanticModel, "<%getRootContainer().eAllContents(\"EClass\")[name==\"NewEClass\"].nSize()%>").intValue();
+ instanceCount = countNamedEClasses(semanticModel, "NewEClass");
Assert.assertEquals("Wrong count of elementhaving the wanted value.", 4, instanceCount);
// Check there is an element more
@@ -149,7 +161,7 @@ public class TreeItemRefreshTest extends TreeTestCase {
int instanceCount = -1;
- instanceCount = interpreter.evaluateInteger(semanticModel, "<%getRootContainer().eAllContents(\"EClass\")[name==\"EClass1\"].nSize()%>").intValue();
+ instanceCount = countNamedEClasses(semanticModel, "EClass1");
Assert.assertEquals("Wrong count of element having the wanted value.", 1, instanceCount);
@@ -164,7 +176,7 @@ public class TreeItemRefreshTest extends TreeTestCase {
});
- instanceCount = interpreter.evaluateInteger(semanticModel, "<%getRootContainer().eAllContents(\"EClass\")[name==\"EClass21\"].nSize()%>").intValue();
+ instanceCount = countNamedEClasses(semanticModel, "EClass21");
applyRefresh(newTree);
@@ -191,9 +203,6 @@ public class TreeItemRefreshTest extends TreeTestCase {
return TreeUIHelper.toHTML(expected);
}
- /**
- * {@inheritDoc}
- */
@Override
protected void tearDown() throws Exception {
DialectUIManager.INSTANCE.closeEditor(treeEditor, false);
diff --git a/plugins/org.eclipse.sirius.tests.tree/src/org/eclipse/sirius/tests/api/tools/TreeItemRefreshWithToolsTest.java b/plugins/org.eclipse.sirius.tests.tree/src/org/eclipse/sirius/tests/api/tools/TreeItemRefreshWithToolsTest.java
index c98f42a973..702345e30b 100644
--- a/plugins/org.eclipse.sirius.tests.tree/src/org/eclipse/sirius/tests/api/tools/TreeItemRefreshWithToolsTest.java
+++ b/plugins/org.eclipse.sirius.tests.tree/src/org/eclipse/sirius/tests/api/tools/TreeItemRefreshWithToolsTest.java
@@ -14,10 +14,13 @@ import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.sirius.common.tools.api.interpreter.EvaluationException;
+import org.eclipse.sirius.tests.SiriusTestsPlugin;
import org.eclipse.sirius.tests.support.api.TestsUtil;
+import org.eclipse.sirius.tests.support.api.TreeTestCase;
import org.eclipse.sirius.tree.DTree;
import org.eclipse.sirius.tree.DTreeElement;
import org.eclipse.sirius.tree.DTreeItem;
@@ -30,9 +33,6 @@ import org.eclipse.swt.widgets.Tree;
import org.eclipse.ui.IEditorPart;
import org.junit.Assert;
-import org.eclipse.sirius.tests.SiriusTestsPlugin;
-import org.eclipse.sirius.tests.support.api.TreeTestCase;
-
/**
* Test that the tool have effects within do a refresh. Test the deletion tools.
* Test an operation action that add new element Test the edit tool. Correspond
@@ -54,8 +54,6 @@ public class TreeItemRefreshWithToolsTest extends TreeTestCase {
private static final String SESSION_PATH = "/" + SiriusTestsPlugin.PLUGIN_ID + "/data/tree/unit/refreshtools/representations.aird";
- private static final String REQUEST = "<%getRootContainer().eAllContents(\"EClass\")[name==\"NewEClass1\"].nSize()%>";
-
private static final String REPRESENTATION_NAME = "tree";
private static Tree tree;
@@ -68,9 +66,7 @@ public class TreeItemRefreshWithToolsTest extends TreeTestCase {
private DTreeElement treeElement;
- /**
- * {@inheritDoc}
- */
+
@Override
protected void setUp() throws Exception {
super.setUp();
@@ -85,6 +81,19 @@ public class TreeItemRefreshWithToolsTest extends TreeTestCase {
treeEditor = (AbstractDTreeEditor) openedEditor;
tree = treeEditor.getTableViewer().getTreeViewer().getTree();
}
+
+ private int countNamedEClasses(EObject semanticModel, String name) {
+ int count = 0;
+ EObject root = semanticModel.eResource().getContents().get(0);
+ TreeIterator<EObject> iter = root.eAllContents();
+ while (iter.hasNext()) {
+ EObject current = iter.next();
+ if (current instanceof EClass && name.equals(((EClass) current).getName())) {
+ count += 1;
+ }
+ }
+ return count;
+ }
/**
* Test when using the default delete tool the element is deleted from
@@ -92,27 +101,22 @@ public class TreeItemRefreshWithToolsTest extends TreeTestCase {
*/
public void testDeleteFromTool() {
checkInitialization();
- try {
- // Deletion element NewEClass1 in tree.
- applyDeletionTool(treeElement);
- TestsUtil.synchronizationWithUIThread();
-
- // Counts number of NewEClass1
- int instanceCount = interpreter.evaluateInteger(semanticModel, REQUEST).intValue();
+ // Deletion element NewEClass1 in tree.
+ applyDeletionTool(treeElement);
+ TestsUtil.synchronizationWithUIThread();
- // Check that the element is removed
- Assert.assertEquals("Wrong count of element having the wanted value.", 0, instanceCount);
+ // Counts number of NewEClass1
+ int instanceCount = countNamedEClasses(semanticModel, "NewEClass1");
- // Check there is an element within
- int expected = ELEMENTS_NUMBER_IN_TREE - 1;
- Assert.assertEquals("We have " + expected + " elements in ecore model, so we should have " + expected + " elements in tree.", expected, dTree.getOwnedTreeItems().size());
+ // Check that the element is removed
+ Assert.assertEquals("Wrong count of element having the wanted value.", 0, instanceCount);
- // Check that the deletion is effective visually
- Assert.assertEquals("The delete is not effetive in editor", TreeItemRefreshWithToolsTest.getModelHtmlAfterDelete(), getCurrentHtml());
+ // Check there is an element within
+ int expected = ELEMENTS_NUMBER_IN_TREE - 1;
+ Assert.assertEquals("We have " + expected + " elements in ecore model, so we should have " + expected + " elements in tree.", expected, dTree.getOwnedTreeItems().size());
- } catch (EvaluationException e) {
- fail("Error in the request " + REQUEST);
- }
+ // Check that the deletion is effective visually
+ Assert.assertEquals("The delete is not effetive in editor", TreeItemRefreshWithToolsTest.getModelHtmlAfterDelete(), getCurrentHtml());
}
/**
@@ -167,27 +171,22 @@ public class TreeItemRefreshWithToolsTest extends TreeTestCase {
* Check that the test case correspond to what is expected.
*/
private void checkInitialization() {
- try {
- // Retrieve the visual result.
- String currentHtml = TreeUIHelper.toContentHTMl(tree);
+ // Retrieve the visual result.
+ String currentHtml = TreeUIHelper.toContentHTMl(tree);
- Assert.assertEquals("The editor has not the good number element", TreeItemRefreshWithToolsTest.getModelHtml(), currentHtml);
+ Assert.assertEquals("The editor has not the good number element", TreeItemRefreshWithToolsTest.getModelHtml(), currentHtml);
- Assert.assertNotNull("Unit test data is not correct", desc);
+ Assert.assertNotNull("Unit test data is not correct", desc);
- // Check that there is all elements in tree (3)
- Assert.assertEquals("We have " + ELEMENTS_NUMBER_IN_TREE + " elements in ecore model, so we should have " + ELEMENTS_NUMBER_IN_TREE + " elements in tree.", ELEMENTS_NUMBER_IN_TREE, dTree
- .getOwnedTreeItems().size());
+ // Check that there is all elements in tree (3)
+ Assert.assertEquals("We have " + ELEMENTS_NUMBER_IN_TREE + " elements in ecore model, so we should have " + ELEMENTS_NUMBER_IN_TREE + " elements in tree.", ELEMENTS_NUMBER_IN_TREE, dTree
+ .getOwnedTreeItems().size());
- // Counts number of NewEClass1
- int instanceCount = interpreter.evaluateInteger(semanticModel, REQUEST).intValue();
+ // Counts number of NewEClass1
+ int instanceCount = countNamedEClasses(semanticModel, "NewEClass1");
- // Check that there is the element NewEclass1
- Assert.assertEquals("Wrong count of element having the wanted value.", 1, instanceCount);
-
- } catch (EvaluationException e) {
- fail("Error in the request " + REQUEST);
- }
+ // Check that there is the element NewEclass1
+ Assert.assertEquals("Wrong count of element having the wanted value.", 1, instanceCount);
}
/**
@@ -251,9 +250,6 @@ public class TreeItemRefreshWithToolsTest extends TreeTestCase {
return TreeUIHelper.toHTML(expected);
}
- /**
- * {@inheritDoc}
- */
@Override
protected void tearDown() throws Exception {
DialectUIManager.INSTANCE.closeEditor(treeEditor, false);
diff --git a/plugins/org.eclipse.sirius.tests.tree/src/org/eclipse/sirius/tests/unit/tree/MappingBasedPartitionTests.java b/plugins/org.eclipse.sirius.tests.tree/src/org/eclipse/sirius/tests/unit/tree/MappingBasedPartitionTests.java
index f34cdf9a7f..eb59b9bbcb 100644
--- a/plugins/org.eclipse.sirius.tests.tree/src/org/eclipse/sirius/tests/unit/tree/MappingBasedPartitionTests.java
+++ b/plugins/org.eclipse.sirius.tests.tree/src/org/eclipse/sirius/tests/unit/tree/MappingBasedPartitionTests.java
@@ -53,7 +53,7 @@ public class MappingBasedPartitionTests {
@Test
public void orderIsKept() {
- MappingBasedPartition partition = new MappingBasedPartition(ctx, "EObject", Options.newSome("<%eClassifiers%>"), Options.<EObject> newNone());
+ MappingBasedPartition partition = new MappingBasedPartition(ctx, "EObject", Options.newSome("feature:eClassifiers"), Options.<EObject> newNone());
EPackage semanticModel = (EPackage) EcoreUtil.copy(EcorePackage.eINSTANCE);
Iterator<EObject> itTree = partition.evaluate(semanticModel, null).elements();
@@ -70,7 +70,7 @@ public class MappingBasedPartitionTests {
@Test
public void orderIsKeptWithTypeFiltering() {
- MappingBasedPartition partition = new MappingBasedPartition(ctx, "EClass", Options.newSome("<%eClassifiers%>"), Options.<EObject> newNone());
+ MappingBasedPartition partition = new MappingBasedPartition(ctx, "EClass", Options.newSome("feature:eClassifiers"), Options.<EObject> newNone());
EPackage semanticModel = (EPackage) EcoreUtil.copy(EcorePackage.eINSTANCE);
Iterator<EObject> itTree = partition.evaluate(semanticModel, null).elements();

Back to the top