private void modifyDiff(MPatchModel mpatch) { assertEquals("Number of changes doesn't match!", 3, mpatch.getChanges().size()); // get model descriptor of add class 'B' change final EMFModelDescriptor subModel = getAddChangeModelDescriptor(mpatch.getChanges(), "B"); final EList<Object> attribute = subModel.getAttributes().get(EcorePackage.Literals.ENAMED_ELEMENT__NAME); final Object name = attribute.get(0); assertEquals("Attribute name differs!", "B", name); // change to 'C' and verify attribute.set(0, "C"); final Object newName = subModel.getAttributes().get(EcorePackage.Literals.ENAMED_ELEMENT__NAME).get(0); assertEquals("Attribute name should have changed to 'C'!", "C", newName); // get model descriptor of add class 'A2' change final IndepChange addChange = (IndepChange) getAddChangeModelDescriptor(mpatch.getChanges(), "A2").eContainer(); final ElementSetReference corrReference = (ElementSetReference) addChange.getCorrespondingElement(); final OclCondition condition = (OclCondition) corrReference.getConditions().get(0); condition.setExpression("name = 'root'"); // no weakening here! }
/** * Create a symbolic reference which contains an ocl condition which holds the criteria for the * referenced model element given in the parameter. * * @param self The element which should be referenced. * @param contextDepth The depth for which context references should be created. If <code>0</code> * , then no context reference is created. * @return A symbolic reference to the model element. */ public ElementSetReference create(EObject self, int contextDepth) { final ElementSetReference ref = SymrefsFactory.eINSTANCE.createElementSetReference(); ref.setType(self.eClass()); ref.setUriReference(QvtlibHelper.getUriString(self)); ref.setLabel(QvtlibHelper.getLabel(self)); ref.getConditions().add(createOclCondition(self)); // the context can of course only be set if the parent exists if (contextDepth > 0 && self.eContainer() != null) { ref.setContext(create(self.eContainer(), contextDepth - 1)); } return ref; }