Issues with OCL Constraints
Multiple issues with OCL constraints:
-
Fix and test implementation -
Update specification -
Split into separate issues?
In detail:
- DataInstanceOrArgumentsOrItemsInDataElementUse - if a reference to structured or collection data instance is used as the data element, it should not be necessary to provide arguments or items.
and not (self.dataElement.oclIsKindOf(StructuredDataType) and self.argument->isEmpty())
and not (self.dataElement.oclIsKindOf(CollectionDataType) and self.item->isEmpty())
Shall be instead:
and (self.dataElement.oclIsKindOf(StructuredDataInstance) or not (self.resolveDataType().oclIsKindOf(StructuredDataType) and self.argument->isEmpty()))
and (self.dataElement.oclIsKindOf(CollectionDataInstance) or not (self.resolveDataType().oclIsKindOf(CollectionDataType) and self.item->isEmpty()))
- GuardType: allow for data types extending boolean (use conforms to instead)
self.guard ->forAll(g | g.expression.resolveDataType().name = 'Boolean')
Shall be instead
self.guard ->forAll(g | g.expression.resolveDataType().conformsTo('Boolean'))
- BoundedGuard: Incorrect constraint (there is only one block, its guard shall be empty instead)
self.block->forAll(b | b.guard.oclIsUndefined())
Shall be instead
self.block.guard->isEmpty()
- ConditionalFirstGuard: Incorrect constraint (minimum number of guard expressions)
self.block->size() > 1 or self.block->first().guard->size() > 1
Shall be instead
self.block->size() > 1 or self.block->first().guard->size() > 0