public void testIteratorExp_01() { List <object> constraints = doTestContextOK("context Film inv: self.tapes.theFilm = self.tapes.theFilm", getCurrentMethodName()); OclExpression oclExpression = getConstraintExpression(constraints); IteratorExp exp = checkIteratorExp(((OperationCallExp)oclExpression).getSource(), "Bag(Film)", "collect", "Tape", "iterator"); checkAssociationEndCallExp(exp.getBody(), "theFilm", "Film"); checkImplicitSource((PropertyCallExp)exp.getBody(), "iterator", "Tape"); checkAssociationEndCallExp(exp.getSource(), "tapes", "Set(Tape)"); checkImplicitSource((PropertyCallExp)exp.getSource(), "self", "Film"); }
public void testOperationCall_09() { List <object> constraints = doTestContextOK("context Film inv: self.getTapes().theFilm.getTapes().number = self.getTapes().theFilm.getTapes().number", getCurrentMethodName()); OclExpression oclExpression = ((OperationCallExp)getConstraintExpression(constraints)).getSource(); IteratorExp exp = checkIteratorExp(oclExpression, "Bag(Integer)", "collect", "Tape", "iterator"); checkIteratorExp(exp.getSource(), "Bag(Tape)", "collect", "Film", "iterator"); checkIteratorExp(((IteratorExp)exp.getSource()).getSource(), "Bag(Film)", "collect", "Tape", "iterator"); checkAttributeCallExp(exp.getBody(), "number", "Integer"); checkImplicitSource((PropertyCallExp)exp.getBody(), "iterator", "Tape"); }
public void testCollectTuple_01() { List <object> constraints = doTestContextOK("context Film inv: self.Reservation.Person->collect(Tuple{a = age, b : Sequence(Integer) = bosses.age->asSequence()})->exists(x | x.a > 10)", getCurrentMethodName()); OclExpression oclExpression = getConstraintExpression(constraints); IteratorExp exp = checkIteratorExp(oclExpression, "Boolean", "exists", "Tuple(a : Integer, b : Sequence(Integer))", "x"); Assert.IsTrue(exp.getBody() is OperationCallExp); checkOperationCallExp(exp.getBody(), ">", "Boolean"); checkIteratorExp(exp.getSource(), "Bag(Tuple(a : Integer, b : Sequence(Integer)))", "collect", "Person", "iterator"); Assert.IsTrue(((IteratorExp)exp.getSource()).getBody() is TupleLiteralExp); }
public void testImplicitCollect_06() { List <object> constraints = doTestContextOK("context Film inv: self.Reservation.Person.EmployeeRanking[bosses]->exists( x | x.score > 5)", getCurrentMethodName()); OclExpression oclExpression = getConstraintExpression(constraints); IteratorExp exp = checkIteratorExp(oclExpression, "Boolean", "exists", "EmployeeRanking", "x"); Assert.IsTrue(exp.getBody() is OperationCallExp); checkOperationCallExp(exp.getBody(), ">", "Boolean"); checkIteratorExp(exp.getSource(), "Bag(EmployeeRanking)", "collect", "Person", "iterator"); Assert.IsTrue(((IteratorExp)exp.getSource()).getBody() is AssociationClassCallExp); }
public void testIteratorExp_02() { List <object> constraints = doTestContextOK("context Rental inv: self.itens.Rental = self.itens.Rental", getCurrentMethodName()); OclExpression oclExpression = getConstraintExpression(constraints); IteratorExp exp = checkIteratorExp(((OperationCallExp)oclExpression).getSource(), "Sequence(Rental)", "collect", "RentalItem", "iterator"); checkAssociationEndCallExp(exp.getBody(), "Rental", "Rental"); checkImplicitSource((PropertyCallExp)exp.getBody(), "iterator", "RentalItem"); checkAssociationEndCallExp(exp.getSource(), "itens", "OrderedSet(RentalItem)"); checkImplicitSource((PropertyCallExp)exp.getSource(), "self", "Rental"); }
public void testImplicitCollect_04() { List <object> constraints = doTestContextOK("context Tape inv: self.theFilm.getTapes().theFilm.getTapes()->exists( x | x.number > 5)", getCurrentMethodName()); OclExpression oclExpression = getConstraintExpression(constraints); IteratorExp exp = checkIteratorExp(oclExpression, "Boolean", "exists", "Tape", "x"); Assert.IsTrue(exp.getBody() is OperationCallExp); checkOperationCallExp(exp.getBody(), ">", "Boolean"); checkIteratorExp(exp.getSource(), "Bag(Tape)", "collect", "Film", "iterator"); Assert.IsTrue(((IteratorExp)exp.getSource()).getBody() is OperationCallExp); }
public void testImplicitCollect_02() { List <object> constraints = doTestContextOK("context Client inv : self.Rental.maxDaysToReturn->exists(x | x > 5)", getCurrentMethodName()); OclExpression oclExpression = getConstraintExpression(constraints); IteratorExp exp = checkIteratorExp(oclExpression, "Boolean", "exists", "Integer", "x"); Assert.IsTrue(exp.getBody() is OperationCallExp); checkOperationCallExp(exp.getBody(), ">", "Boolean"); checkIteratorExp(exp.getSource(), "Bag(Integer)", "collect", "Rental", "iterator"); Assert.IsTrue(((IteratorExp)exp.getSource()).getBody() is AttributeCallExp); }
public void testImplicitCollect_01() { List <object> constraints = doTestContextOK("context Client inv : self.Rental.itens->exists(i | i.number = 1)", getCurrentMethodName()); OclExpression oclExpression = getConstraintExpression(constraints); IteratorExp exp = checkIteratorExp(oclExpression, "Boolean", "exists", "RentalItem", "i"); Assert.IsTrue(exp.getBody() is OperationCallExp); checkOperationCallExp(exp.getBody(), "=", "Boolean"); checkIteratorExp(exp.getSource(), "Sequence(RentalItem)", "collect", "Rental", "iterator"); Assert.IsTrue(((IteratorExp)exp.getSource()).getBody() is AssociationEndCallExp); }
public void testCollect_02() { List <object> constraints = doTestContextOK("context Rental inv: self.itens->collect(number)->notEmpty()", getCurrentMethodName()); OclExpression oclExpression = getConstraintExpression(constraints); IteratorExp exp = checkIteratorExp(((ModelPropertyCallExp)oclExpression).getSource(), "Sequence(String)", "collect", "RentalItem", "iterator"); Console.WriteLine("source = " + exp.getSource().getType().getName()); Assert.IsTrue(((ModelPropertyCallExp)oclExpression).getSource() is IteratorExp); }