Commit ed424308 authored by Philip Makedonski's avatar Philip Makedonski
Browse files

+ constraints implementation fixes

parent 1067a4f3
Loading
Loading
Loading
Loading
+11 −7
Original line number Diff line number Diff line
@@ -280,7 +280,7 @@ context StructuredDataInstance {
  //'union' constraint on the type of the 'StructuredDataInstance'
  constraint StructuredDataInstanceUnionConstraint {
    //TODO: check if there is till a problem
    check:     not self.dataType.allConstraints->exists(c | c.type.name = 'union')
    check:     not self.dataType.allConstraints()->exists(c | c.type.name = 'union')  //TODO: add ()
          or self.memberAssignment->size() <= 1
    message:   self.prefix() + 
               "If the 'dataType' of the 'StructuredDataInstance' has the predefined constraint 'union' then the 'memberAssignment' shall not contain more than one 'MemberAssignment'."
@@ -288,10 +288,12 @@ context StructuredDataInstance {

  //'uniontype' constraint on the type of the 'StructuredDataInstance'
  constraint StructuredDataInstanceUniontypeConstraint {
    check:     not self.dataType.allConstraints->exists(c | c.type.name = 'uniontype')
          or self.memberAssignment->forAll(m | self.dataType.member->contains(m) //TODO: fix . to ->
              or self.dataType.extension->one(e | 
                  e.extending.oclAsType(StructuredDataType).allMembers()->contains(m)))
    check:     not self.dataType.allConstraints()->exists(c | c.type.name = 'uniontype') //TODO: add ()
    //TODO: condition needed to be revised
          or self.memberAssignment->collect(m | m.member.container())->excluding(self.dataType)->size() < 2
//          or self.memberAssignment->forAll(m | self.dataType.oclAsType(StructuredDataType).member->includes(m.member) //TODO: fix . to ->; contains -> includes; m -> m.member; add oclAstType(StructuredDataType)
//              or self.dataType.oclAsType(StructuredDataType).extension->one(e | 
//                  e.extending.oclAsType(StructuredDataType).allMembers()->includes(m.member))) //TODO: fix contains -> includes; m -> m.member; add oclAstType(StructuredDataType)
    message:   self.prefix() + 
               "If the 'dataType' of 'StructuredDataInstance' has the predefined constraint 'uniontype' then there shall only be 'MemberAssignment' for the 'Member's of the 'dataType' itself or of at most one of the 'StructuredDataType's which the 'dataType' is extending."
  }
@@ -621,7 +623,7 @@ context LiteralValueUse {

  //Integer type for integer value
  constraint LiteralValueIntType {
    check:     not self.intValue.oclIsUndefined() 
    check:     not self.intValue.oclIsUndefined() //TODO: weird caching issues..
          implies (self.dataType.oclIsUndefined() or self.dataType.conformsTo('Integer'))
    message:   self.prefix() + 
               "If 'intValue' is specified then the 'dataType' is either unspecified or the specified 'DataType' conforms to predefined type 'Integer'."
@@ -970,8 +972,10 @@ context Block {
  //Guard for each participating tester in locally ordered test descriptions
  constraint GuardsForParticipatingComponents {
    //TODO: Enum::Literal not supported -> use Enum#Literal
    check:     self.getParticipatingComponents()->reject(c | c.role = ComponentInstanceRole#SUT)
    check:     (not self.`guard`.isEmpty() implies //TODO: constraint shall be relaxed when there are no guards
                self.getParticipatingComponents()->reject(c | c.role = ComponentInstanceRole#SUT)
              ->forAll(c | self.`guard`->exists(ex | ex.scope = c)) //TODO: renamed componentInstance to scope
          )
          or not self.getParentTestDescription().isLocallyOrdered
    message:   self.prefix() + 
               "If the 'Block' is contained in a locally ordered 'TestDescription' then a guard shall be specified for every participating 'ComponentInstance' in the associated 'TestConfiguration' that has the role 'Tester' or there shall be no guards at all. "