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 testCollectionLiteralExp() { AstOclModelElementFactory factory1 = AstOclModelElementFactoryManager.getInstance(umlModel.getOclPackage()); CollectionLiteralExp exp = factory1.createCollectionLiteralExp(createCollectionParts(), factory1.createSetType( getClassifier("Integer"))); Assert.AreEqual("Set{ 100, 200, 300 }", exp.ToString()); Assert.AreEqual("Set(Integer)", exp.getType().getName()); CollectionLiteralExp exp2 = factory1.createCollectionLiteralExp(createCollectionParts(), factory1.createSetType( getClassifier("Integer"))); Assert.AreEqual("Set{ 100, 200, 300 }", exp2.ToString()); Assert.AreEqual("Set(Integer)", exp2.getType().getName()); exp = factory1.createCollectionLiteralExp(createCollectionParts(), factory1.createBagType(getClassifier("Integer"))); Assert.AreEqual("Bag{ 100, 200, 300 }", exp.ToString()); Assert.AreEqual("Bag(Integer)", exp.getType().getName()); exp = factory1.createCollectionLiteralExp(createCollectionParts(), factory1.createSequenceType(getClassifier("Integer"))); Assert.AreEqual("Sequence{ 100, 200, 300 }", exp.ToString()); Assert.AreEqual("Sequence(Integer)", exp.getType().getName()); exp = factory1.createCollectionLiteralExp(createCollectionParts(), factory1.createOrderedSetType(getClassifier("Integer"))); Assert.AreEqual("OrderedSet{ 100, 200, 300 }", exp.ToString()); Assert.AreEqual("OrderedSet(Integer)", exp.getType().getName()); OclExpression elem1 = factory1.createIntegerLiteralExp(100, getClassifier("Integer")); OclExpression elem2 = factory1.createIntegerLiteralExp(200, getClassifier("Integer")); CollectionRange range = factory1.createCollectionRange(elem1, elem2); List <object> parts = new List <object> (); parts.Add(range); exp = factory1.createCollectionLiteralExp(parts, factory1.createSetType(getClassifier("Integer"))); Assert.AreEqual("Set{ 100 .. 200 }", exp.ToString()); Assert.AreEqual("Set(Integer)", exp.getType().getName()); }