Ejemplo n.º 1
0
  @Override
  public void setUp() throws Exception {

    super.setUp();

    EcoreFactory factory = EcoreFactory.eINSTANCE;
    EPackage p = factory.createEPackage();
    p.setName("TestPackage1");
    EClass class0 = factory.createEClass();
    class0.setName("Class0");
    EClass class1 = factory.createEClass();
    class1.setName("Class1");
    EClass class2 = factory.createEClass();
    class2.setName("Class2");

    p.getEClassifiers().add(class0);
    p.getEClassifiers().add(class1);
    p.getEClassifiers().add(class2);

    leftModel = EcoreUtil.copy(p);
    URI leftURI = URI.createURI("leftmodel.ecore");
    ModelUtils.attachResource(leftURI, leftModel);

    expectedModel = EcoreUtil.copy(leftModel);
    URI expectedURI = URI.createURI("expectedmodel.ecore");
    ModelUtils.attachResource(expectedURI, expectedModel);

    p.getEClassifiers().remove(class1);
    rightModel = EcoreUtil.copy(p);
    URI rightURI = URI.createURI("rightmodel.ecore");
    ModelUtils.attachResource(rightURI, rightModel);
  }
Ejemplo n.º 2
0
 /**
  * Determines the containing resource for the given eObject.
  *
  * @param eObject the {@link EObject} whose containing resource has to be found
  * @return the resource of the containing eObject or <code>null</code> in case the eObject does
  *     not specify a containing resource and none containing the eObject could be found in the
  *     internal list of resources in scope either.
  */
 private Resource getContainingResource(EObject eObject) {
   // stereotype applications may e.g. not specify an eResource but be contained within one.
   if (eObject.eResource() != null) {
     return eObject.eResource();
   }
   for (Resource resourceInScope : getResourcesInScope()) {
     if (ModelUtils.contains(resourceInScope, eObject)) {
       return resourceInScope;
     }
   }
   return null;
 }