Esempio n. 1
0
 /** Return true if the sole purpose of asPackage is to host implicit opposite properties. */
 public static boolean isImplicitPackage(org.eclipse.ocl.pivot.@NonNull Package asPackage) {
   boolean hasImplicits = false;
   if (!asPackage.getOwnedAnnotations().isEmpty()) {
     return false;
   }
   if (!asPackage.getOwnedComments().isEmpty()) {
     return false;
   }
   if (!asPackage.getOwnedConstraints().isEmpty()) {
     return false;
   }
   if (!asPackage.getOwnedExtensions().isEmpty()) {
     return false;
   }
   if (!asPackage.getOwnedInstances().isEmpty()) {
     return false;
   }
   if (!asPackage.getOwnedPackages().isEmpty()) {
     return false;
   }
   for (org.eclipse.ocl.pivot.Class asClass : asPackage.getOwnedClasses()) {
     if (!asClass.getOwnedAnnotations().isEmpty()) {
       return false;
     }
     if (!asClass.getOwnedBehaviors().isEmpty()) {
       return false;
     }
     if (!asClass.getOwnedBindings().isEmpty()) {
       return false;
     }
     if (!asClass.getOwnedComments().isEmpty()) {
       return false;
     }
     if (!asClass.getOwnedConstraints().isEmpty()) {
       return false;
     }
     if (!asClass.getOwnedExtensions().isEmpty()) {
       return false;
     }
     if (!asClass.getOwnedInvariants().isEmpty()) {
       return false;
     }
     if (!asClass.getOwnedOperations().isEmpty()) {
       return false;
     }
     for (Property asProperty : asClass.getOwnedProperties()) {
       if (!asProperty.isIsImplicit()) {
         return false;
       }
       hasImplicits = true;
     }
   }
   return hasImplicits;
 }
 /** Tests a guarded let if in operator. This gave CG problems. */
 @Test
 public void test_cg_let_implies() {
   TestOCL ocl = createOCL();
   StandardLibrary standardLibrary = ocl.getStandardLibrary();
   String textQuery =
       "let bodyConstraint : Constraint = null\n"
           + "in bodyConstraint <> null implies\n"
           + "bodyConstraint?.ownedSpecification = null";
   org.eclipse.ocl.pivot.Class testType = standardLibrary.getIntegerType();
   assert testType.getOwnedInvariants().isEmpty();
   ocl.assertQueryTrue(testType, textQuery);
   //		ocl.assertQueryTrue(ValuesUtil.createTypeValue(metamodelManager.getMetaclass(testType)),
   // textQuery);
   ocl.dispose();
 }
 @Test
 public void test_let_implies_let_implies() {
   TestOCL ocl = createOCL();
   StandardLibrary standardLibrary = ocl.getStandardLibrary();
   String textQuery =
       "let bodyConstraint : Constraint = oclType().ownedInvariants?->any(name = 'body')\n"
           + "in bodyConstraint <> null implies\n"
           + "let bodySpecification : ValueSpecification = bodyConstraint?.ownedSpecification\n"
           + "in bodySpecification <> null and\n"
           + "bodySpecification?.oclIsKindOf(ExpressionInOCL) implies\n"
           + "true";
   //	    "CompatibleBody(bodySpecification)";
   org.eclipse.ocl.pivot.Class testType = standardLibrary.getIntegerType();
   assert testType.getOwnedInvariants().isEmpty();
   ocl.assertQueryTrue(-1, textQuery);
   ocl.dispose();
 }
 public void addAllElements(
     org.eclipse.ocl.pivot.@NonNull Class asClass, @NonNull ScopeView scopeView) {
   Attribution attribution = PivotUtilInternal.getAttribution(asClass);
   attribution.computeLookup(asClass, this, scopeView);
   org.eclipse.ocl.pivot.Class asUnspecializedClass =
       PivotUtil.getUnspecializedTemplateableElement(asClass);
   org.eclipse.ocl.pivot.Package asPackage = asUnspecializedClass.getOwningPackage();
   if (asPackage != null) {
     attribution = PivotUtilInternal.getAttribution(asPackage);
     attribution.computeLookup(asPackage, this, scopeView);
   }
   { // FIXME redundant
     asPackage = asUnspecializedClass.getOwningPackage();
     if (asPackage != null) {
       attribution = PivotUtilInternal.getAttribution(asPackage);
       attribution.computeLookup(asPackage, this, scopeView);
     }
   }
 }
 @Test
 public void test_cg_loop_source_self_or() throws ParserException, IOException {
   TestOCL ocl = createOCL();
   if (!EMFPlugin.IS_ECLIPSE_RUNNING) {
     OCLinEcoreStandaloneSetup.doSetup();
   }
   String metamodelText =
       "import ecore : 'http://www.eclipse.org/emf/2002/Ecore#/';\n"
           + "package pkg : pkg = 'pkg' {\n"
           + "  class A {\n"
           + "    invariant True : true;\n"
           + "  }\n"
           + "}\n";
   Resource metamodel = cs2as(ocl, metamodelText);
   Model pivotModel = (Model) metamodel.getContents().get(0);
   org.eclipse.ocl.pivot.Package pivotPackage = pivotModel.getOwnedPackages().get(0);
   org.eclipse.ocl.pivot.Class pivotType = pivotPackage.getOwnedClasses().get(0);
   Constraint pivotConstraint = pivotType.getOwnedInvariants().get(0);
   String textQuery =
       "context.oclAsType(Class).ownedInvariants->excluding(self)?->forAll(name <> self.name or isCallable <> self.isCallable)";
   ocl.assertQueryTrue(pivotConstraint, textQuery);
   ocl.dispose();
 }
 @Test
 public void test_dynamic_dispatch_411154() throws ParserException, IOException {
   if (useCodeGen) return;
   TestOCL ocl = createOCL();
   if (!EMFPlugin.IS_ECLIPSE_RUNNING) {
     OCLinEcoreStandaloneSetup.doSetup();
     //			OCLDelegateDomain.initialize(null);
   }
   MetamodelManager metamodelManager = ocl.getMetamodelManager();
   String metamodelText =
       "package Bug411154 : pfx = 'Bug411154.ecore'\n"
           + "{\n"
           + "	class Domain {\n"
           + "		property types : T1[*] { ordered composes };\n"
           + "		property t1_2a : T1;\n"
           + "		property t1_3a : T1;\n"
           + "		property t1_3b : T1;\n"
           + "		property t1_4 : T1;\n"
           + "		property t2a_2a : T2a;\n"
           + "		property t2a_3a : T2a;\n"
           + "		property t2b_2b : T2b;\n"
           + "		property t3a : T3a;\n"
           + "	}\n"
           + "	abstract class T1 {\n"
           + "		operation op1() : String { body: 'T1::op1'; }\n"
           + "		operation op4() : String { body: 'T1::op4'; }\n"
           + "		operation op5() : String { body: 'T1::op5'; }\n"
           + "		operation op6() : String { body: 'T1::op6'; }\n"
           + "	}\n"
           + "	class T2a extends T1 {\n"
           + "		operation op1() : String { body: 'T2a::op1'; }\n"
           + "		operation op2() : String { body: 'T2a::op2'; }\n"
           + "		operation op4() : String { body: 'T2a::op4'; }\n"
           + "		operation op6() : String { body: 'T2a::op6'; }\n"
           + "		operation op7() : String { body: 'T2a::op7'; }\n"
           + "		operation op9() : String { body: 'T2a::op9'; }\n"
           + "	}\n"
           + "	class T2b extends T1 {\n"
           + "		operation op6() : String { body: 'T2b::op6'; }\n"
           + "		operation op7() : String { body: 'T2b::op7'; }\n"
           + "		operation op9() : String { body: 'T2b::op9'; }\n"
           + "	}\n"
           + "	class T3a extends T2a,T2b {\n"
           + "		operation op1() : String { body: 'T3a::op1'; }\n"
           + "		operation op2() : String { body: 'T3a::op2'; }\n"
           + "		operation op3() : String { body: 'T3a::op3'; }\n"
           + "		operation op6() : String { body: 'T3a::op6'; }\n"
           + "		operation op7() : String { body: 'T3a::op7'; }\n"
           + "	}\n"
           + "	class T3b extends T2a,T2b {\n"
           + "	}\n"
           + "	class T4 extends T3a,T3b {\n"
           + "		operation op6() : String { body: 'T4::op6'; }\n"
           + "		operation op7() : String { body: 'T4::op7'; }\n"
           + "	}\n"
           + "}\n";
   Resource metamodel = cs2as(ocl, metamodelText);
   Model pivotModel = (Model) metamodel.getContents().get(0);
   org.eclipse.ocl.pivot.Package pivotPackage = pivotModel.getOwnedPackages().get(0);
   org.eclipse.ocl.pivot.Class pivotTypeDomain =
       NameUtil.getNameable(pivotPackage.getOwnedClasses(), "Domain");
   //		org.eclipse.ocl.pivot.Class pivotTypeT1 =
   // ClassUtil.getNamedElement(pivotPackage.getOwnedType(), "T1");
   org.eclipse.ocl.pivot.Class pivotTypeT2a =
       NameUtil.getNameable(pivotPackage.getOwnedClasses(), "T2a");
   org.eclipse.ocl.pivot.Class pivotTypeT2b =
       NameUtil.getNameable(pivotPackage.getOwnedClasses(), "T2b");
   org.eclipse.ocl.pivot.Class pivotTypeT3a =
       NameUtil.getNameable(pivotPackage.getOwnedClasses(), "T3a");
   org.eclipse.ocl.pivot.Class pivotTypeT3b =
       NameUtil.getNameable(pivotPackage.getOwnedClasses(), "T3b");
   org.eclipse.ocl.pivot.Class pivotTypeT4 =
       NameUtil.getNameable(pivotPackage.getOwnedClasses(), "T4");
   EPackage ePackage = metamodelManager.getEcoreOfPivot(EPackage.class, pivotPackage);
   EClass eClassDomain = metamodelManager.getEcoreOfPivot(EClass.class, pivotTypeDomain);
   //		EClass eClassT1 = metamodelManager.getEcoreOfPivot(EClass.class, pivotTypeT1);
   EClass eClassT2a = metamodelManager.getEcoreOfPivot(EClass.class, pivotTypeT2a);
   EClass eClassT2b = metamodelManager.getEcoreOfPivot(EClass.class, pivotTypeT2b);
   EClass eClassT3a = metamodelManager.getEcoreOfPivot(EClass.class, pivotTypeT3a);
   EClass eClassT3b = metamodelManager.getEcoreOfPivot(EClass.class, pivotTypeT3b);
   EClass eClassT4 = metamodelManager.getEcoreOfPivot(EClass.class, pivotTypeT4);
   EReference eReferenceDomain_types =
       metamodelManager.getEcoreOfPivot(
           EReference.class, NameUtil.getNameable(pivotTypeDomain.getOwnedProperties(), "types"));
   EReference eReferenceDomain_t1_2a =
       metamodelManager.getEcoreOfPivot(
           EReference.class, NameUtil.getNameable(pivotTypeDomain.getOwnedProperties(), "t1_2a"));
   EReference eReferenceDomain_t1_3a =
       metamodelManager.getEcoreOfPivot(
           EReference.class, NameUtil.getNameable(pivotTypeDomain.getOwnedProperties(), "t1_3a"));
   EReference eReferenceDomain_t1_3b =
       metamodelManager.getEcoreOfPivot(
           EReference.class, NameUtil.getNameable(pivotTypeDomain.getOwnedProperties(), "t1_3b"));
   EReference eReferenceDomain_t1_4 =
       metamodelManager.getEcoreOfPivot(
           EReference.class, NameUtil.getNameable(pivotTypeDomain.getOwnedProperties(), "t1_4"));
   EReference eReferenceDomain_t2a_2a =
       metamodelManager.getEcoreOfPivot(
           EReference.class, NameUtil.getNameable(pivotTypeDomain.getOwnedProperties(), "t2a_2a"));
   EReference eReferenceDomain_t2a_3a =
       metamodelManager.getEcoreOfPivot(
           EReference.class, NameUtil.getNameable(pivotTypeDomain.getOwnedProperties(), "t2a_3a"));
   EReference eReferenceDomain_t2b_2b =
       metamodelManager.getEcoreOfPivot(
           EReference.class, NameUtil.getNameable(pivotTypeDomain.getOwnedProperties(), "t2b_2b"));
   EReference eReferenceDomain_t3a =
       metamodelManager.getEcoreOfPivot(
           EReference.class, NameUtil.getNameable(pivotTypeDomain.getOwnedProperties(), "t3a"));
   EFactory eFactory = ePackage.getEFactoryInstance();
   Resource resource = new ResourceImpl();
   EObject testObjectDomain = eFactory.create(eClassDomain);
   resource.getContents().add(testObjectDomain);
   EObject testObjectT2a = eFactory.create(eClassT2a);
   EObject testObjectT2b = eFactory.create(eClassT2b);
   EObject testObjectT3a = eFactory.create(eClassT3a);
   EObject testObjectT3b = eFactory.create(eClassT3b);
   EObject testObjectT4 = eFactory.create(eClassT4);
   @SuppressWarnings("unchecked")
   List<EObject> list = (List<EObject>) testObjectDomain.eGet(eReferenceDomain_types);
   list.add(testObjectT2a);
   list.add(testObjectT2b);
   list.add(testObjectT3a);
   list.add(testObjectT3b);
   list.add(testObjectT4);
   testObjectDomain.eSet(eReferenceDomain_t1_2a, testObjectT2a);
   testObjectDomain.eSet(eReferenceDomain_t1_3a, testObjectT3a);
   testObjectDomain.eSet(eReferenceDomain_t1_3b, testObjectT3b);
   testObjectDomain.eSet(eReferenceDomain_t1_4, testObjectT4);
   testObjectDomain.eSet(eReferenceDomain_t2a_2a, testObjectT2a);
   testObjectDomain.eSet(eReferenceDomain_t2a_3a, testObjectT3a);
   testObjectDomain.eSet(eReferenceDomain_t2b_2b, testObjectT2b);
   testObjectDomain.eSet(eReferenceDomain_t3a, testObjectT3a);
   //
   ocl.assertQueryEquals(testObjectT2a, "T2a::op1", "self.op1()");
   ocl.assertQueryEquals(testObjectT2a, "T2a::op2", "self.op2()");
   ocl.assertSemanticErrorQuery(
       pivotTypeT2a,
       "self.op3()",
       PivotMessagesInternal.UnresolvedOperation_ERROR_,
       "Bug411154",
       "T2a::op3");
   ocl.assertQueryEquals(testObjectT2a, "T2a::op4", "self.op4()");
   ocl.assertQueryEquals(testObjectT2a, "T1::op5", "self.op5()");
   ocl.assertQueryEquals(testObjectT2a, "T2a::op6", "self.op6()");
   ocl.assertQueryEquals(testObjectT2a, "T2a::op7", "self.op7()");
   ocl.assertSemanticErrorQuery(
       pivotTypeT2a,
       "self.op8()",
       PivotMessagesInternal.UnresolvedOperation_ERROR_,
       "Bug411154",
       "T2a::op8");
   ocl.assertQueryEquals(testObjectT2a, "T2a::op9", "self.op9()");
   //
   ocl.assertQueryEquals(testObjectT3a, "T3a::op1", "self.op1()");
   ocl.assertQueryEquals(testObjectT3a, "T3a::op2", "self.op2()");
   ocl.assertQueryEquals(testObjectT3a, "T3a::op3", "self.op3()");
   ocl.assertQueryEquals(testObjectT3a, "T2a::op4", "self.op4()");
   ocl.assertQueryEquals(testObjectT3a, "T1::op5", "self.op5()");
   ocl.assertQueryEquals(testObjectT3a, "T3a::op6", "self.op6()");
   ocl.assertQueryEquals(testObjectT3a, "T3a::op7", "self.op7()");
   ocl.assertSemanticErrorQuery(
       pivotTypeT3a,
       "self.op8()",
       PivotMessagesInternal.UnresolvedOperation_ERROR_,
       "Bug411154",
       "T3a::op8");
   ocl.assertSemanticErrorQuery(
       pivotTypeT3a,
       "self.op9()",
       "Ambiguous resolution:\n"
           + "\tOperation : Bug411154::T2a::op9() : String[?]\n"
           + "\tOperation : Bug411154::T2b::op9() : String[?]");
   //
   ocl.assertQueryEquals(testObjectDomain, "T2a::op1", "t1_2a.op1()");
   ocl.assertSemanticErrorQuery(
       pivotTypeDomain,
       "t1_2a.op2()",
       PivotMessagesInternal.UnresolvedOperation_ERROR_,
       "Bug411154",
       "T1::op2");
   ocl.assertSemanticErrorQuery(
       pivotTypeDomain,
       "t1_2a.op3()",
       PivotMessagesInternal.UnresolvedOperation_ERROR_,
       "Bug411154",
       "T1::op3");
   ocl.assertQueryEquals(testObjectDomain, "T2a::op4", "t1_2a.op4()");
   ocl.assertQueryEquals(testObjectDomain, "T1::op5", "t1_2a.op5()");
   //
   ocl.assertQueryEquals(testObjectDomain, "T3a::op1", "t1_3a.op1()");
   ocl.assertSemanticErrorQuery(
       pivotTypeDomain,
       "t1_3a.op2()",
       PivotMessagesInternal.UnresolvedOperation_ERROR_,
       "Bug411154",
       "T1::op2");
   ocl.assertSemanticErrorQuery(
       pivotTypeDomain,
       "t1_3a.op3()",
       PivotMessagesInternal.UnresolvedOperation_ERROR_,
       "Bug411154",
       "T1::op3");
   ocl.assertQueryEquals(testObjectDomain, "T2a::op4", "t1_3a.op4()");
   ocl.assertQueryEquals(testObjectDomain, "T1::op5", "t1_3a.op5()");
   //
   ocl.assertQueryEquals(testObjectDomain, "T2a::op1", "t1_3b.op1()");
   ocl.assertSemanticErrorQuery(
       pivotTypeDomain,
       "t1_3b.op2()",
       PivotMessagesInternal.UnresolvedOperation_ERROR_,
       "Bug411154",
       "T1::op2");
   ocl.assertSemanticErrorQuery(
       pivotTypeDomain,
       "t1_3b.op3()",
       PivotMessagesInternal.UnresolvedOperation_ERROR_,
       "Bug411154",
       "T1::op3");
   ocl.assertQueryEquals(testObjectDomain, "T2a::op4", "t1_3b.op4()");
   ocl.assertQueryEquals(testObjectDomain, "T1::op5", "t1_3b.op5()");
   ocl.assertQueryInvalid(
       testObjectDomain,
       "t1_3b.op6()",
       NLS.bind(
           PivotMessages.AmbiguousOperation, "Bug411154::T1::op6() : String[?]", "Bug411154::T3b"),
       InvalidValueException.class);
   ocl.assertSemanticErrorQuery(
       pivotTypeDomain,
       "t1_3b.op7()",
       PivotMessagesInternal.UnresolvedOperation_ERROR_,
       "Bug411154",
       "T1::op7");
   //
   ocl.assertQueryEquals(testObjectDomain, "T3a::op1", "t1_4.op1()");
   ocl.assertSemanticErrorQuery(
       pivotTypeDomain,
       "t1_4.op2()",
       PivotMessagesInternal.UnresolvedOperation_ERROR_,
       "Bug411154",
       "T1::op2");
   ocl.assertSemanticErrorQuery(
       pivotTypeDomain,
       "t1_4.op3()",
       PivotMessagesInternal.UnresolvedOperation_ERROR_,
       "Bug411154",
       "T1::op3");
   ocl.assertQueryEquals(testObjectDomain, "T2a::op4", "t1_4.op4()");
   ocl.assertQueryEquals(testObjectDomain, "T1::op5", "t1_4.op5()");
   ocl.assertQueryEquals(testObjectDomain, "T4::op6", "t1_4.op6()");
   ocl.assertSemanticErrorQuery(
       pivotTypeDomain,
       "t1_4.op7()",
       PivotMessagesInternal.UnresolvedOperation_ERROR_,
       "Bug411154",
       "T1::op7");
   //
   ocl.assertQueryEquals(testObjectDomain, "T2a::op1", "t2a_2a.op1()");
   ocl.assertQueryEquals(testObjectDomain, "T2a::op2", "t2a_2a.op2()");
   ocl.assertSemanticErrorQuery(
       pivotTypeDomain,
       "t2a_2a.op3()",
       PivotMessagesInternal.UnresolvedOperation_ERROR_,
       "Bug411154",
       "T2a::op3");
   ocl.assertQueryEquals(testObjectDomain, "T2a::op4", "t2a_2a.op4()");
   ocl.assertQueryEquals(testObjectDomain, "T1::op5", "t2a_2a.op5()");
   ocl.assertQueryEquals(testObjectDomain, "T2a::op6", "t2a_2a.op6()");
   ocl.assertQueryEquals(testObjectDomain, "T2a::op7", "t2a_2a.op7()");
   //
   ocl.assertQueryEquals(testObjectDomain, "T2b::op6", "t2b_2b.op6()");
   //
   ocl.assertQueryEquals(testObjectDomain, "T3a::op1", "t2a_3a.op1()");
   ocl.assertQueryEquals(testObjectDomain, "T3a::op2", "t2a_3a.op2()");
   ocl.assertSemanticErrorQuery(
       pivotTypeDomain,
       "t2a_3a.op3()",
       PivotMessagesInternal.UnresolvedOperation_ERROR_,
       "Bug411154",
       "T2a::op3");
   ocl.assertQueryEquals(testObjectDomain, "T2a::op4", "t2a_3a.op4()");
   ocl.assertQueryEquals(testObjectDomain, "T1::op5", "t2a_3a.op5()");
   //
   ocl.assertQueryEquals(testObjectDomain, "T3a::op1", "t3a.op1()");
   ocl.assertQueryEquals(testObjectDomain, "T3a::op2", "t3a.op2()");
   ocl.assertQueryEquals(testObjectDomain, "T3a::op3", "t3a.op3()");
   ocl.assertQueryEquals(testObjectDomain, "T2a::op4", "t3a.op4()");
   ocl.assertQueryEquals(testObjectDomain, "T1::op5", "t3a.op5()");
   ocl.dispose();
 }
 @Test
 public void test_cg_name_occlusion_401692() throws ParserException, IOException {
   TestOCL ocl = createOCL();
   if (!EMFPlugin.IS_ECLIPSE_RUNNING) {
     OCLinEcoreStandaloneSetup.doSetup();
     //			OCLDelegateDomain.initialize(null);
   }
   MetamodelManager metamodelManager = ocl.getMetamodelManager();
   String metamodelText =
       "package scope = 'abc'\n"
           + "{\n"
           + "	class A\n"
           + "	{\n"
           + "		attribute d : String;\n"
           + "		attribute e : String;\n"
           + "	}\n"
           + "	class B\n"
           + "	{\n"
           + "		operation findA(e : String) : A[?]\n"
           + "		{\n"
           + "			body:\n"
           + "				let found : OrderedSet(A) = as?->select(a : A | a.d = e) in if found->size() > 0 then found->first() else null endif;\n"
           + "		}\n"
           + "		property as : A[*] { ordered composes };\n"
           + "	}\n"
           + "}\n";
   Resource metamodel = cs2as(ocl, metamodelText);
   Model pivotModel = (Model) metamodel.getContents().get(0);
   org.eclipse.ocl.pivot.Package pivotPackage = pivotModel.getOwnedPackages().get(0);
   org.eclipse.ocl.pivot.Class pivotTypeA =
       NameUtil.getNameable(pivotPackage.getOwnedClasses(), "A");
   org.eclipse.ocl.pivot.Class pivotTypeB =
       NameUtil.getNameable(pivotPackage.getOwnedClasses(), "B");
   EPackage ePackage = metamodelManager.getEcoreOfPivot(EPackage.class, pivotPackage);
   EClass eClassA = metamodelManager.getEcoreOfPivot(EClass.class, pivotTypeA);
   EClass eClassB = metamodelManager.getEcoreOfPivot(EClass.class, pivotTypeB);
   EAttribute eAttributeAd =
       metamodelManager.getEcoreOfPivot(
           EAttribute.class, NameUtil.getNameable(pivotTypeA.getOwnedProperties(), "d"));
   EAttribute eAttributeAe =
       metamodelManager.getEcoreOfPivot(
           EAttribute.class, NameUtil.getNameable(pivotTypeA.getOwnedProperties(), "e"));
   EReference eReferenceBas =
       metamodelManager.getEcoreOfPivot(
           EReference.class, NameUtil.getNameable(pivotTypeB.getOwnedProperties(), "as"));
   EFactory eFactory = ePackage.getEFactoryInstance();
   Resource resource = new ResourceImpl();
   EObject testObjectA1 = eFactory.create(eClassA);
   testObjectA1.eSet(eAttributeAd, "d1");
   testObjectA1.eSet(eAttributeAe, "e1");
   EObject testObjectA2 = eFactory.create(eClassA);
   testObjectA2.eSet(eAttributeAd, "d2");
   testObjectA2.eSet(eAttributeAe, "e2");
   EObject testObjectB = eFactory.create(eClassB);
   resource.getContents().add(testObjectB);
   @SuppressWarnings("unchecked")
   List<EObject> as = (List<EObject>) testObjectB.eGet(eReferenceBas);
   as.add(testObjectA1);
   as.add(testObjectA2);
   //
   ocl.assertQueryEquals(testObjectB, testObjectA1, "self.findA('d1')");
   ocl.assertQueryEquals(testObjectB, null, "self.findA('e2')");
   ocl.dispose();
 }
 /**
  * Executes the query for the specified <tt>target</tt> object. The result is the OCL evaluation
  * result which may be a Number, String, Collection or other object for normal returns or a
  * NullLiteralExp for null, or an InvalidLiteralExp for invalid.
  *
  * @param target the object on which to execute the query; this must be an instance of the context
  *     with which the delegate was created
  * @param arguments a map of variable names to values; these must correspond to the variables with
  *     which the delegate was created
  * @return the query's result
  * @throws InvocationTargetException in case of failure to prepare or execute the query, usually
  *     because of an exception
  */
 @Override
 public Object execute(@Nullable Object target, Map<String, ?> arguments)
     throws InvocationTargetException {
   @SuppressWarnings("null")
   @NonNull
   Map<String, ?> nonNullArguments =
       (arguments != null ? arguments : (Map<String, ?>) Collections.<String, Object>emptyMap());
   try {
     if (specification == null) {
       prepare();
     }
     @SuppressWarnings("null")
     @NonNull
     ExpressionInOCL nonNullSpecification = specification;
     OCL ocl = delegateDomain.getOCL();
     IdResolver idResolver = ocl.getIdResolver();
     Object targetValue = idResolver.boxedValueOf(target);
     org.eclipse.ocl.pivot.Class targetType = idResolver.getStaticTypeOf(targetValue);
     Type requiredType = nonNullSpecification.getOwnedContext().getType();
     if ((requiredType == null)
         || !targetType.conformsTo(ocl.getStandardLibrary(), requiredType)) {
       String message =
           StringUtil.bind(
               PivotMessagesInternal.WrongContextClassifier_ERROR_, targetType, requiredType);
       throw new OCLDelegateException(new SemanticException(message));
     }
     List<Variable> parameterVariables = nonNullSpecification.getOwnedParameters();
     int argCount = arguments != null ? arguments.size() : 0;
     if (parameterVariables.size() != argCount) {
       String message =
           StringUtil.bind(
               PivotMessagesInternal.MismatchedArgumentCount_ERROR_,
               argCount,
               parameterVariables.size());
       throw new OCLDelegateException(new SemanticException(message));
     }
     Query query = ocl.createQuery(nonNullSpecification);
     EvaluationEnvironment env = query.getEvaluationEnvironment(target);
     for (Variable parameterVariable : parameterVariables) {
       // bind arguments to parameter names
       String name = parameterVariable.getName();
       Object object = nonNullArguments.get(name);
       if ((object == null) && !nonNullArguments.containsKey(name)) {
         String message =
             StringUtil.bind(
                 PivotMessagesInternal.EvaluationResultIsInvalid_ERROR_,
                 nonNullSpecification.getBody());
         throw new OCLDelegateException(new SemanticException(message));
       }
       Object value = idResolver.boxedValueOf(object);
       targetType = idResolver.getStaticTypeOf(value);
       requiredType = ClassUtil.nonNullModel(parameterVariable.getType());
       if (!targetType.conformsTo(ocl.getStandardLibrary(), requiredType)) {
         String message =
             StringUtil.bind(
                 PivotMessagesInternal.MismatchedArgumentType_ERROR_,
                 name,
                 targetType,
                 requiredType);
         throw new OCLDelegateException(new SemanticException(message));
       }
       env.add(parameterVariable, value);
     }
     Object result = evaluate(query, target);
     //			if (result.isInvalid()) {
     //				String message = ClassUtil.bind(OCLMessages.EvaluationResultIsInvalid_ERROR_,
     // getOperationName());
     //				throw new OCLDelegateException(message);
     //			}
     //		if ((result == null) / * || ocl.isInvalid(result) * /) {
     //			String message = ClassUtil.bind(OCLMessages.EvaluationResultIsNull_ERROR_,
     // getOperationName());
     //			throw new OCLDelegateException(message);
     //		}
     //		return converter.convert(ocl, result);
     //			if (result == null) {
     //				String message = NLS.bind(OCLMessages.EvaluationResultIsInvalid_ERROR_,
     // PivotUtil.getBody(specification));
     //				throw new InvocationTargetException(new OCLDelegateException(message));
     //			}
     return idResolver.ecoreValueOf(null, result);
   } catch (InvocationTargetException e) {
     throw e;
   } catch (EvaluationException e) {
     String message =
         StringUtil.bind(
             PivotMessagesInternal.EvaluationResultIsInvalid_ERROR_, specification.getBody());
     throw new InvocationTargetException(new EvaluationException(message));
   } catch (WrappedException e) {
     throw new InvocationTargetException(e.getCause());
   } catch (Exception e) {
     throw new InvocationTargetException(e);
   }
 }
 protected org.eclipse.ocl.pivot.@NonNull Class createType(
     org.eclipse.ocl.pivot.@NonNull Class domainType) {
   org.eclipse.ocl.pivot.Class pivotType = PivotFactory.eINSTANCE.createClass();
   pivotType.setName(domainType.getName());
   return pivotType;
 }