An assert constraint usage specifies that the result of a given constraint must always be true. If, at any point, the assert constraint evaluates to anything other than its asserted value, it indicates a logical inconsistency within the model.

There are two ways a constraint can be asserted:

Asserting a constraint by referencing a constraint defined elsewhere in the model

Asserting constraints via the Textual Editor

To assert constraints via the Textual Editor


  1. In the body of an element for which you want to reference a constraint, declare one of the following:
    1. For an unnamed assert constraint, declare the assert keyword, then follow with the name of the constraint you want to reference.
    2. For a named assert constraint, declare the assert constraint keyword, name the new usage, and then reference subset the constraint you want to reference.

      To negate an assert constraint usage, specify the not keyword after the assert keyword, e.g., assert not constraint.

  2. Specify the constraint (expression, attributes, etc.) in the element's body.
  3. Click the Synchronize button.

constraint def MassLimit {
    attribute mass : MassValue;
    attribute massLimit : MassValue;
    mass <= massLimit
}
assert constraint massIsPositive {
    attribute mass : MassValue;
    mass > 0 [kilogram]
}

part vehicle {
    attribute massActual : MassValue;
    attribute massRequired : MassValue;

    assert massIsPositive { :>> mass = massRequired; }                                                  // step 1.a - unnamed usage reference subsets another constraint usage

    assert constraint positiveMass ::> massIsPositive { :>> mass = massRequired; }      // step 1.b - named usage reference subsets another constraint usage


    assert not massIsPositive { :>> mass = massRequired; }                                           // negated assert usage
}

Asserting constraints via the Drag and Drop handler in a view

To assert constraints via the Drag and Drop handler in a view


  • Drag and drop an assert constraint element from the Containment tree or use its symbol's Drag and Drop handler and drop it on:
    • the requirement element symbol that you want to assert the constraint by referencing it using the Create Assert Constraint command. 
    • the assert constraint symbol that you want to assert by referencing the constraint using the Set Asserted Constraint command.

Asserting constraints via the Specification panel

To assert constraints via the Specification panel


  • Drag and drop an assert constraint element from the Containment tree or use its symbol's Drag and Drop handler and drop it on the Asserted Constraint field in the Properties section of the Specification panel for the assert constraint element. 
    The appropriate constraint is specified for the element.

Asserting constraints via the view palette

To assert constraints via the view palette


  1. In the view palette, under the Requirements/Constraints group, click assert.

    If the needed button is not displayed, click the down-facing arrow next to the assert constraint button and select the needed button in the dropdown menu.

  2. Do one of the following:
    1. To assert an existing constraint, in the view pane, click on the source element symbol, then on the constraint element symbol. 
    2. To assert a new constraint, in the view pane, click on the source element symbol, then elsewhere in the view pane to create a constraint element symbol. 
      The assert path is drawn between the element symbols.

Asserting constraints via the Create Relation command

To assert constraints via the Create Relation command


  1. Right-click on the client (source) element.
  2. In the shortcut menu, click Create Relation, then in the submenu, under Outgoing, click assert. The Create... dialog opens.
  3. In the Create... dialog, do one of the following:
    1. In a view, click the element symbol you want to be the supplier (target). Hold Shift to select multiple elements.
    2. Click the Add button. The element selection dialog opens. In the element selection dialog, select the element you want to be the supplier (target) and click OK.
    3. Drag and drop the needed element you want to be the supplier (target) from the Containment tree onto the Create... dialog.
  4. In the Create... dialog, click OK

Asserting constraints via the Specification panel

To assert constraints via the Specification panel


  • Drag and drop a constraint element from the Containment tree or use its symbol's Drag and Drop handler and drop it on the Asserted Constraint field in the Properties section of the Specification panel for the assert constraint usage. 
    The appropriate constraint is specified for the element.

Asserting a constraint via the owned assert constraint usage itself as the asserted constraint

Asserting constraints via the Textual Editor

To assert constraints via the Textual Editor


  1. In the Textual Editor, place the cursor where you want to create the element and declare the keyword assert constraint for an assert constraint usage.

    To negate an assert constraint usage, specify the not keyword after the assert keyword, e.g., assert not constraint.

  2. Specify the element name.
  3. Specify the constraint (expression, attributes, etc.) in the element's body.
  4. Click the Synchronize button.

part vehicle {
    attribute massActual : MassValue;
    attribute massRequired : MassValue;

    assert constraint massIsPositive { massActual <= massRequired }           // named assert constraint usage
    assert constraint { massActual <= massRequired }                                    // unnamed assert constraint usage
    assert not constraint massIsPositive { massActual <= massRequired }    // named and negated assert constraint usage

}

Asserting constraints via the Create Element command

To assert constraints via the Create Element command


  1. In the Containment tree, right-click an element, and in the shortcut menu, click Create Element.

  2. In the Create Element dialog, click assert constraint to create an assert constraint usage element.
  3. Name the element.
  4. Specify the constraint (expression, attributes, etc.).

Asserting constraints via the view palette

To assert constraints via the view palette


  1. In the view palette, under the Requirements/Constraints group, click the assert constraint button to create an assert constraint usage element.
  2. Click in the view pane where you want to create the constraint.
  3. Specify the constraint (expression, attributes, etc.).

Asserting constraints via the symbol compartment in a view

For more information, see the Compartments page.

To assert constraints via the symbol compartment in a view


  1. Do one of the following:
    1. Select an element symbol and click the Create Element button on it. In the dropdown menu, click the assert constraint element.
    2. Select an element symbol and on the right side of the assert constraints compartment, click the Create assert constraint button.
  2. Specify the constraint (expression, attributes, etc.).
    The new element is created and displayed in the assert constraints compartment.

Asserting constraints via the Specification panel

To assert constraints via the Specification panel


  1. Open the Specification panel.
  2. Do one of the following:
    1. In the Properties section bar, click the Create Element button. The shortcut menu appears. Click the assert constraint element in the shortcut menu.
    2. In the assert constraints compartment section's bar, click the Create assert constraint  button.
  3. Specify the constraint (expression, attributes, etc.).
    The element is created in the assert constraints compartment.