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 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 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()); }