Exemplo n.º 1
0
        public void testNewAttributeOK_03()
        {
            doTestContextOK("context Film def: newAttr : Integer = 10  def: newAttr2 : Boolean = true",
                            getCurrentMethodName());
            CoreClassifier film = (CoreClassifier)environment.lookup("Film");

            Assert.IsNotNull((CoreAttribute)film.lookupAttribute("newAttr"));
            OclDeriveConstraint constraint = (OclDeriveConstraint)film.getDeriveConstraint("newAttr");

            Assert.IsNotNull(constraint);
            Assert.AreEqual("Integer", ((ExpressionInOclImpl)constraint.getExpression()).getBodyExpression().getType().getName());

            Assert.IsNotNull((CoreAttribute)film.lookupAttribute("newAttr2"));
            constraint = (OclDeriveConstraint)film.getDeriveConstraint("newAttr2");
            Assert.IsNotNull(constraint);
            Assert.AreEqual("Boolean", ((ExpressionInOclImpl)constraint.getExpression()).getBodyExpression().getType().getName());
        }
Exemplo n.º 2
0
        public void testNewAttribute_01()
        {
            doTestManyContextOK("context Film def: newAttr : Integer = 10 context SpecialFilm inv: newAttr > 10",
                                getCurrentMethodName());
            CoreClassifier      film       = (CoreClassifier)environment.lookup("Film");
            OclDeriveConstraint constraint = (OclDeriveConstraint)film.getDeriveConstraint("newAttr");

            Assert.IsNotNull(constraint);
            Assert.AreEqual("Integer", ((ExpressionInOclImpl)constraint.getExpression()).getBodyExpression().getType().getName());
        }
Exemplo n.º 3
0
        public void testNewAttributeOK_02()
        {
            doTestContextNotOK("context Film def: newAttr : Integer = true",
                               getCurrentMethodName());
            CoreClassifier film = (CoreClassifier)environment.lookup("Film");
            CoreAttribute  attr = (CoreAttribute)film.lookupAttribute("newAttr");

            Assert.IsNotNull(attr);
            Assert.AreEqual("Integer", attr.getFeatureType().getName());
            Assert.IsNull(film.getDeriveConstraint("newAttr"));
        }
Exemplo n.º 4
0
        public Object[] getOwnedElements()
        {
            List <object> allOwnedElements = new List <object>();
            OclConstraint constraint;

            constraint = owner.getInitConstraint(this.getName());
            if (constraint != null)
            {
                allOwnedElements.Add(constraint);
            }

            constraint = owner.getDeriveConstraint(this.getName());
            if (constraint != null)
            {
                allOwnedElements.Add(constraint);
            }

            return(allOwnedElements.ToArray());
        }