Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 312607 - Incorrect validation status returned from validator.
Summary: Incorrect validation status returned from validator.
Status: CLOSED WONTFIX
Alias: None
Product: EMF Services
Classification: Modeling
Component: Validation (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal
Target Milestone: ---   Edit
Assignee: EMF Services Validation inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-12 09:09 EDT by meri.web.accounts CLA
Modified: 2022-05-26 15:19 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description meri.web.accounts CLA 2010-05-12 09:09:17 EDT
If validators property reportSuccesses is set to false and no constraint returns failure status (e.g. model is OK with no errors), 
validation returns NO_CONSTRAINTS_EVALUATED error instead of ALL_CONSTRAINTS_PASSED error.

Code snippet:
	IBatchValidator validator = (IBatchValidator)ModelValidationService.getInstance().newValidator(EvaluationMode.BATCH);
	validator.setReportSuccesses(false);
	//all constraints are satisfied
	IStatus status = validator.validate( objects, monitor );
	System.out.println(status);

System output:
	Status OK: org.eclipse.emf.validation code=10 No constraints were evaluated. null

Workaround:
	Wrap returned status into own IStatus class:

class AroundValidationFrameworkBugStatus implements IStatus {
	
	private final IStatus status;

	public AroundValidationFrameworkBugStatus(IStatus status) {
		super();
		this.status = status;
	}

	public IStatus[] getChildren() {
		return status.getChildren();
	}

	//I could hard code constant or do this ...
	@SuppressWarnings("restriction")
	public int getCode() {
		int code = status.getCode();
		if (code==org.eclipse.emf.validation.internal.EMFModelValidationStatusCodes.NO_CONSTRAINTS_EVALUATED)
			return org.eclipse.emf.validation.internal.EMFModelValidationStatusCodes.ALL_CONSTRAINTS_PASSED;
		
		return code;
	}

	public Throwable getException() {
		return status.getException();
	}

	//I could hard code constant or do this ...
	@SuppressWarnings("restriction")
	public String getMessage() {
		if (org.eclipse.emf.validation.internal.EMFModelValidationStatusCodes.ALL_CONSTRAINTS_PASSED==getCode()) {
			return org.eclipse.emf.validation.internal.EMFModelValidationStatusCodes.ALL_CONSTRAINTS_PASSED_MSG;
		}
	
		return status.getMessage();
	}

	public String getPlugin() {
		return status.getPlugin();
	}

	public int getSeverity() {
		return status.getSeverity();
	}

	public boolean isMultiStatus() {
		return status.isMultiStatus();
	}

	public boolean isOK() {
		return status.isOK();
	}

	public boolean matches(int severityMask) {
		return status.matches(severityMask);
	}
	
	
}
Comment 1 Pierre-Charles David CLA 2022-05-14 09:53:29 EDT
Eclipse EMF Validation is moving away from this bugs.eclipse.org issue tracker to https://github.com/eclipse/emf-validation.

If this issue is relevant to you and still present in the latest release:

* Create a new issue at https://github.com/eclipse/emf-validation/issues/.
  * Use as title in GitHub the title of this Bugzilla ticket (may include the bug number or not, at your own convenience)
  * In the GitHub description, start with a link to this bugzilla ticket
  * Optionally add new content to the description if it can helps towards resolution
* Update bugzilla ticket
  * Add to "See also" property (up right column) the link to the newly created GitHub issue
  * Add a comment "Migrated to <link-to-newly-created-GitHub-issue>"
  * Set status as CLOSED MOVED

All issues that remain open will be automatically closed next week or so. Then the Bugzilla component for EMF Validation will be archived and made read-only.