The major purpose of the tool is the perform consistency checking on a UML model. Specifically the tool performs model instantiation checking on two levels:
In this section we will provide examples for each of these cases to show how the tool can be used to perform the check.
For this example we will validate a user-defined class diagram against a UML profile, which is a UML metamodel extended with stereotypes. We note here that the tool does not expect a complete metamodel; rather, the developer can provide a partial metamodel with only the meta-elements the developer is focusing on. This means that meta-elements and their features as well as relationships between meta-elements can be left out if the user-defined model does not need to be checked for them.
The figure above is a partial metamodel of a UML profile where the focus is on the two stereotypes defined by the profile. As you can see, features of the meta-elements, as well as other meta-elements, are not provided. When the tool reads the instance diagram, the objects corresponding to meta-elements not provided in the profile will be ignored and not checked.
The figure above is an instance of the profile described earlier. This is a user-defined class diagram that uses the stereotypes defined by the profile. According to the profile, this is a correct instance because the stereotyped class c1 has exactly one attribute with the stereotype <<MyAttr>>, which matches the subset association between <<MyClass>> and <<MyAttr>> defined in the profile. The figure below shows the output of the tool when executed on the UML model containing the simple profile and the user-defined class diagram. It shows that there are no errors with the instance diagram, and since there are no OCL constraints in the profile, there are no constraints violations either.
In this example we have a user-defined class diagram as shown in the figure below. This class-diagram defines an custom enumeration using the notation for an enumeration defined previously.
This class diagram also contains a number of OCL constraints, but for the purpose of this example we will show just one of them in the next figure. The constraint specifies that the an instructor with the rank of Assistant Professor can only teach courses whose course number is less than 600.
Next we show an object diagram based on this user-defined class diagram. Because the popular modeling software Rational Rose does not support object diagrams, we have to use collaboration diagrams instead to represent one. Objects are represented using classifier roles while links between objects are represented using association roles. There are five objects in this example object diagram.
We will now look at the slot values defined for the Instructor object named DrAlice. Notice that her rank is Assistant Professor, which violates the OCL constraint we just talked about because there is a link between the object DrAlice and the object CS660, which is a course with the cource number 660. When our tool is run on this UML model, we get the error as shown in the next figure. The particular constraint that is violated is displayed so the user can attempt to track the problem down.