Consistency Checking

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:

  1. Validating a user-defined model against the UML metamodel.
  2. Validating an object diagram against a user-defined class diagram.

In this section we will provide examples for each of these cases to show how the tool can be used to perform the check.

Validating Against a UML Metamodel

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.

A partial metamodel representing a UML profile
profile

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.

A user-defined class diagram which is an instance of a profile
instance of a profile

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.

Output of validating a user-defined class diagram against a profile
profile checking output

Validating Against a User-Defined Class Diagram

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.

A user-defined class diagram
example user-defined class diagram

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.

An OCL constraint in the user-defined class diagram
OCL constraint in user-defined class diagram

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.

An object diagram based on the user-defined class diagram
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.

Slot values for the Instructor object
object diagram slot value
Output of checking object diagram with user-defined class diagram
object-class diagram checking output