Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenoit Maggi2014-08-08 09:25:23 +0000
committerBenoit Maggi2014-08-08 14:32:36 +0000
commit3ac9b1501c10430c7ff6fcb341c3f0109aaea42b (patch)
treeef304d62fc97dbbfc92ccd00914e0a2760b4d272 /plugins/infra
parent76d2247dad1925c6c062b08d6d25c8231ffae15f (diff)
downloadorg.eclipse.papyrus-3ac9b1501c10430c7ff6fcb341c3f0109aaea42b.tar.gz
org.eclipse.papyrus-3ac9b1501c10430c7ff6fcb341c3f0109aaea42b.tar.xz
org.eclipse.papyrus-3ac9b1501c10430c7ff6fcb341c3f0109aaea42b.zip
Bug 441408 - [UmlRT] Add test for validations rules
- add a test for the isActiveEntity rule - add a getter to get the diagnostic from the command - change the source to a unique id for the BasicDiagnostic comming from status Change-Id: I1f09e1d01fa9944675ea6c0ee872e6aa1011418c Signed-off-by: Benoit Maggi <benoit.maggi@cea.fr>
Diffstat (limited to 'plugins/infra')
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/EValidatorAdapter.java36
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/AbstractValidateCommand.java7
2 files changed, 36 insertions, 7 deletions
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/EValidatorAdapter.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/EValidatorAdapter.java
index ffc8e2fa89a..04bcb5ebcf2 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/EValidatorAdapter.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/EValidatorAdapter.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM - Initial API and implementation
* Christian W. Damus (CEA) - Target EObject must be the diagnostic's first data element
- *
+ * Benoit Maggi (CEA LIST) - Add an unique id as source for diagnostic
*****************************************************************************/
@@ -29,7 +29,9 @@ import org.eclipse.emf.ecore.EDataType;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.validation.model.EvaluationMode;
import org.eclipse.emf.validation.model.IConstraintStatus;
+import org.eclipse.emf.validation.model.IModelConstraint;
import org.eclipse.emf.validation.service.IBatchValidator;
+import org.eclipse.emf.validation.service.IConstraintDescriptor;
import org.eclipse.emf.validation.service.ModelValidationService;
import org.eclipse.uml2.uml.util.UMLValidator;
@@ -181,16 +183,36 @@ public class EValidatorAdapter
}
} else if (status instanceof IConstraintStatus) {
IConstraintStatus constraintStatus = (IConstraintStatus) status;
- diagnostics.add(new BasicDiagnostic(
- status.getSeverity(),
- status.getPlugin(),
- status.getCode(),
- status.getMessage(),
- toArray(constraintStatus.getResultLocus(), constraintStatus.getTarget())));
+ diagnostics.add(createBasicDiagnostic(status, constraintStatus));
}
}
/**
+ * Create a basic diagnostic with an unique id as source
+ * @param status
+ * @param constraintStatus
+ * @return
+ */
+ protected BasicDiagnostic createBasicDiagnostic(IStatus status,
+ IConstraintStatus constraintStatus) {
+ String source = status.getPlugin();
+ IModelConstraint constraint = constraintStatus.getConstraint();
+ if (constraint != null){
+ IConstraintDescriptor descriptor = constraint.getDescriptor();
+ if (descriptor != null) {
+ source = descriptor.getId();
+ }
+ }
+
+ return new BasicDiagnostic(
+ status.getSeverity(),
+ source,
+ status.getCode(),
+ status.getMessage(),
+ toArray(constraintStatus.getResultLocus(), constraintStatus.getTarget()));
+ }
+
+ /**
* Converts a possibly unordered collection to a list that has a designated
* {@code first} element.
*
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/AbstractValidateCommand.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/AbstractValidateCommand.java
index 34df185abac..628dee777d1 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/AbstractValidateCommand.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/AbstractValidateCommand.java
@@ -109,6 +109,13 @@ abstract public class AbstractValidateCommand extends AbstractTransactionalComma
public void disableUIFeedback() {
this.showUIfeedback = false;
}
+
+ /**
+ * @return
+ */
+ public Diagnostic getDiagnostic() {
+ return diagnostic;
+ }
/**
* @return The resource on which markers should be applied.

Back to the top