Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Compare » using EMF Compare to compare Comparison objects(using EMF Compare to compare Comparison objects)
using EMF Compare to compare Comparison objects [message #1745550] Wed, 12 October 2016 12:02 Go to next message
Conor O'Mahony is currently offline Conor O'MahonyFriend
Messages: 27
Registered: August 2016
Junior Member
In our RCP application, we are implementing EMF Compare to compare our model instances, which is working well so far.
As part of this we are writing some JUnit tests that check the actual Comparison model generated in our application against a snapshot/stored Comparison model of what we expect it to be - and for this we are also using EMF Compare.
So basically we use EMF Compare to compare Comparison objects Smile

We changed the matching engine in our application to include an ID function - and some of our tests failed as the expected stored Comparison is now different to the one being computed in our application, i.e., our test result Comparison object reports that there are differences and the test fails.
When I manually inspect the file, the differences look the same, it just looks like the order of the submatches is different. I tried changing the test EMF Compare matching engine to ignore ordering (by adding a feature filter and return false for checkForOrderingChanges()), but this doesn't work.

I have attached two Comparisons that I would expect EMF Compare to find the same. Am I missing something in how the compare works?
Many thanks,
Conor
Re: using EMF Compare to compare Comparison objects [message #1745755 is a reply to message #1745550] Mon, 17 October 2016 08:27 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
Hi,

These two models indeed look the same, though if compared without identifiers I'm sure EMF Compare will indeed see them as different because of the very few attributes present to differentiate them. You say that you've implemented an ID function. Have you tried debugging in it to ensure that it does indeed matches properly the submatches? Could you save that comparison result as well to show us how it looks like?

And if it is indeed an ordering change that's detected even if you specified that ordering shouldn't be taken into account, it sounds like a bug. In such a case could you raise a bug against EMF Compare with samples to reproduce the behavior?

Laurent Goubet
Obeo
Re: using EMF Compare to compare Comparison objects [message #1745771 is a reply to message #1745755] Mon, 17 October 2016 12:13 Go to previous message
Conor O'Mahony is currently offline Conor O'MahonyFriend
Messages: 27
Registered: August 2016
Junior Member
Hi Laurent,

Thanks for your reply.
The ID function is used in the matching engine in the application (rather than the one used in the test) and all it does for the model objects is return the name as the ID, as the names are unique.

      Function<EObject, String> idFunction = new Function<EObject, String>()
      {
         public String apply(EObject input)
         {
            if (input instanceof AbstractBlock)
            {
               return ((AbstractBlock) input).getName();
            }
            // a null return here tells the match engine to fall back to the other matchers
            return null;
         }
      };
      
      IMatchEngine.Factory.Registry registry = EMFCompareRCPPlugin.getDefault().getMatchEngineFactoryRegistry();
      /*
       * configure our matching engine
       */
      IEObjectMatcher fallBackMatcher = DefaultMatchEngine.createDefaultEObjectMatcher(UseIdentifiers.NEVER);
      IEObjectMatcher customIDMatcher = new IdentifierEObjectMatcher(fallBackMatcher, idFunction);
      IComparisonFactory comparisonFactory = new DefaultComparisonFactory(new DefaultEqualityHelperFactory());
      final MatchEngineFactoryImpl matchEngineFactory = new MatchEngineFactoryImpl(customIDMatcher, comparisonFactory);
      matchEngineFactory.setRanking(20); // default engine ranking is 10, must be higher to override.
      registry.add(matchEngineFactory);


I created 2 project models in our app, both with blocks named "Block_1", "Block_2" and "Block_3" (with some minor differences in Block_1 and Block_3), and ran the EMF compare - attached are the results of the comparison run WITH the ID function used, and the other where it does not use the ID function - the difference again appears to be just the ordering of the matches. (I can see this in the Application GUI too where we have plugged in the default EMF viewer - the differences are shown in a different order, so I believe that my ID function is working, it just has the list of matches in a different order).

In the test then, which is essentially using EMF compare to compare those 2 files, I debugged into the FeatureFilter in the test engine compare, to check the "Match" object matching, and it looks like it doesn't match the match objects correctly to begin with (and subsequently the check for ordering never gets used as the matchingContainment check fails.)

I will debug it some more, but the overall problem seems to be that the match objects in the tests aren't being matched to one another.

[Updated on: Mon, 17 October 2016 13:18]

Report message to a moderator

Previous Topic:Determine if all conflicts have been resolved
Next Topic:Default Behaviour for matching derived features
Goto Forum:
  


Current Time: Thu Sep 26 15:50:13 GMT 2024

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

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

Back to the top