Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Redor2018-05-14 10:57:14 +0000
committerLaurent Redor2018-05-14 15:20:02 +0000
commitdcbc85f08dd4c85ff97d528f116bb72a965ec750 (patch)
tree832220a98934acc7ed02461dd629ac5d6f993018
parent9a26f615995f991bd5acb2cf84ccc2ef74e3cf55 (diff)
downloadorg.eclipse.sirius-dcbc85f08dd4c85ff97d528f116bb72a965ec750.tar.gz
org.eclipse.sirius-dcbc85f08dd4c85ff97d528f116bb72a965ec750.tar.xz
org.eclipse.sirius-dcbc85f08dd4c85ff97d528f116bb72a965ec750.zip
[481386] Fix regression detected by a new test
The tests added in GoToMarkerTraceabilityWithUserInteractionTest for bug 534273 reveal a regression in the code of AbstractDDiagramConstraint modified to fix bug 481386. Indeed, if a semantic element is deleted, with the new code there is a RuntimeException when calling InterpreterRegistry.getInterpreter(EObject) on this semantic element. This case is now handled in getFailingRules(EObject), before initial commit for bug 481386, it was indirectly done in checkRulesFromActivatedViewpoints(EObject, DDiagram) by calling SessionManager.INSTANCE.getSession(EObject) and by checking if the session was null. Now with this commit, the eObject that are not contained in a resource are ignored from the validation. This commit also makes the tests from GoToMarkerTraceabilityWithUserInteractionTest more reliable. I noticed locally sometimes failure on testTraceabilityWithClosedSession. Bug: 481386 Change-Id: I68c7990ce1332a88dbec2c39c7e656f6c4922c54 Signed-off-by: Laurent Redor <laurent.redor@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/tools/api/validation/constraint/AbstractDDiagramConstraint.java31
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/GoToMarkerTraceabilityWithUserInteractionTest.java25
2 files changed, 36 insertions, 20 deletions
diff --git a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/tools/api/validation/constraint/AbstractDDiagramConstraint.java b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/tools/api/validation/constraint/AbstractDDiagramConstraint.java
index d21fd458d1..fa016f0045 100644
--- a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/tools/api/validation/constraint/AbstractDDiagramConstraint.java
+++ b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/tools/api/validation/constraint/AbstractDDiagramConstraint.java
@@ -118,22 +118,25 @@ public abstract class AbstractDDiagramConstraint extends AbstractModelConstraint
}
if (diagram != null) {
- /*
- * If some rules are manually activated, then we'll pick in these ones, otherwise we'll use all the rules.
- */
- Collection<Viewpoint> selectedVps = Session.of(objectToValidate).map(s -> s.getSelectedViewpoints(false)).orElseGet(() -> new ArrayList<Viewpoint>());
- if (diagram.getActivatedRules().size() > 0) {
- failingRules.addAll(getFailingRulesFromCollection(objectToValidate, diagram.getActivatedRules().iterator()));
- } else if (diagram.getDescription() != null) {
- final DiagramDescription desc = diagram.getDescription();
- final ValidationSet validationSet = desc.getValidationSet();
- if (validationSet != null) {
- failingRules.addAll(getFailingRulesFromCollection(objectToValidate, validationSet.getAllRules().iterator()));
+ // Do not run validation on DSemanticDecorator without semantic element or with deleted semantic element
+ if (((DSemanticDecorator) objectToValidate).getTarget() != null && ((DSemanticDecorator) objectToValidate).getTarget().eResource() != null) {
+ /*
+ * If some rules are manually activated, then we'll pick in these ones, otherwise we'll use all the
+ * rules.
+ */
+ Collection<Viewpoint> selectedVps = Session.of(objectToValidate).map(s -> s.getSelectedViewpoints(false)).orElseGet(() -> new ArrayList<Viewpoint>());
+ if (diagram.getActivatedRules().size() > 0) {
+ failingRules.addAll(getFailingRulesFromCollection(objectToValidate, diagram.getActivatedRules().iterator()));
+ } else if (diagram.getDescription() != null) {
+ final DiagramDescription desc = diagram.getDescription();
+ final ValidationSet validationSet = desc.getValidationSet();
+ if (validationSet != null) {
+ failingRules.addAll(getFailingRulesFromCollection(objectToValidate, validationSet.getAllRules().iterator()));
+ }
+ failingRules.addAll(getFailingRulesFromDiagramExtension(objectToValidate, desc, selectedVps));
}
-
- failingRules.addAll(getFailingRulesFromDiagramExtension(objectToValidate, desc, selectedVps));
+ failingRules.addAll(checkRulesFromActivatedViewpoints(objectToValidate, selectedVps));
}
- failingRules.addAll(checkRulesFromActivatedViewpoints(objectToValidate, selectedVps));
}
return failingRules;
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/GoToMarkerTraceabilityWithUserInteractionTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/GoToMarkerTraceabilityWithUserInteractionTest.java
index 4f316128d6..e56559798c 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/GoToMarkerTraceabilityWithUserInteractionTest.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/GoToMarkerTraceabilityWithUserInteractionTest.java
@@ -15,6 +15,8 @@ import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
@@ -33,6 +35,7 @@ import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITreeSelection;
import org.eclipse.sirius.business.api.session.Session;
+import org.eclipse.sirius.business.internal.session.danalysis.SaveSessionJob;
import org.eclipse.sirius.common.ui.tools.api.util.EclipseUIUtil;
import org.eclipse.sirius.diagram.DDiagram;
import org.eclipse.sirius.diagram.ui.part.SiriusDiagramEditor;
@@ -339,8 +342,20 @@ public class GoToMarkerTraceabilityWithUserInteractionTest extends AbstractScena
URI uri = URI.createURI("platform:/resource/DesignerTestProject/vp1038.ecore#//p3");
semanticElementForTraceability = ted.getResourceSet().getEObject(uri, true);
ted.getCommandStack().execute(RemoveCommand.create(ted, semanticElementForTraceability));
- localSession.getOpenedSession().save(new NullProgressMonitor());
- bot.waitUntil(new SessionSavedCondition(localSession.getOpenedSession()));
+ SWTBotUtils.waitAllUiEvents();
+ if (closeEditor) {
+ // The save will be done automatically as there is no opened editor.
+ try {
+ Job.getJobManager().join(SaveSessionJob.FAMILY, new NullProgressMonitor());
+ } catch (OperationCanceledException e) {
+ fail("Failure during the join on \"SaveSessionJob.FAMILY\": " + e.getMessage());
+ } catch (InterruptedException e) {
+ fail("Failure during the join on \"SaveSessionJob.FAMILY\": " + e.getMessage());
+ }
+ } else {
+ localSession.getOpenedSession().save(new NullProgressMonitor());
+ bot.waitUntil(new SessionSavedCondition(localSession.getOpenedSession()));
+ }
if (fromClosedSession) {
// Close session
@@ -413,11 +428,9 @@ public class GoToMarkerTraceabilityWithUserInteractionTest extends AbstractScena
public void testTraceabilityWhenGoToMarkerIsCalledOnAllOpenedEditors() {
setUpMarker(REPRESENTATION_EMPTY_DIAGRAM, "emptyDiagram", "platform:/resource/DesignerTestProject/vp1038.ecore#//p1/A");
- openRepresentation(localSession.getOpenedSession(), REPRESENTATION_EMPTY_DIAGRAM, "emptyDiagram2",
- DDiagram.class);
+ openRepresentation(localSession.getOpenedSession(), REPRESENTATION_EMPTY_DIAGRAM, "emptyDiagram2", DDiagram.class);
- openRepresentation(localSession.getOpenedSession(), REPRESENTATION_EMPTY_DIAGRAM, "emptyDiagram3",
- DDiagram.class);
+ openRepresentation(localSession.getOpenedSession(), REPRESENTATION_EMPTY_DIAGRAM, "emptyDiagram3", DDiagram.class);
callGoToMarkerOnAllOpenedEditors(traceMarker);

Back to the top