public void testOperationCallExp()
        {
            AstOclModelElementFactory factory1 = AstOclModelElementFactoryManager.getInstance(umlModel.getOclPackage());

            VariableDeclaration variable = factory1.createVariableDeclaration("abc", getClassifier("Film"), null);
            VariableExp         source   = factory1.createVariableExp(variable);

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

            paramTypes.Add(getClassifier("Integer"));

            CoreOperation operation = getClassifier("Film").lookupOperation("getRentalFee", paramTypes);

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

            arguments.Add(factory1.createIntegerLiteralExp(100, getClassifier("Integer")));

            OperationCallExp exp = factory1.createOperationCallExp(source, operation, arguments,
                                                                   operation.getReturnType(), false);

            Assert.AreEqual("abc.getRentalFee(100)", exp.ToString());
            Assert.AreEqual("Real", exp.getType().getName());

            CollectionLiteralExp literalCollection = factory1.createCollectionLiteralExp(createCollectionParts(),
                                                                                         factory1.createSetType(
                                                                                             getClassifier("Integer")));
            CollectionTypeImpl type1          = (CollectionTypeImpl)factory1.createSetType(getClassifier("Integer"));
            CoreOperation      collectionOper = type1.lookupOperation("size", new List <object>());

            OperationCallExp exp1 = factory1.createOperationCallExp(literalCollection, collectionOper, new List <object>(),
                                                                    getClassifier("Integer"), false);

            Assert.IsNotNull(exp1);
        }
        public void testVariableExp()
        {
            AstOclModelElementFactory factory1 = AstOclModelElementFactoryManager.getInstance(umlModel.getOclPackage());

            OclExpression       init1    = factory1.createIntegerLiteralExp(100, getClassifier("Integer"));
            VariableDeclaration variable = factory1.createVariableDeclaration("abc", getClassifier("Integer"), init1);

            VariableExp exp1 = factory1.createVariableExp(variable);
            VariableExp exp2 = factory1.createVariableExp(variable);

            Assert.AreEqual("abc", exp1.ToString());
            Assert.AreEqual("Integer", exp1.getType().getName());

            Assert.AreEqual("abc", exp2.ToString());
            Assert.AreEqual("Integer", exp2.getType().getName());

            Assert.AreEqual("100", variable.getInitExpression().ToString());
        }
        public void testAttributeCallExp()
        {
            AstOclModelElementFactory factory1 = AstOclModelElementFactoryManager.getInstance(umlModel.getOclPackage());

            VariableDeclaration variable = factory1.createVariableDeclaration("abc", getClassifier("Film"), null);
            VariableExp         source1  = factory1.createVariableExp(variable);
            VariableExp         source2  = factory1.createVariableExp(variable);

            CoreAttribute attribute = getClassifier("Film").lookupAttribute("name");

            AttributeCallExp exp1 = factory1.createAttributeCallExp(source1, attribute, false);
            AttributeCallExp exp2 = factory1.createAttributeCallExp(source2, attribute, true);

            Assert.AreEqual("abc.name", exp1.ToString());
            Assert.AreEqual("String", exp1.getType().getName());

            Assert.AreEqual("abc.name@pre", exp2.ToString());
            Assert.AreEqual("String", exp2.getType().getName());
        }
        public void testIterateExp()
        {
            AstOclModelElementFactory factory1 = AstOclModelElementFactoryManager.getInstance(umlModel.getOclPackage());

            VariableDeclaration variable = factory1.createVariableDeclaration("abc", getClassifier("Distributor"), null);
            VariableExp         source   = factory1.createVariableExp(variable);

            VariableDeclaration iter    = factory1.createVariableDeclaration("iter", getClassifier("SpecialFilm"), null);
            VariableExp         iterRef = factory1.createVariableExp(iter);

            CoreAttribute    attr    = getClassifier("SpecialFilm").lookupAttribute("lateReturnFee");
            AttributeCallExp attCall = factory1.createAttributeCallExp(iterRef, attr, false);

            IntegerLiteralExp   initExp = factory1.createIntegerLiteralExp(100, getClassifier("Integer"));
            VariableDeclaration result  = factory1.createVariableDeclaration("result", getClassifier("Integer"), initExp);


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

            paramTypes.Add(getClassifier("Integer"));
            CoreOperation oper = getClassifier("Integer").lookupOperation("+", paramTypes);

            VariableExp   resultExp = factory1.createVariableExp(result);
            List <object> args      = new List <object>();

            args.Add(attCall);
            OclExpression body = factory1.createOperationCallExp(resultExp, oper, args, getClassifier("Integer"), false);

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

            iterators.Add(iter);

            IterateExp exp = factory1.createIterateExp(getClassifier("Integer"), source, body, iterators, result);

            Assert.AreEqual("abc->iterate(iter : SpecialFilm ; result : Integer = 100 | result + iter.lateReturnFee)",
                            exp.ToString());
            Assert.AreEqual("Integer", exp.getType().getName());
        }
        public void testAssociationEndCallExp_08()
        {
            AstOclModelElementFactory factory1 = AstOclModelElementFactoryManager.getInstance(umlModel.getOclPackage());

            VariableDeclaration variable = factory1.createVariableDeclaration("abc", getClassifier("Allocation"), null);
            VariableExp         source   = factory1.createVariableExp(variable);

            CoreAssociationEnd assocEnd = getClassifier("Allocation").lookupAssociationEnd("films");

            AssociationEndCallExp exp1 = factory1.createAssociationEndCallExp(source, assocEnd, null, null, false);

            Assert.AreEqual("abc.films", exp1.ToString());
            Assert.AreEqual("SpecialFilm", exp1.getType().getName());
        }
        public void testAssociationEndCallExp_07()
        {
            AstOclModelElementFactory factory1 = AstOclModelElementFactoryManager.getInstance(umlModel.getOclPackage());

            VariableDeclaration variable = factory1.createVariableDeclaration("abc", getClassifier("Reservation"), null);
            VariableExp         source   = factory1.createVariableExp(variable);

            CoreAssociationEnd assocEnd = getClassifier("Reservation").lookupAssociationEnd("Person");

            AssociationEndCallExp exp1 = factory1.createAssociationEndCallExp(source, assocEnd, null, null, true);

            Assert.AreEqual("abc.Person@pre", exp1.ToString());
            Assert.AreEqual("Person", exp1.getType().getName());
        }
        public void testIteratorExp()
        {
            AstOclModelElementFactory factory1 = AstOclModelElementFactoryManager.getInstance(umlModel.getOclPackage());

            VariableDeclaration variable = factory1.createVariableDeclaration("abc", getClassifier("Distributor"), null);
            VariableExp         source   = factory1.createVariableExp(variable);

            VariableDeclaration iter    = factory1.createVariableDeclaration("iter", getClassifier("SpecialFilm"), null);
            VariableExp         iterRef = factory1.createVariableExp(iter);

            CoreAttribute    attr = getClassifier("SpecialFilm").lookupAttribute("name");
            AttributeCallExp body = factory1.createAttributeCallExp(iterRef, attr, false);

            CoreClassifier setSpecialFilm = factory1.createSetType(getClassifier("SpecialFilm"));

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

            iterators.Add(iter);

            IteratorExp exp = factory1.createIteratorExp("select", setSpecialFilm, source, body, iterators);

            Assert.AreEqual("abc->select(iter : SpecialFilm | iter.name)", exp.ToString());
            Assert.AreEqual("Set(SpecialFilm)", exp.getType().getName());
        }
        public void testIfExp()
        {
            AstOclModelElementFactory factory1 = AstOclModelElementFactoryManager.getInstance(umlModel.getOclPackage());

            VariableDeclaration variable  = factory1.createVariableDeclaration("abc", getClassifier("Boolean"), null);
            VariableExp         condition = factory1.createVariableExp(variable);

            IntegerLiteralExp thenExp = factory1.createIntegerLiteralExp(100, getClassifier("Integer"));
            RealLiteralExp    elseExp = factory1.createRealLiteralExp("247.49", getClassifier("Real"));

            IfExp exp = factory1.createIfExp(condition, thenExp, elseExp);

            Assert.AreEqual("if abc then 100 else 247.49 endif", exp.ToString());
            Assert.AreEqual("Real", exp.getType().getName());
        }
        public void testAssociationEndCallExp_06()
        {
            AstOclModelElementFactory factory1 = AstOclModelElementFactoryManager.getInstance(umlModel.getOclPackage());

            VariableDeclaration variable = factory1.createVariableDeclaration("abc", getClassifier("Person"), null);
            VariableExp         source   = factory1.createVariableExp(variable);

            CoreAssociationEnd    bosses    = getClassifier("Person").lookupAssociationEnd("bosses");
            CoreAssociationEnd    employees = getClassifier("Person").lookupAssociationEnd("employees");
            AssociationEndCallExp sourceExp = factory1.createAssociationEndCallExp(source, bosses, employees, null,
                                                                                   false);

            CoreAssociationEnd    assocEnd = getClassifier("Person").lookupAssociationEnd("Reservation");
            AssociationEndCallExp exp      = factory1.createAssociationEndCallExp(sourceExp, assocEnd, null, null, false);

            Assert.AreEqual("abc.bosses.Reservation", exp.ToString());
            Assert.AreEqual("Sequence(Reservation)", exp.getType().getName());
        }
        public void fTest_01()
        {
            AstOclModelElementFactory factory1 = AstOclModelElementFactoryManager.getInstance(umlModel.getOclPackage());

            VariableDeclaration variable = factory1.createVariableDeclaration("abc", getClassifier("SpecialFilm"), null);
            VariableExp         source   = factory1.createVariableExp(variable);

            CoreClassifier c1 = getClassifier("SpecialFilm");

            CoreModel coreModel = c1.getModel();

            List <object> ass = coreModel.getAllAssociations();


            CoreClassifier c2    = getClassifier("Film");
            List <object>  core  = c1.getAllAssociationEnds();
            List <object>  core2 = c2.getAllAssociationEnds();

            var a = c2.lookupAssociationEnd("tapes");
        }
        public void testOperationCallExpWithAtPre()
        {
            AstOclModelElementFactory factory1 = AstOclModelElementFactoryManager.getInstance(umlModel.getOclPackage());

            VariableDeclaration variable = factory1.createVariableDeclaration("abc", getClassifier("Film"), null);
            VariableExp         source   = factory1.createVariableExp(variable);

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

            paramTypes.Add(getClassifier("Integer"));

            CoreOperation operation = getClassifier("Film").lookupOperation("getRentalFee", paramTypes);

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

            arguments.Add(factory1.createIntegerLiteralExp(100, getClassifier("Integer")));

            OperationCallExp exp = factory1.createOperationCallExp(source, operation, arguments,
                                                                   operation.getReturnType(), true);

            Assert.AreEqual("abc.getRentalFee@pre(100)", exp.ToString());
            Assert.AreEqual("Real", exp.getType().getName());
        }
        public void testLetExp()
        {
            AstOclModelElementFactory factory1 = AstOclModelElementFactoryManager.getInstance(umlModel.getOclPackage());

            OclExpression       initExp  = factory1.createIntegerLiteralExp(100, getClassifier("Integer"));
            VariableDeclaration variable = factory1.createVariableDeclaration("abc", getClassifier("Integer"), initExp);

            OclExpression varExp     = factory1.createVariableExp(variable);
            OclExpression intLiteral = factory1.createIntegerLiteralExp(200, getClassifier("Integer"));
            List <object> paramTypes = new List <object>();

            paramTypes.Add(getClassifier("Integer"));
            CoreOperation oper = getClassifier("Integer").lookupOperation("+", paramTypes);

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

            args.Add(intLiteral);
            OclExpression inExp = factory1.createOperationCallExp(varExp, oper, args, getClassifier("Integer"), false);

            LetExp exp = factory1.createLetExp(variable, inExp);

            Assert.AreEqual("let abc : Integer = 100 in abc + 200", exp.ToString());
            Assert.AreEqual("Integer", exp.getType().getName());
        }