#!/usr/bin/env python

import coral
import coral.modeler
import coral.modeler.modeler
import coral.addins.constraint.engine as E

prj=coral.loadDocument("testGetConstraintObjects.xml")

for root in prj.contents():
    for part in root.__getAllParts__():
        if part.oclIsKindOf(coral.lang.CONSTRAINT10.ConstraintModel):
            CM=part
        

E.loadConstraintModel(CM)
assert len(E.__engine__.getConstraints(CM,coral.lang.UML14.Class())) == 31
assert len(E.__engine__.getConstraints(CM,coral.lang.UML14.Class())) == 31
CM.constraint.resetSlot()
#constraints are buffered
assert len(E.__engine__.getConstraints(CM,coral.lang.UML14.Class())) == 31
E.__engine__.type2constraintObjects={}
assert len(E.__engine__.getConstraints(CM,coral.lang.UML14.Class())) == 0
