Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » Query PatternMatchModel from Eunit
Query PatternMatchModel from Eunit [message #1404586] Mon, 04 August 2014 10:25 Go to next message
abdush mohd is currently offline abdush mohdFriend
Messages: 35
Registered: April 2014
Member
Hi,

I am trying to write a Eunit test for an EPL transformation module.
I am following the same structure as in this example for EVL:

https://www.eclipse.org/epsilon/examples/index.php?example=org.eclipse.epsilon.eunit.examples.evl

I set the export as to "EPL" and try to check which and how many patterns are matched. If for example there is a Pattern named "pattern1", so how can I access the instances of the model where this pattern was matched and the instances of the its roles??

I tried both EPL!pattern1.all and EPL.getMatches() but always get an empty collection.

Here is the eunit file.

Thanks

Abdu
Re: Query PatternMatchModel from Eunit [message #1404714 is a reply to message #1404586] Tue, 05 August 2014 09:04 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 1028
Registered: July 2009
Senior Member
Hi Abdu,

The epsilon.epl task exports its pattern match model in the project's model repository (see [1], line 81) for other Epsilon tasks to use through <model ref="..."> nested elements. Since you're interacting with the ANT project programmatically you'll need to retrieve the exported model from the project's repository programmatically and then add it to the model repository of the EUnit module (module.getContext().getModelRepository().addModel(...)), though I'm not sure how you'd go about the latter off the top of my head.

Cheers,
Dimitris

[1] https://dev.eclipse.org/svnroot/modeling/org.eclipse.epsilon/trunk/plugins/org.eclipse.epsilon.workflow/ant/org/eclipse/epsilon/workflow/tasks/EpsilonTask.java
Re: Query PatternMatchModel from Eunit [message #1405019 is a reply to message #1404714] Wed, 06 August 2014 11:37 Go to previous messageGo to next message
abdush mohd is currently offline abdush mohdFriend
Messages: 35
Registered: April 2014
Member
Hi Dimitris,

Sorry, I have been trying out this but couldn't manage to run it.

When I add these lines to the eunit file, still my test fails:

var module = new Native('org.eclipse.epsilon.eunit.EUnitModule');
  module.getContext().getModelRepository().addModel(EPL);


Do I have to get the exported model using getProjectRepository() or just its name? It seems that EplTask doesn't have a getProjectRepository() method.

Actually, I can access the PatternMatchModel in my eunit module simply by its name but when I try to check the matched pattern the test fails because it returns empty sequence for the instances matching the pattern in this line:

var R1matched =EPL!SingleInputOutputNonObjectNode.all;


As this line compiles without any error, I guess that the PatternMatchModel is accessible by its name and it has a Type for one of my defined patterns, as expected. The only problem is that it fails because this returns an empty sequence while there are 3 matches for this pattern.

Anything that I might have missed?

Regards
Abdu
Re: Query PatternMatchModel from Eunit [message #1405834 is a reply to message #1405019] Fri, 08 August 2014 09:24 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 1028
Registered: July 2009
Senior Member
Hi Abdu,

Could you please provide something that I can run so that I can investigate further?

Cheers,
Dimitris
Re: Query PatternMatchModel from Eunit [message #1405881 is a reply to message #1405834] Fri, 08 August 2014 11:36 Go to previous messageGo to next message
abdush mohd is currently offline abdush mohdFriend
Messages: 35
Registered: April 2014
Member
Hi Dimitris,

Here is a folder for the eunit project, similar to the EVL example.

Thanks,
Abdu
Re: Query PatternMatchModel from Eunit [message #1406191 is a reply to message #1405881] Sat, 09 August 2014 09:00 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 1028
Registered: July 2009
Senior Member
Hi Abdu,

Looking at the lines below, your EPL patterns will run until there are no matches left in the model, which could explain why your pattern-match model is empty.

epl_task.setRepeatWhileMatches(true);
epl_task.setMaxLoops(-1);

Cheers,
Dimitris
Re: Query PatternMatchModel from Eunit [message #1406312 is a reply to message #1406191] Sat, 09 August 2014 17:49 Go to previous messageGo to next message
abdush mohd is currently offline abdush mohdFriend
Messages: 35
Registered: April 2014
Member
aah.. Thanks Dimitris, nice catch. That's very helpful.. somehow i missed that.

So, there is no way to run the module until there is no match, and see how many times a pattern has been matched?

[Updated on: Sat, 09 August 2014 19:23]

Report message to a moderator

Re: Query PatternMatchModel from Eunit [message #1406519 is a reply to message #1406312] Sun, 10 August 2014 09:05 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 1028
Registered: July 2009
Senior Member
Hi Abdu,

I'm glad this helped. Off the top of my head, you could use a variable declared in the pre part of the EPL module to keep track of the number of matches (i.e. increment it by 1 in the onmatch part of each pattern) and then use the workflow's <exports>/<uses> nested elements to pass the value of the variable on to the next task.

Cheers,
Dimitris
Re: Query PatternMatchModel from Eunit [message #1408974 is a reply to message #1406519] Sat, 16 August 2014 17:35 Go to previous message
abdush mohd is currently offline abdush mohdFriend
Messages: 35
Registered: April 2014
Member
Hi Dimitris,

Thanks for your suggestion. I used <exports> and <uses> elements before within a workflow to pass variables between modules, but I had difficulty to do so for my unit test. The EPL task is created and executed from the eunit module so I didn't know how this could be done.

As, it is a test unit, I decided simply to call and execute the EPL task as many times as I want and check and compare the pattern matches.

Thanks.
Abdu

[Updated on: Sat, 16 August 2014 17:35]

Report message to a moderator

Previous Topic:Copy one element to another
Next Topic:Is there a possibilty to set Ecore Resource options in Epsilon?
Goto Forum:
  


Current Time: Sun Aug 30 14:12:37 GMT 2015

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

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