Home » Modeling » OCL » OCL Validation outside of eclipse
| OCL Validation outside of eclipse [message #1102170] |
Thu, 05 September 2013 09:12  |
Jean-Baptiste Guillois Messages: 28 Registered: August 2011 |
Junior Member |
|
|
Hello,
I am trying to programmatically trigger OCL validation of my EMF model. Everything works well using the Eclipse environment (EMF model editor and instance viewer)
I use this code in my unit tests. After reading some posts in this forum, I added the following OCL initialization code in my setUp() method:
String oclDelegateURI = OCLDelegateDomain.OCL_DELEGATE_URI;
Operation.Internal.InvocationDelegate.Factory.Registry.INSTANCE.put(oclDelegateURI,
new OCLInvocationDelegateFactory.Global());
EStructuralFeature.Internal.SettingDelegate.Factory.Registry.INSTANCE.put(oclDelegateURI,
new OCLSettingDelegateFactory.Global());
EValidator.ValidationDelegate.Registry.INSTANCE.put(oclDelegateURI,
new OCLValidationDelegateFactory.Global());
Then, in my test method i use the following:
// Validate this domain
Diagnostic diag = Diagnostician.INSTANCE.validate(myDomain);
assertNotNull(diag.getChildren());
for (Diagnostic subDiag : diag.getChildren()) {
System.out.println(subDiag.getMessage());
}
I get the following validation diagnostics, which are both correct but the second one reveals that my OCL constraint has not been evaluated:
The feature 'environments' of 'com.xxx.root.impl.DomainImpl@35b57d0b{#//}' with 0 values must have at least 1 values
Unable to find delegate to evaluate the 'atLeastOneFlow' constraint on 'com.xxx.interaction.impl.InteractionTemplateImpl@27cb4b33{#///@interactionTemplates.0}': http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot
Any idea?
Many thanks for your help,
Best Regards,
-- Jean-Baptiste
PS: I am using org.eclipse.ocl-3.2.1, org.eclipse.ocl.ecore-3.2.0, org.eclipse.ocl.common-1.0.2
|
|
|
| Re: OCL Validation outside of eclipse [message #1102205 is a reply to message #1102170] |
Thu, 05 September 2013 10:03   |
Ed Willink Messages: 3446 Registered: July 2009 |
Senior Member |
|
|
Hi
You've only provided only half a problem; no repro.
So I can only provide a half a reply; no solution.
Regards
Ed Willink
On 05/09/2013 14:12, Missing name Mising name wrote:
> Hello,
>
> I am trying to programmatically trigger OCL validation of my EMF
> model. Everything works well using the Eclipse environment (EMF model
> editor and instance viewer)
>
> I use this code in my unit tests. After reading some posts in this
> forum, I added the following OCL initialization code in my setUp()
> method:
>
> String oclDelegateURI = OCLDelegateDomain.OCL_DELEGATE_URI;
>
> Operation.Internal.InvocationDelegate.Factory.Registry.INSTANCE.put(oclDelegateURI,
>
> new OCLInvocationDelegateFactory.Global());
>
> EStructuralFeature.Internal.SettingDelegate.Factory.Registry.INSTANCE.put(oclDelegateURI,
>
> new OCLSettingDelegateFactory.Global());
>
> EValidator.ValidationDelegate.Registry.INSTANCE.put(oclDelegateURI,
> new OCLValidationDelegateFactory.Global());
>
> Then, in my test method i use the following:
>
> // Validate this domain
> Diagnostic diag = Diagnostician.INSTANCE.validate(myDomain);
> assertNotNull(diag.getChildren());
>
> for (Diagnostic subDiag : diag.getChildren()) {
> System.out.println(subDiag.getMessage());
> }
>
>
> I get the following validation diagnostics, which are both correct but
> the second one reveals that my OCL constraint has not been evaluated:
> The feature 'environments' of
> 'com.xxx.root.impl.DomainImpl@35b57d0b{#//}' with 0 values must have
> at least 1 values
> Unable to find delegate to evaluate the 'atLeastOneFlow' constraint on
> 'com.xxx.interaction.impl.InteractionTemplateImpl@27cb4b33{#///@interactionTemplates.0}':
> http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot
>
>
> Any idea?
>
> Many thanks for your help,
>
> Best Regards,
> -- Jean-Baptiste
> PS: I am using org.eclipse.ocl-3.2.1, org.eclipse.ocl.ecore-3.2.0,
> org.eclipse.ocl.common-1.0.2
>
>
|
|
| |
| Re: OCL Validation outside of eclipse [message #1125392 is a reply to message #1125211] |
Fri, 04 October 2013 09:07   |
Ed Willink Messages: 3446 Registered: July 2009 |
Senior Member |
|
|
Hi
If you set a breakpoint on BasicDiagnostic, you can see that the "An
exception occurred while delegating evaluation of the" occurred because of a
java.lang.NoClassDefFoundError:
org/eclipse/ocl/examples/domain/utilities/DomainUtil
which is nearly the same as
org/eclipse/ocl/examples/domain/elements/DomainElement
Try fixing the classpath.
Regards
Ed Willink
On 04/10/2013 05:19, Jean-Baptiste Guillois wrote:
> Hi Ed,
>
> I am sorry for not getting back to you earlier.
>
> Please find attached a zip file containing a minimal project with a main class that:
> - create an instance of a Test class
> - triggers the validation of this instance
>
> After execution, you will have in the console something like:
> Diagnostic ERROR source=root code=0 An exception occurred while delegating evaluation of the 'check1' constraint on 'root.impl.TestImpl@3890c1ee{#//}': org/eclipse/ocl/examples/domain/elements/DomainElement data=[root.impl.TestImpl@3890c1ee (att1: 1, att2: 123)]
>
> This is what i am struggling at...
>
> If you can provide any help/hint regarding this error, that would be great,
>
> Thx,
>
> Best regards,
|
|
|
| Re: OCL Validation outside of eclipse [message #1125408 is a reply to message #1125392] |
Fri, 04 October 2013 09:25   |
Ed Willink Messages: 3446 Registered: July 2009 |
Senior Member |
|
|
Hi
https://bugs.eclipse.org/bugs/show_bug.cgi?id=418677 raised.
Regards
Ed Willink
On 04/10/2013 09:07, Ed Willink wrote:
> Hi
>
> If you set a breakpoint on BasicDiagnostic, you can see that the "An
> exception occurred while delegating evaluation of the" occurred
> because of a
>
> java.lang.NoClassDefFoundError:
> org/eclipse/ocl/examples/domain/utilities/DomainUtil
>
> which is nearly the same as
> org/eclipse/ocl/examples/domain/elements/DomainElement
>
> Try fixing the classpath.
>
> Regards
>
> Ed Willink
>
> On 04/10/2013 05:19, Jean-Baptiste Guillois wrote:
>> Hi Ed,
>>
>> I am sorry for not getting back to you earlier.
>>
>> Please find attached a zip file containing a minimal project with a
>> main class that:
>> - create an instance of a Test class
>> - triggers the validation of this instance
>>
>> After execution, you will have in the console something like:
>> Diagnostic ERROR source=root code=0 An exception occurred while
>> delegating evaluation of the 'check1' constraint on
>> 'root.impl.TestImpl@3890c1ee{#//}':
>> org/eclipse/ocl/examples/domain/elements/DomainElement
>> data=[root.impl.TestImpl@3890c1ee (att1: 1, att2: 123)]
>>
>> This is what i am struggling at...
>>
>> If you can provide any help/hint regarding this error, that would be
>> great,
>>
>> Thx,
>>
>> Best regards,
>
|
|
| | | | | |
Goto Forum:
Current Time: Mon Oct 07 10:09:18 EDT 2013
Powered by FUDForum. Page generated in 0.01851 seconds
|