Ejemplo n.º 1
0
        public void testNewOperation_01()
        {
            doTestContextOK("context SpecialFilm def: isSpecialFilm() : Boolean = name = \"Special\"",
                            getCurrentMethodName());
            CoreClassifier classifier = (CoreClassifier)environment.lookup("SpecialFilm");
            List <object>  paramTypes = new List <object>();
            CoreClassifier returnType = (CoreClassifier)environment.lookup("Boolean");

            CoreOperation definedOperation = classifier.lookupSameSignatureOperation("isSpecialFilm", paramTypes, returnType);

            Assert.IsNotNull(definedOperation);
            Assert.IsNotNull(definedOperation.getBodyDefinition());
            OclBodyConstraint constraint = definedOperation.getBodyDefinition();

            Assert.IsNotNull(constraint);
            Assert.AreEqual("Boolean", ((ExpressionInOclImpl)constraint.getExpression()).getBodyExpression().getType().getName());
        }
Ejemplo n.º 2
0
        public void testBody()
        {
            AstOclConstraintFactory   factory1 = AstOclConstraintFactoryManager.getInstance(umlModel.getOclPackage());
            AstOclModelElementFactory factory2 = AstOclModelElementFactoryManager.getInstance(umlModel.getOclPackage());

            RealLiteralExp  exp1     = factory2.createRealLiteralExp("200.50", getClassifier("Real"));
            ExpressionInOcl expInOcl = factory1.createExpressionInOcl("name", getClassifier("Film"), exp1);

            List <object> parms = new List <object>();

            parms.Add(getClassifier("Integer"));
            CoreOperation oper = getClassifier("Film").lookupOperation("getRentalFee", parms);

            OclBodyConstraint constraint = (OclBodyConstraint)factory1.createBodyConstraint("test.ocl", oper, expInOcl, null);

            Assert.AreEqual("body: 200.50", constraint.ToString());

            Assert.AreEqual(constraint, oper.getBodyDefinition());
            Assert.AreEqual(expInOcl, oper.getBodyDefinition().getExpression());

            oper.deleteAllConstraintsForSource("test.ocl");
            Assert.IsNull(oper.getBodyDefinition());
        }