Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » @Check validations not being executed
@Check validations not being executed [message #1007899] Fri, 08 February 2013 03:00 Go to next message
Aleks Mising name is currently offline Aleks Mising nameFriend
Messages: 8
Registered: November 2010
Junior Member
Hi all,

I've recently run into a problem that I am struggling to figure out.

I will try and keep this as short and as clear as possible, so here goes:

I have an Xtext model in which I describe an object, say Application:

Application:
	'application' name=ID '{'
		('description' description=STRING ';')?
                'applicant' 'id' applicantId=STRING ';'
		('applicant' applicant=[Applicant|FQN] ';')?
	'}'
;


At the moment Applicant is very simple, just a single element with a description field.
Now I also have a validation configured that checks that my application either has a value for the application id OR a valid reference to an applicant. Neither of these two are mandatory, but at least one must be present.

So to simplify, the check looks like this:

@Check
public void checkAtLeastIdOrApplicantExist(Application application) {
    if (application.getApplicantId().isEmpty() || application.getApplicant() == null) {
             //create error;
      }
}


Now I've added some unit tests around this and I've found something that I don't quite understand and haven't found documented anywhere..

If I run a test with an application that refers to a null applicant and no application id everything is fine, I hit the breakpoint and a validation issue gets created.
BUT, if I run a test with an application that has no application id BUT it has a reference to an invalid, non-existing applicant, I get a 'dangling reference' issue but the actual check above never gets executed?! I would prefer to have both, but am only getting the dangling reference error....

Is this some feature (and is there a way to disable it) or is something else the issue?


Thanks for your help!

Re: @Check validations not being executed [message #1007978 is a reply to message #1007899] Fri, 08 February 2013 07:27 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Aleks,

do you use an imported EPackage or a generated pacakge? It seems that
your model is inconsistent. Do you have other checks defined? Do you
modfiy the model by accident somewhere in the validation? Without a
concrete sample model and some more code it's hard to guess what's going
wrong.

Regards,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 08.02.13 04:01, schrieb Aleks Mising name:
> Hi all,
>
> I've recently run into a problem that I am struggling to figure out.
> I will try and keep this as short and as clear as possible, so here goes:
> I have an Xtext model in which I describe an object, say Application:
>
>
> Application:
> 'application' name=ID '{'
> ('description' description=STRING ';')?
> 'applicant' 'id' applicantId=STRING ';'
> ('applicant' applicant=[Applicant|FQN] ';')?
> '}'
> ;
>
>
> At the moment Applicant is very simple, just a single element with a
> description field. Now I also have a validation configured that checks
> that my application either has a value for the application id OR a valid
> reference to an applicant. Neither of these two are mandatory, but at
> least one must be present.
>
> So to simplify, the check looks like this:
>
>
> @Check
> public void checkAtLeastIdOrApplicantExist(Application application) {
> if (application.getApplicantId().isEmpty() ||
> application.getApplicant() == null) {
> //create error;
> }
> }
>
>
> Now I've added some unit tests around this and I've found something that
> I don't quite understand and haven't found documented anywhere..
>
> If I run a test with an application that refers to a null applicant and
> no application id everything is fine, I hit the breakpoint and a
> validation issue gets created.
> BUT, if I run a test with an application that has no application id BUT
> it has a reference to an invalid, non-existing applicant, I get a
> 'dangling reference' issue but the actual check above never gets
> executed?! I would prefer to have both, but am only getting the dangling
> reference error....
>
> Is this some feature (and is there a way to disable it) or is something
> else the issue?
>
>
> Thanks for your help!
>
>
Re: @Check validations not being executed [message #1009550 is a reply to message #1007978] Fri, 15 February 2013 09:55 Go to previous message
Jos Warmer is currently offline Jos WarmerFriend
Messages: 114
Registered: October 2010
Senior Member
If you have a dangling reference, the parsing phase results in an error. As far as I know the validation phase is only triggered when the parsing ends without an error.

Jos
Previous Topic:Epackage Import Example - Domainmodel to SecretCompartment
Next Topic:No hovers in Fowler's State-Machine
Goto Forum:
  


Current Time: Thu Apr 25 00:59:44 GMT 2024

Powered by FUDForum. Page generated in 0.02914 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top