@Check validations not being executed [message #1007899] |
Fri, 08 February 2013 03:00 |
Aleks Mising name 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 |
Sebastian Zarnekow 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!
>
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.02914 seconds