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); }
protected void checkOperationCallType(OclExpression oclExpression, String typeName, String operationName, Type sourceClass, String sourceType, Object[] argTypes) { Assert.IsTrue(oclExpression is OperationCallExp); OperationCallExp exp = (OperationCallExp)oclExpression; Assert.AreEqual(typeName, exp.getType().getName()); Assert.IsTrue(exp.getReferredOperation().operationNameMatches(operationName)); if (sourceClass != null) { Assert.IsTrue(sourceClass.IsInstanceOfType(exp.getSource())); Assert.AreEqual(exp.getSource().getType().getName(), sourceType); } else { Assert.IsFalse(exp.getReferredOperation().isInstanceScope()); } if (argTypes == null) { Assert.AreEqual(0, exp.getArguments().Count); } else { Assert.AreEqual(argTypes.Length, exp.getArguments().Count); } }
protected OperationCallExp checkOperationCallExp(OclExpression oclExpression, String opName, String returnTypeName) { Assert.IsTrue(oclExpression is OperationCallExp); OperationCallExp opExp = (OperationCallExp)oclExpression; Assert.AreEqual(opName, opExp.getReferredOperation() != null ? opExp.getReferredOperation().getName() : opExp.getName()); // Assert.AreEqual(returnTypeName, opExp.getReferredOperation() != null? opExp.getReferredOperation().getReturnType().getName() : opExp.getType().getName()); Assert.AreEqual(returnTypeName, opExp.getType().getName()); return(opExp); }
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()); }